# Can you find a centre and angle of rotation without any construction?

Some time ago, I had a message from someone who - somewhat oddly - wanted to find a centre of rotation (with an unknown angle) without constructing any bisectors. (Obviously, if it was a right-angle rotation, they could use the set-square trick; if it was a half-turn, the centre of rotation is pretty much obvious.)

If you have the coordinates of two points and their images, you can do it algebraically - although it’s not pretty.

Suppose the original two points are at $(x_1, y_1)$ and $(x_2, y_2)$ and their images are at $(x’_1, y’_1)$ and $(x’_2, y’_2)$. Suppose also that the points are rotate an angle $\theta$ (anticlockwise) around a point $(X,Y)$.

### Some background

If you rotate the point $(1,0)$ an angle of $\theta$ anticlockwise around the origin, it ends up at $(\cos(\theta), \sin(\theta))$. The point $(0,1)$ maps to $(-\sin(\theta), \cos(\theta))$ - which you can verify if you want to.

Rotation is one of a large range of transformations called a *linear mapping* - which means it has two nice properties: $f(\bb {a+b}) = f(\bb a) + f(\bb b)$, and $f(k\bb a) = kf(\bb a)$. In other words, if you apply a rotation to the sum of two vectors, you get the same result as applying the rotation to each of the vectors separately and adding the result. Similarly, if you apply a rotation to a multiple of a vector, you get the same thing as if you rotated the vector and multiplied the result appropriately.

That’s powerful, because it means we can write down where any point rotates to - because a general point $(x,y)$ can be written as $x(1,0) + y(0,1)$, we know it maps to $x(\cos(\theta), \sin(\theta)) + y(-\sin(\theta), \cos(\theta))$, or $(x\cos(\theta)-y\sin(\theta), x\sin(\theta) + y\cos(\theta))$.

(This whole thing is more easily done with matrices, but who has time to format those?)

So that’s fine for rotating about the origin - but…

### What about an arbitrary centre of rotation?

Here, we can apply a trick: we can translate everything so that the (unknown!) centre of rotation is at the origin, do the rotation, and translate everything back again.

So, instead of applying the rotation to (e.g.) $(x_1, y_1)$, we’re applying it to $(x_1 - X, y_1 - Y)$, then adding $(X,Y)$ back on to the answer.

So, we know that our rotation around an arbitrary point maps $(x_1, y_1)$ to $((x_1 - X)\cos(\theta)-(y_1 - Y)\sin(\theta)+X, (x_1-X)\sin(\theta) + (y_1-Y)\cos(\theta))+Y$, and $(x_2, y_2)$ to $((x_2 - X)\cos(\theta)-(y_2 - Y)\sin(\theta)+X, (x_2-X)\sin(\theta) + (y_2-Y)\cos(\theta)+Y)$.

### OK…

This gives us four equations in three unknowns ($X$, $Y$ and $\theta$):

- $x’_1 = (x_1 - X)\cos(\theta)-(y_1 - Y)\sin(\theta)+X$ [1]
- $x’_2 = (x_2 - X)\cos(\theta)-(y_2 - Y)\sin(\theta)+X$ [2]
- $y’_1 = (x_1 - X)\sin(\theta) + (y_1-Y)\cos(\theta))+Y$ [3]
- $y’_2 = (x_2 - X)\sin(\theta) + (y_2-Y)\cos(\theta)+Y$ [4]

Subtracting [1] from [2] gives $x’_2 - x’_1 = (x_2 - x_1) \cos(\theta) - (y_2-y_1)\sin(\theta)$. This is a mess, but it can be solved: the right-hand side can be written as $\sqrt{(x_2-x_1)^2 + (y_2-y_1)^2}\cos(\theta + \alpha)$, where $\tan(\alpha)=\frac{(y_2-y_1)}{(x_2-x_1)}$. From there, it’s ‘just’ a bit of trigonometry to find the possible candidates for $\theta$.

Knowing $\theta$, you can substitute the value into any pair of equations and solve simultaneously to find $X$ and $Y$.

An alternative, if you don’t fancy the trig, is to treat $\cos(\theta)$ and $\sin(\theta)$ as variables - call them $C$ and $S$.

Using this, subtracting [1] from [2] gives $x’_2 - x’_1 = (x_2 - x_1)C - (y_2 - y_1)S$; subtracting [3] from [4] give $y’_2 - y’_1 = (x_2 - x_1)S + (y_2 - y_1)C$. Now we have two equations in two unknowns, and can solve for $\cos(\theta)$ and $\sin(\theta)$ explicitly.

I reckon $\cos(\theta) = \frac{ (x’_2 - x’_1)(x_2 - x_1) + (y’_2 - y’_1)(y_2 - y_1)}{(x_2-x_1)^2 + (y_2 - y_1)^2}$ and $\sin(\theta) \frac{ (y’_2 - y’_1)(x_2 - x_1) + (x’_2 - x’_1)(y_2 - y_1)}{(x_2-x_1)^2 + (y_2 - y_1)^2}$.

### Two wrinkles

One thing you need to check here is that there is a possible answer: this can only be the case if $C^2 + S^2 = 1$. It’s also not enough to put $\cos^{-1}$ of ‘stuff’ into your calculator: you need to find the angle that works for both sine and cosine, which may be in any of the four quadrants.

If you think all that algebra is more straightforward than drawing the perpendicular bisectors of the pairs of corresponding points and seeing where they cross, then fine, have at it! Personally, I’d go for the geometric method every time.

* Edited 2018-07-23 to link to the set square trick. Thanks to Cynthia for pointing out the omission! * Edited 2018-07-23 to fix LaTeX. Thanks, Adam!