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.

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

asked June 3rd 19 at 19:05

1 answer

answered on

Solution

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

Find more questions by tags ActionScriptGeometry

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