# Rotation around non-zero point

$$\begin{cases}x' = x \cos(\varphi) - y \sin(\varphi) \\ y' = x \sin(\varphi) + y \cos(\varphi)\end{cases}$$

This a the formula for rotating $(x, y)$ by $\varphi$. It works well when I want to rotate rectangle's vertices which is centered in $(0, 0)$ but what if center is not zero and It's something like $(5, 10)$ ?

• transfer it to origin. rotate. then transfer it back to its original place.
– msm
Oct 12, 2016 at 6:49

Then the formula will just change to accomodate the new origin.

$$x' = 5+(x-5) \cos(\varphi) - (y-10) \sin(\varphi) \\ y' = 10+(x-5) \sin(\varphi) + (y-10) \cos(\varphi)$$

I hope this helps you.

• Thanks but It only works on $x'$, When I want to rotate $(40.89, 40.26)$ around $(40.39, 41.01)$, The formula you gave gives $x' = 41.80921000000001$ which I didn't test it yet but seems reasonable however $y' = 98.37548999999999$ which is too far from being true Oct 12, 2016 at 7:01
• @omidh It was a mistake and I am sorry for it. Actually it should have gone as follows. It also matches with the formula given by msm. Oct 12, 2016 at 7:05
1. Transfer the points to the origin $$\begin{bmatrix} x' \\ y' \end{bmatrix}=\begin{bmatrix} x-5 \\ y-10 \end{bmatrix}$$

2. Rotate

$$\begin{bmatrix} x'' \\ y'' \end{bmatrix}=R\begin{bmatrix} x' \\ y' \end{bmatrix}$$ where $$R=\begin{bmatrix} \cos(\phi)& -\sin(\phi) \\ \sin(\phi)&\cos(\phi) \end{bmatrix}$$

1. Transfer back to the original place $$\begin{bmatrix} x''' \\ y''' \end{bmatrix}=\begin{bmatrix} x''+5 \\ y''+10 \end{bmatrix}$$

So the overall transform becomes: $$\begin{bmatrix} x''' \\ y''' \end{bmatrix}= R\begin{bmatrix} x-5 \\ y-10 \end{bmatrix}+\begin{bmatrix} 5 \\ 10 \end{bmatrix}$$