How to find the coordinates of the vertices of the rotated rectangle in two-dimensional space?

5b545d58f1e89205316263.png
There is a rectangle of known length and width, and the angle of rotation. The axis of rotation in the center. Of this rectangle.
How do I find the coordinates of the vertices of this rectangle.
Found on the Wikipedia article
It describes the formula of rotation in two-dimensional space, I do not understand how to use it.
5b545f85ba5c9318273004.png

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 as there is some function that returns the coordinates?
If not then how to find them
June 3rd 19 at 19:05
1 answer
June 3rd 19 at 19:07
Solution
5b5481f04e365599950422.png
For example - let's rotate the rectangle on 90gradusov, its width is 6, height 4.
Since it is known that the point of rotation in the center - easy to find the coordinates of dividing the width and height in half
A(x, y) - Ah = 0(coordinate) - (6 / 2), Ay = 0 + (4 / 2) A(-3, 2)
In(x, y) - BX = 0(coordinate) + (6 / 2), Wu = 0 + (4 / 2) and(3, 2)
With(x, y) - CX = 0(coordinate) + (6 / 2), su = 0 - (4 / 2) C(3, -2)
D(x, y) Dx = 0(coordinate) - (6 / 2), Dy = 0 - (4 / 2) D(-3, -2)

Find a point after rotation
in Your formula
Ah = -3 * cos90 - 2 * sin90 = -3 * 0 - 2 * 1 = -2
Ay = -3 * sin90 + 2 *cos90 = -3 * 1 + 2 * 0 = -3

A(x, y) = (-2, -3);

The same actions done with all points, and figures, where possible, rounded
So?

var x1 = (-obj.width/2)*Math.cos(rott)-(obj.height/2)*Math.sin(rott);
var y1 = (-obj.width/2)*Math.sin(rott)+(obj.height/2)*Math.cos(rott);

var x2 = (obj.width/2)*Math.cos(rott)-(obj.height/2)*Math.sin(rott);
var y2 = (obj.width/2)*Math.sin(rott)+(obj.height/2)*Math.cos(rott);

var x3 = (obj.width/2)*Math.cos(rott)-(-obj.height/2)*Math.sin(rott);
var y3 = (obj.width/2)*Math.sin(rott)+(-obj.height/2)*Math.cos(rott);

var x4 = (-obj.width/2)*Math.cos(rott)-(-obj.height/2)*Math.sin(rott);
var y4 = (-obj.width/2)*Math.sin(rott)+(-obj.height/2)*Math.cos(rott); - emerald.Kuphal commented on June 3rd 19 at 19:10
So. And the rotation angles in radians you need to translate, because JavaScript only understands Math in radians, if I'm not mistaken - amy commented on June 3rd 19 at 19:13

Find more questions by tags ActionScriptGeometry