0
$\begingroup$

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

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

2 Answers 2

3
$\begingroup$

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.

$\endgroup$
2
  • $\begingroup$ 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 $\endgroup$
    – omidh
    Oct 12, 2016 at 7:01
  • $\begingroup$ @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. $\endgroup$ Oct 12, 2016 at 7:05
1
$\begingroup$
  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}$$

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.