[Math] Given two corners of a rectangle, and an angle of rotation, is it possible to calculate the position of the other corners

geometrytrigonometry

Given two co-ordinates, representing opposite corners of a rectangle, and an angle of rotation that the original rectangle was rotated about the center, is it possible to calculate the position of the other two corners in order to re-create the original rectangle, but now rotated?

To clarify – I know the original rectangle had two sides perpendicular to the x-axis and two perpendicular to the y-axis…

So lets say we have a rectangle with a longer side perpendicular to the x-axis. We rotate it by 20 degrees clockwise about its center. We store the coordinates of what was the top right and the bottom left corners and the angle we rotated (20 degrees, and the assumption it was clockwise). Given just these new co-ordinates and the knowledge that we rotated by 20 degrees, is it possible to calculate the location of the other two corners. If so, can you provide me some steps to do so?

So in the picture below I know E, D' and B' and the Angle between the lines E-D and E-D'. Is it possible to calculate A' and C' with just those bits of knowledge?

enter image description here

Best Answer

Assuming that the vertices $A,B,C$ and $D$ are oriented as in your diagram, and $\theta$ measures the anticlockwise rotation:

Given $B'=(a',b')$ and $D'(c',d')$:

  1. Translate coordinate system so that the rectangle's center is at the origin: $$E' = (B' + D') / 2$$ $$B'_T = B' - E', \qquad D'_T = D' - E'$$

  2. Rotate coordinate system so that the rectangle is oriented with its sides parallel to the $x,y$ axes (i.e. undo the rotation): $$B_T=\left(\begin{matrix} a_T \\ b_T\end{matrix}\right) = \left( \begin{matrix} \cos \theta & \sin \theta \\ -\sin \theta & \cos \theta \end{matrix}\right)\left(\begin{matrix} a'_T \\ b'_T\end{matrix}\right), \quad D_T=\left(\begin{matrix} c_T \\ d_T\end{matrix}\right)=\left( \begin{matrix} \cos \theta & \sin \theta \\ -\sin \theta & \cos \theta \end{matrix}\right)\left(\begin{matrix} c'_T \\ d'_T\end{matrix}\right)$$

  3. Find other corners $A_T,C_T$ by $$A_T = \left(\begin{matrix} a_T \\ d_T \end{matrix}\right), \qquad C_T = \left(\begin{matrix} b_T \\ c_T \end{matrix}\right)$$

  4. Rotate $A_T$ and $C_T$ back to obtain $A'_T$ and $C'_T$: $$A'_T=\left( \begin{matrix} \cos \theta & -\sin \theta \\ \sin \theta & \cos \theta \end{matrix}\right)\left(\begin{matrix} a_T \\ d_T\end{matrix}\right), \qquad C'_T=\left( \begin{matrix} \cos \theta & -\sin \theta \\ \sin \theta & \cos \theta \end{matrix}\right)\left(\begin{matrix} b_T \\ c_T\end{matrix}\right)$$
  5. Translate coordinate system back that the rectangle's center returns to where it was.

$$A' = A'_T + E', \qquad C' = C'_T + E'$$

Related Question