user2970916
user2970916

Reputation: 1186

How to Determine the Angle of Rotation for a Point

I have 2 points in an x, y plane. I want to rotate one point onto the other point by rotating it about the z-axis.

How can I find the angle to rotate one point onto the other?

Upvotes: 0

Views: 1520

Answers (2)

John Alexiou
John Alexiou

Reputation: 29244

Maybe the best thing is to get the angles from horizontal for the two points and then take the difference.

angle_1 = atan2( y_1, x_1 );
angle_2 = atan2( y_2, x_2 );

rotation_angle = angle_1-angle_2;

Upvotes: 1

kraskevich
kraskevich

Reputation: 18546

Well, the sin of this angle is [a, b] / (abs(a) * abs(b)) and its cos is (a, b) / (abs(a) * abs(b)), where [a, b] is a cross product of a and b, (a, b) is a scalar product and abs(x) is the length of the vector x. It is pretty easy to find an angle given its sin and cos.

Upvotes: 0

Related Questions