T
T
Tanyel2018-07-22 13:44:36
Geometry
Tanyel, 2018-07-22 13:44:36

How to find the vertex coordinates of a rotated rectangle in 2D space?

5b545d58f1e89205316263.png
There is a rectangle known for its length and width, and the angle of rotation. Axis of rotation in the center. This rectangle.
How do I find the coordinates of the vertices of this rectangle. I found an article
on Wikipedia . It describes the rotation formula in two-dimensional space, I did not understand how to use it. you need something like: var a_x = ... var a_y = ... var b_x = ... var b_y = ... var c_x = ... var c_y = ... var d_x = ... var d_y = ... Maybe in as there is some function that returns the coordinates? If not, how do you find them?
5b545f85ba5c9318273004.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xidjex, 2018-07-22
@Tanyel

5b5481f04e365599950422.png
For example - let's rotate the rectangle by 90 degrees, its width will be 6, height 4.
Since it is known that the pivot point is in the center - we can easily find the coordinates by dividing the width and height in half
A (x, y) - Ax \u003d 0 (coordinate) - ( 6 / 2), Ay \u003d 0 + (4 / 2) A (-3, 2)
B (x, y) - Bx \u003d 0 (coordinate) + (6 / 2), Wu \u003d 0 + (4 / 2) B(3, 2)
C(x, y) - Cx = 0(coordinate) + (6 / 2), Cy = 0 - (4 / 2) C(3, -2)
D(x, y) - Dx = 0(coordinate) - (6 / 2), Dy = 0 - (4 / 2) D(-3, -2)
Find point A after rotation
according to your formula
Ax = -3 * cos90 - 2 * sin90 = -3 * 0 - 2 * 1 = -2
Ay = -3 * sin90 + 2 *cos90 = -3 * 1 + 2 * 0 = -3
A(x, y) = (-2, -3);
We do the same actions with all points, and round the numbers if possible.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question