Calculating in radians the rotation of one point around another

懵懂的女人 提交于 2019-12-11 07:14:03

问题


I have been trying to get this problem resolved for week and have get to come 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.

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!


回答1:


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.




回答2:


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



回答3:


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)



来源:https://stackoverflow.com/questions/4684195/calculating-in-radians-the-rotation-of-one-point-around-another

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!