What's the coordinates after a rotation?

64 Views Asked by At

I have the coordinates of a rectangle inside a frame, let's call those (r1, c1). More precisely, they are the coordinates of top left corner (yellow dot) relative to top left corner of the frame (the 1 on the picture).

enter image description here

Then I rotate the center of the frame 90 degrees, and now I want to know the new rectangle coordinates, the top left (red dot) coordinates relative to frame's top left corner (the 2 on the picture). How do I compute those new coordinates (r2, c2) knowing (r1, c1) and rotation angle?

The frame has width W and height H while the rectangle has width w and height h.

enter image description here

1

There are 1 best solutions below

0
On BEST ANSWER

I am not sure about which axis is which in computer graphics but let's take $(0,0)$ to be the upper left hand corner in your original drawing and let $(l,w)$ be the lower right hand corner where the first coordinate is taken to be the distance from the top to the bottom and the second coordinate is taken to be the distance from the left to the right.

Then the yellow dot on the small rectangle has coordinates $(x,y)$ and the origin gets moved to $(0,l)$ and the yellow dot gets moved to $(y, l-x)$.