4
$\begingroup$

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.

  • 0
    looks like your question got mixed up.2012-09-13

1 Answers 1

8

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.