Rotation around non-zero point

10.5k Views Asked by At

$$\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)$ ?

2

There are 2 best solutions below

2
On BEST ANSWER

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.

0
On
  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}$$