# Rotate and translate

If you rotate a 2-dim. figure around two different center points with the same angle, you need an extra translation to move the images into the same position.

For simplicity, we assume that one center is the origin, and the other is $c=(c_x, c_y, 1)^T$ (homogeneous coordinates in projective space). Let’s determine the equations to convert the rotation $R$ around $c$ into a rotation around the origin $O=(0,0, 1)^T$, followed by a translation $t=(t_x, t_y, 1)^T$. With

$$R = \begin{pmatrix} \cos \alpha & \sin \alpha & 0 \\ -\sin \alpha & \cos \alpha & 0 \\ 0 & 0 & 1 \end{pmatrix}, T = \begin{pmatrix} 1 & 0 & t_x \\ 0 & 1 & t_y \\ 0 & 0 & 1 \end{pmatrix}, C = \begin{pmatrix} 1 & 0 & c_x \\ 0 & 1 & c_y \\ 0 & 0 & 1 \end{pmatrix},$$

we have for all $v$:

$$CR(-C)v = TRv$$

Note: Because computer screens have the origin in the upper left with a flipped y-axis, the rotation matrix has the sign in the opposite place of mathematical convention. To correct for that, I made the rotation in the picture below clockwise (also the opposite of mathematical convention). Substituting $\alpha$ by $-\alpha'$ everywhere will lead you to the traditional equations.

Expanding the matrices yields:

$$\begin{pmatrix} \cos \alpha & \sin \alpha & -c_x\cos\alpha - c_y\sin\alpha + c_x \\ -\sin \alpha & \cos \alpha & c_x\sin\alpha - c_y\cos\alpha + c_y \\ 0 & 0 & 1 \end{pmatrix}v = \begin{pmatrix} \cos \alpha & \sin \alpha & t_x \\ -\sin \alpha & \cos \alpha & t_y \\ 0 & 0 & 1 \end{pmatrix}v$$

So we are left with equations that define $t$ as the image of the origin:

Solving first eq. for $c_y$:

$$c_y = c_x\frac{1-\cos\alpha}{\sin\alpha}-\frac{t_x}{\sin\alpha} = c_x\tan\frac\alpha2-\frac{t_x}{\sin\alpha}$$

And inserting in second eq., solving for $c_x$:

Using this lemma:

Geometrically, you can find the center to a translation by choosing two points, connect them to their respective images, and take the line segment bisectors. The intersection of the bisectors is the point that is equidistant to all (point, image point) pairs.

Here is an illustration showing only one point and its image, the corresponding bisector, and the resulting equation for $c_y$: