Hi.
Hope you can help me with a little confusing math problem.
I have a rectangle with length 2 and height 1 and want to make a raycast from each corner of it. When the rectangle has no rotation I can calculate the points of the corners by:
leftBottom.x = -(rigidbody.collider.bounds.extents.x - 0.1f);
leftBottom.y = -(rigidbody.collider.bounds.extents.y - 0.1f);
leftBottom = transform.TransformPoint(leftBottom);
leftTop.x = - (rigidbody.collider.bounds.extents.x - 0.1f);
leftTop.y = (rigidbody.collider.bounds.extents.y - 0.1f);
leftTop = transform.TransformPoint(leftTop);
rightBottom.x = (rigidbody.collider.bounds.extents.x - 0.1f);
rightBottom.y = - (rigidbody.collider.bounds.extents.y - 0.1f);
rightBottom = transform.TransformPoint(rightBottom);
rightTop.x = (rigidbody.collider.bounds.extents.x - 0.1f);
rightTop.y = (rigidbody.collider.bounds.extents.y - 0.1f);
rightTop = transform.TransformPoint(rightTop);
This works well. But if my rectangle rotates (e.g. 90°) then the calculated points are the same as no rotation would be given.
How do I have to add the rotation to this to get the correct rotated corner points?
Any help is appreciated