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.

  • 1
    http://en.wikipedia.org/wiki/Rotation_matrix2012-09-13
  • 0
    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.2012-09-13
  • 0
    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?2012-09-13
  • 0
    Added an example.2012-09-13
  • 0
    [check this out](http://www.wolframalpha.com/input/?i={{cos%285.50540590872993+deg%29%2C+-sin%285.50540590872993+deg%29}%2C{sin%285.50540590872993+deg%29%2C+cos%285.50540590872993+deg%29}}+*+{{2328.30755138590}%2C{1653.74059364716}})2012-09-13
  • 0
    @experimentX, I'm really sorry, I have not been clear in my edits. It wasn't 0,0 I needed to rotate about, but 0,1884. How do I add that to your example?2012-09-13
  • 0
    huh? you can always do coordinate transformations (translation) ... make the center of rotation $(0,0)$ and rotate it ... and then take inverse transform it.2012-09-13
  • 0
    Ok, I will need to play around with excel a bit, to try and understand this.2012-09-13
  • 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.