How to calculate angle of rotation for a given line?

8.3k Views Asked by At

For illustration purposes, I have attached an image of the line with the angle that I want to calculate. I am trying to determine the angle of rotation and the calculation that I am using currently is as below:

angle = math.atan2(y2-y1,x2-x1)enter image description here

I use this formula to calculate the rotation for $A$ and $A'$, and then I add up the angle of $a$ and $b$ get the rotation. So I am really not sure if this is the correct way to do this. The idea in the end is to see if the rotation from $A$ to $A'$ is $>70$ degrees or $<70$ degrees. Sorry my math is pretty rusted at the moment.

1

There are 1 best solutions below

3
On BEST ANSWER

Your formula is incorrect, assuming it's a rotation about the origin, you can find the angle of rotation using this formula: $$ \theta = \tan^{-1}\left( \frac{y_2 x_1 - x_2 y_1}{x_1 x_2 + y_1 y_2 } \right) $$ Check this wiki page if you want to learn more about the rotational transformation: https://en.wikipedia.org/wiki/Rotation_%28mathematics%29