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

95 Views Asked by At

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

2

There are 2 best solutions below

0
On BEST ANSWER

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

2
On

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