I'm trying to calculate the heading between two points on Earth. I have both their equatorial positions, however, either my concept, my formula or my implementation is wrong. The angle is off by a few degrees...
I know Orbiter doesn't have a problem calculating heading - if you set a target base, the little triangle at the top points to it.
My question is: How does Orbiter do that accurately? Here's my formula:
I designated x as longitude, y as latitude.
My guess is that the sine and cosine functions aren't 100% accurate.
I also get two singularities in the formula - that is to be expected, since I'm dividing with 0 when I'm directly north or south to the target. What's odd is that the singularity doesn't appear at one particular angle, but ranges over a degree in width or so.
I know Orbiter doesn't have a problem calculating heading - if you set a target base, the little triangle at the top points to it.
My question is: How does Orbiter do that accurately? Here's my formula:
I designated x as longitude, y as latitude.
My guess is that the sine and cosine functions aren't 100% accurate.
I also get two singularities in the formula - that is to be expected, since I'm dividing with 0 when I'm directly north or south to the target. What's odd is that the singularity doesn't appear at one particular angle, but ranges over a degree in width or so.