PDA

View Full Version : An Earthy Equation

FlapsOut
17 Jun 2007, 00:11
Anyone studying Physical Geometrics knows that the Earth, rather than being a bedrock hard globe in the heavens, is more like a water-balloon...constantly expanding and contracting as it rotates.

I would like to know that; If I were to calculate a 'Curve-of-the-Earth' distance calculation from, for instance:

'KIAH' to '13TE'? Would anyone have an argument against this formulae? And, if so? What argument?

In C#, BTW...

double distance = CalculateDistanceByTwoLatLngs(30.6560320034623, -96.5383015573025, 29.959241723995, -95.3403444794987);

private double CalculateDistanceByTwoLatLngs(double Latitude1, double Longitude1, double Latitude2, double Longitude2)
{
double Lat1, Lng1, Lat2, Lng2;

Lat1 = (Latitude1 * 3.141592657) / 180;
Lng1 = (Longitude1 * 3.141592657) / 180;
Lat2 = (Latitude2 * 3.141592657) / 180;
Lng2 = (Longitude2 * 3.141592657) / 180;

double distance = Math.Acos(Math.Sin(Lat1) * Math.Sin(Lat2) + Math.Cos(Lat1) * Math.Cos(Lat2) * Math.Cos(Lng2 - Lng1));

if (distance < 0)
distance += Math.PI;

distance = 3959.0 * distance; // 3959.0 being the 'Average Radius of the Earth in Miles'

return (distance);
}

Then? distance = 86.167549658405591 Miles...er, 86.17 miles.

Flaps ;)

P.S. Please do not answer with, 'Well, FSNav says...' or 'Well, FS Commander says...' :o

arno
17 Jun 2007, 04:09
Hi,

The only thing I see right away is that you use an average radius of the earth, while the SDK clearly lists the two radii that FS uses for its earth model. So I think that would make it not 100% accurate.

Here are the figures from the SDK:

Equatorial diameter=12756.27 km
Equatorial circumference=40075.0 km
Polar diameter=12734.62 km
Polar circumference=40007.0 km

But I never needed a formula to calculate the distance between two lat/longs over a long distance (only when using meters from a reference point in flat earth), so I don't know if the actual formula you use is correct.

rhysa
17 Jun 2007, 23:12
If you are going to use a spherical model then why not just use the Haversine method?

Then there is the Vincenty method, which I found here (http://www.movable-type.co.uk/scripts/latlong-vincenty.html) that uses an ellipsoidal model if you want to be very accurate. You can use the WGS84 numbers in this method and so you should get a good match with FSX.

FSX uses the WGS-84 standard, it is mentioned in the terrain SDK I think, but also you will see that arno's numbers match up with the WGS84 standard definition (http://home.online.no/~sigurdhu/WGS84_Eng.html).

I've used Haversine mainly because we only do short distance calculations where the error will be very small, and the results we see in FSX back that up.

FlapsOut
18 Jun 2007, 02:15
Thanks Guys,