# Rotating a Rectangle Help

• Aug 13th 2008, 05:43 AM
nickd_101
Rotating a Rectangle Help
Hello,
I'm trying to work on rotating a rectangle for some computer code. I know the top left and right co-ordinates and the rectangle size, but I'm trying to figure out how I'd determine the relative co-ordinates of the bottom points that would be joined to create the rectangle. Is there a formula for this?

I haven't done maths in a while so please excuse me if this is straightforward!

Thanks
• Aug 13th 2008, 06:44 AM
Chop Suey
You can use a rotation matrix.

Suppose you have a point P(x,y). Let the image point be B(x,y) after a rotation of $\displaystyle \theta$ radians. The coordinates of the image point can be found by matrix multiplication:

$\displaystyle \left[ {\begin{array}{*{20}c} {\cos{\theta}} & {-\sin{\theta}} \\ {\sin{\theta}} & {\cos{\theta}} \\ \end{array}}\right] \left[ {\begin{array}{*{20}c} {x} \\ {y} \\ \end{array}} \right] = \left[ {\begin{array}{*{20}c} {x'} \\ {y'} \\ \end{array}} \right]$