scruffyduck Posted January 6, 2005 Report Posted January 6, 2005 Hi all I am writing a program which uses FSCUIPC to control different things like weather etc depending on location. I have an algorithm to calculated distance between two points but wondered if anyone could point me at where to find one to determine the bearing of one location (position of the aircraft) to another (waypoint). thanks in advance
Pete Dowson Posted January 6, 2005 Report Posted January 6, 2005 ... wondered if anyone could point me at where to find one to determine the bearing of one location (position of the aircraft) to another (waypoint). The formula I use in TrafficLook is very approximate, being normal plane trigonometry. That'd be reasonably close for near waypoints, but progressively worse as distance increases due to the curvature of the Earth. Also, I think my formula would be pretty bad anywhere near the poles (> 60 degrees N or S). // Everything in double floats, angles in degrees, result is True not Mag double Wrk = cos(PI * (fabs(MyLat+WayLat))/360.0)*(WayLon-MyLon); double Bearing = (MyLat == WayLat) ? 90.0 : (180.0 * atan(fabs(Wrk/(WayLat-MyLat))) / PI); if (MyLat >= WayLat) { if (MyLon >= WayLon) Bearing = 180.0 + Bearing; else Bearing = 180.0 - Bearing; } else if (MyLon > WayLon) Bearing = 360.0 - Bearing; If you want accurate bearings for longer distances or for anywhere in the world, you need spherical trig. Then I'm rather lost. You can find formulae on the 'net but you need to search. Regards, Pete
scruffyduck Posted January 6, 2005 Author Report Posted January 6, 2005 Hi Pete Many thanks for that - at the moment I think I only need to be accurate to within +/- 10deg over relatively short distances so that should work fine
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now