Reputation: 63
May I know how I should calculate the bearing of one point relative to another? All the formulas I'm seeing on the Internet are for lat/lon coordinates. I'm working with the Cartesian coordinate system here and am unable to find a solution. Please help!
Upvotes: 1
Views: 1431
Reputation: 174
Use atan2 function (IIRC your objective-c should have it). It gives you a result between -PI and PI. You have to map it to 0-360 if you need it.
Upvotes: 3
Reputation: 4164
Not really an answer to your question, but if you're getting your points using CLLocationManager, each CLLocation has a course property, which gives you the bearing of your journey for the given point. For the actual math, see Axeman's answer.
Upvotes: 1