# rotating a rectangle via a rotation matrix

I want to rotate a 2D rectangle using a rotation matrix. After the rotation, I want the points (x, y) of the rectangle to be:

(625.49939, 632.40015) top left
(636.49939, 632.40015) top right
(636.49939, 672.40015) bottom right
(625.49939, 672.40015) bottom left


Before the rectangle is rotated, it appears 40 units wide and 11 units tall. After the rotation, it will appear 11 units wide and 40 units tall.

I know that I have to rotate it 90 degrees, but how can I find exactly where to place the rectangle before the rotation so that it ends up in my desired position?

1. The rectangle starts in position ??? so that it appears 40 units wide and 11 units tall
2. The rectangle will be rotated 90 degrees clockwise (at its center point).
3. The rectangle ends with the coordinates listed above.

How do I find the starting coordinates?

-

One way for you to do this would be to center in on the fact that the center point doesn't change in a rotation. So find the center of the rectangle. Let's call it $(x,y)$ (although it's very easy to find).
Then, make it so that you can pretend your rectangle is at the origin. That is, subtract the center coordinates from each of the corners, so that you get for instance $(625.49939 - x,632.40015 - y)$ as one of the corners.
Then you can apply the standard rotation matrices to these coordinates. Since you have the coordinates after the rotation, you would use the rotation matrix that rotates by $-90^\circ$. This will rotate the rectangle.