开发者

Calculating in radians the rotation of one point around another

I have been trying to get this problem resolved for week and have get to c开发者_JAVA技巧ome to a solution. What I have is 2 points in a 2d space, what I need to resolve is what the rotation of one is around the other. With luck the attached diagram will help, what I need to be able to calculate is the rotational value of b around a.

Calculating in radians the rotation of one point around another

I have found lots of stuff that points to finding the dot product etc but I am still searching for that golden solution :o(

Thanks!


Vector2 difference = pointB - pointA;

double rotationInRadians = Math.Atan2(difference.Y, difference.X);

See http://msdn.microsoft.com/en-us/library/system.math.atan2.aspx for reference.


A guess:

  • 1.) Find the slope m of the line A, B.
  • 2.) Convert slope to angle theta = arctan(m)
  • 3.) Project the angle to a quadrant in a cartesian coordinate system centered at point A to get the normalized angle


I'll assume that due east (along the X axis, to the right) is zero radians, and that +x points to the right and +y points down.

The bearing of B with respect to A is

angle = Arctan2 [(A_y - B_y) / (B_x - A_x)]

Use the proper function to calculate the proper quadrant (probably Math.Atan2)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜