# Given point before and after rotation at given axis calculate the angle of rotation

I have a point at 2d space in only positive x and y axis, point P(x1, y1) is rotated along axis point C(x3, y3) to reach at point P2(x2, y2).

Now I just need to calculate the angle of rotation.

If possible please share simplified formula along with the details.

Refer this image provided for clarity

Thanks

• Make sense thanks. Could you put this on answer so i could upVote it – DeWy Sady Jun 28 '16 at 13:47

## 2 Answers

$$\arctan_2(y_2-y_c,x_2-x_c)-\arctan_2(y_1-y_c,x_1-x_c)$$

Hint:

Take the two vectors: $$\vec p_1=P_1C=(x_1-x_3,y_1-y_3)^T \qquad \vec p_2=P_2C=(x_2-x_3,y_2-y_3)^T$$

do you know that the dot product of these vectors is: $$\vec p_1 \cdot \vec p_2=|\vec p_1||\vec p_2| \cos \theta$$ where $\theta$ is the angle between the two vectors?

$$\vec p_1 \cdot \vec p_2=(x_1-x_3)(x_2-x_3)+(y_1-y_3)(y_2-y_3)$$ $$|\vec p_1 |=\sqrt{(x_1-x_3)^2+(y_1-y_3)}$$ $$|\vec p_2 |=\sqrt{(x_2-x_3)^2+(y_2-y_3)}$$ $$\theta=\arccos\left(\frac{\vec p_1 \cdot \vec p_2}{|\vec p_1||\vec p_2|} \right)$$

• I need a formula to calculate the θ. This I know but since i am not in touch with math since 6 years i need simplified version. With simplified I mean in not in vector form – DeWy Sady Jun 28 '16 at 13:25
• Use the componets of the vectors as I've added to my answer. – Emilio Novati Jun 28 '16 at 13:42