Find 3 remaining points of a rectangle given the angle in 2d space

90 Views Asked by At

If you have a point on a window where the top left is 0,0 and bottom right is 100,100 for a 100 pixel window. (This is only for reference in the coordinate system that I am using). And I have a rectangle that I want to draw at an angle relative to the top left corner of it. How would I find the 3 remaining points to draw this correctly?

Note: This question is purely math and is asking nothing of programming.

1

There are 1 best solutions below

0
On

Given a point on the rectangle $(x_0,y_0)$, an angle $\alpha$ "below horizontal" of the length, and the length and width dimensions $l,w$ :

$(x_1,y_1) = (x_0+l\cdot \cos \alpha,\ y_0+l\cdot \sin\alpha)$
$(x_3,y_3) = (x_0-w\cdot \sin\alpha,\ y_0+w\cdot \cos \alpha)$
$(x_2,y_2) = (x_1+x_3-x_0,\ y_1+y_3-y_0)$