Cálculo del rumbo de A(x1,y1) relativo a B(x2,y2) en iOS
Frecuentes
Visto 1,279 veces
1
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!
2 Respuestas
3
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.
Respondido 28 ago 12, 12:08
1
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.
Respondido 28 ago 12, 10:08
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas iphone objective-c math navigation trigonometry or haz tu propia pregunta.
Do you know how to calculate the slope of a line between 2 points in the Cartesian plane ? - High Performance Mark
I don't but I can find out. How does it help to compute the bearing? - Alvin Loh
Because the bearing is the slope of the line between your 2 points. In your picture blue bears 065° from red, and, inevitably, red has the reciprocal bearing from blue. - High Performance Mark
How do I get the bearing value from the slope? - Alvin Loh
The bearing is the slope. The bearing of blue from red is the slope of the line from red to blue. The bearing of red from blue is the slope of the line from blue to red. If you've calculated the slope as, perhaps '4/5' then you have to convert that to an angular measurement. @Axeman's answer tells you how to do that. - High Performance Mark