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!
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.
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
)