Class GeoMath
Geodesic distance helpers for map tools such as measuring and headings.
public static class GeoMath
- Inheritance
-
objectGeoMath
Remarks
Spherical earth, not the WGS84 ellipsoid, so distances carry up to about 0.56 percent error against a geodesic. Always the short way around, including across the antimeridian. This uses the mean earth radius while MarkerMath uses the equatorial circumference, by design: a haversine wants the mean radius and the mercator scale is defined at the equator. Do not show more precision than that bound carries.
Fields
EarthRadiusMeters
Mean earth radius in meters, 6371008.8, the IUGG arithmetic mean.
public const double EarthRadiusMeters = 6371008.8
Field Value
Methods
DistanceMeters(LatLon, LatLon)
Great-circle distance between two coordinates, by the haversine formula.
public static double DistanceMeters(LatLon a, LatLon b)
Parameters
Returns
- double
Distance in meters along the surface. Always the short way around, so a pair spanning the antimeridian is handled correctly.
DistanceMeters3D(LatLon, double, LatLon, double)
Straight-line distance between two points at altitude, for lines drawn between aircraft.
public static double DistanceMeters3D(LatLon a, double altAMeters, LatLon b, double altBMeters)
Parameters
aLatLonFirst coordinate, degrees WGS84.
altAMetersdoubleAltitude of the first point in meters.
bLatLonSecond coordinate, degrees WGS84.
altBMetersdoubleAltitude of the second point in meters.
Returns
- double
Distance in meters: the ground distance and the altitude difference combined as the hypotenuse. Treats the ground arc as a straight leg, which is accurate while the separation is small next to the earth's radius.
InterpolateGreatCircle(LatLon, LatLon, double)
Point a fraction of the way from a to
b along the great circle through them.
public static LatLon InterpolateGreatCircle(LatLon a, LatLon b, double fraction)
Parameters
aLatLonStart coordinate, degrees WGS84.
bLatLonEnd coordinate, degrees WGS84.
fractiondouble0 returns
a, 1 returnsb.
Returns
- LatLon
Interpolated coordinate, degrees WGS84.
Remarks
Spherical slerp on the same great circle DistanceMeters(LatLon, LatLon) measures, so a sum of DistanceMeters(LatLon, LatLon) over consecutive interpolated points recovers the original two-point distance.