About two weeks ago, I posted the following question:
> I need to compute the distance between two points on the surface of an
> ellipsoid. I'm looking for the distance *on* the surface. In short,
> I'm after the length of the shortest geodesic curve joining the
> points.
I was naively expecting a nice solution, akin to the "great circles"
on a sphere. I was soon disabused of this notion.
A big thanks to all who replied. Here is a summary of the responses.
I found two approaches to this problem.
One approach involves computing a discretized approximation to a
geodesic. This works on any ellipsoid. The first two software
pointers follow this approach. As far as I can tell, all the other
references follow the second approach.
The second approach is designed for the Earth, exploiting two special
features: (1) it is an ellipsoid of revolution, and (2) it is nearly
spherical. These properties allow one to construct a solution as a
power series in the small "flattening" parameter. One truncates the
series depending upon the accuracy required.
I was looking for a solution that works for any ellipsoid. Most of
what follows is geodesy-centric, so I have only explored a handful of
the suggestions listed below. Also --- as one person noted --- a web
search with key words of "ellipsoid & distance & arc" will generate a
list of hundreds of sites. (All dealing with the Earth, I might add).
What follows is heavily cut'n'pasted from the responses or from web
pages. Don't take these as advice or endorsement from me -- these are
not my words below!
Available Software on the net:
http://www.magic-software.com/gr_surf.htm
The code here computes a polygonal approximation to a geodesic and
then refines it until the geodesic curvature vanishes at each vertex
on the path.
http://www.netlib.org/ode/geodesic/
Similar to the above, except that it actually works on any manifold --
you supply a routine to compute the metric at any point, etc.
ftp://kai.er.usgs.gov/pub/PROJ.4/
Well-proven code, forward and inverse problem.
ftp://ftp.ngs.noaa.gov/pub/pcsoft/for_inv.3d
From the (U.S.) National Geodetic Survey:
INVERSE/FORWARD3D (Version 1.0)
Comprises four programs - Inverse (Version 2.0) which computes the
geodetic azimuth and distance between two points, given their
geographic positions; Forward (Version 2.0) which computes the
geographic position of a point, given the geodetic azimuth and
distance from a point with known geographic position; and the
three-dimensional versions of these programs . INVERS3D (Version 1.0)
and FORWRD3D (Version 1.0), which include the height component.
ftp://mapping.usgs.gov/pub/software/current_software/w5501
This program will solve either the geodetic position or inverse
problems in any quadrant of the Earth using the parameters of one of
five commonly-used ellipsoids.
http://www.globalserve.net/~nac/products.html
A product called NACNav (60USD/license) which can calculate the
shortest distance between two points anywhere on the earth surface and
the angle between the direction and the magnetic north (determined by
local magnetic declination).
Suggested References
If you need very high accuracy, I suggest reading B.R. Bowring, "Total
Inverse Solution for the Geodesic and Great Elliptic", Survey Review,
33, 261 (July 1996).
If you are satisfied with the relative error of the square of the
Earth's flattening, then see J. Meeus, Astronomical Algorithms, 1991.
Two people recommended: Bomford, G., 1952, Geodesy: London, England,
Oxford University Press.
Clark, D., 1963, Plane and Geodetic Surveying, II: London, England,
Constable & Co., Ltd.
Hosmer, G.L., 1930, Geodesy: New York, New York, John Wiley & Sons, Inc.
Lambert, W.D. and Swick, C.H.,1935, Formulas and Tables for the
Computation of Geodetic Positions on the International Ellipsoid:
U.S. Coast and Geodetic Survey Special Publication No. 200.
U.S.C.& G.S., Formulas and Tables for the Computation of Geodetic
Positions, U.S. Coast and Geodetic Survey Special Publication No. 8.
"Direct and Inverse Solutions of Geodesics on the Ellipsoid with
Application of Nested Equations", T. Vincenty, Survey Review 22, April
1975.
Thomas, Paul D., 1965, Geodesic arc-length on the reference ellipsoid
to second-order terms in the flattening, Journal of Geophysical
Research, vol.70(14), 3331-3340.