I've tried googling this, but I always end up somewhere that just says it's easy.

Anyhow, I have a coordinate system, where I need to rotate a bunch of points. It's all 2D. Coordinates varies and so does the angles, but the point to rotate around, is always 0,0.

I've look a bit at this post, but I haven't really been able to make it work. https://stackoverflow.com/questions/2259476/rotating-a-point-about-another-point-2d

It mentions subtracting the pivot point, but should I subtract the distance to the pivot point? Since my pivot point is $(0,0)$ it sounds too easy, to just subtract 0 (and also doesn't give me the results I expect).

As an example, I have a point in $ (2328.30755138590, 1653.74059364716) $ (very accurate, I know). I need to rotate it $ 5.50540590872993 $ degrees around $(0,0)$.

I would expect it to end in 2339.68319170805, 1878.18099075262(based on a rotation in my CAD software) but I don't really see how I can get it to do that.

Actually, I need to rotate it around $(0, 1884.25802838571)$. Sorry. I have gotten some coordinate systems mixed.

  • 1
    $\begingroup$ en.wikipedia.org/wiki/Rotation_matrix $\endgroup$ – dato datuashvili Sep 13 '12 at 10:18
  • $\begingroup$ Please give a specific example of a situation, where you think the formula gives you a wrong result. Then it will be easier to correct misunderstandings. And, "NO!", you are supposed to subtract the pivot as a vector. How would you subtract a distance from a point anyway? They are incompatible data types. $\endgroup$ – Jyrki Lahtonen Sep 13 '12 at 10:33
  • $\begingroup$ I am sorry, if I am not being clear. I am asking here because my math skills are horrible. When you say subtract the pivot point as vector, exactly what do you mean? The vector between 0,0 and my point? $\endgroup$ – Nicolai Sep 13 '12 at 10:36
  • $\begingroup$ Added an example. $\endgroup$ – Nicolai Sep 13 '12 at 10:42
  • $\begingroup$ check this out $\endgroup$ – Santosh Linkha Sep 13 '12 at 10:53

Let's say you want to rotate a point $P = (a, b)$ w.r.t. to point $Q = (c, d)$ by angle $\theta_0$.

You need to first calculate the co-ordinate of point $P$ taking $Q$ as origin, which will be $(a-c, b-d)$.

Convert the representation of P from cartesian co-ordinate system to polar co-ordinate system. Now the polar co-ordinates of P(taking Q as origin) will be

$$\left (\sqrt{{(a-c)^2}+(b-d)^2}, sin^{-1}\frac{c-d}{\sqrt{{(a-c)^2}+(b-d)^2} } \right )$$

All you have to do now is to increase the angle by $\theta_0$. Lastly convert the polar co-odinate back to cartesian co-ordinate using this $(r, \theta)$ ~ $(r\sin\theta, r\cos\theta)$.

But note that your co-ordinates are taking point Q as the origin. To find the co-ordinate w.r.t. to the real origin, just add $c$ and $d$ to the x and y co-ordinates respectively.

Note- To rotate a point $(a,b)$ in cartesian co-ordinate by angle $\phi$ you just need to multiply matrix $\left[ \begin{array}{ c c } \cos\phi & -\sin\phi \\ \sin\phi & \cos \phi \end{array} \right] $and $ \left[ \begin{array}{ c c } a \\ b \end{array} \right]$, hence you can apply this matrix multiplication to $\left[ \begin{array}{ c c } a-c \\ b-d \end{array} \right] $ and then add $c$ and $d$ to the $x$ and $y$ co-ordinate.

| cite | improve this answer | |

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.