How do you exactly compute the distance traveled between two points at different altitudes on a spherical body? If the two points are at the same altitude it’s a simple great-circle calculation. But what is the additional term to account for a steady climb or descent precisely? Say we’re talking about a spaceplane that steadily climbs up to a great height over a great distance after taking off.
Illustration:
https://i.stack.imgur.com/3n7jL.png
The National Geodetic Survey (NGS) (a division of NOAA) has some information on this, and even sample Fortran code and working programs on their website and for a PC.
See:
http://www.ngs.noaa.gov/TOOLS/Inv_Fwd/Inv_Fwd.html
The program that you want is INVERS3D:
http://www.ngs.noaa.gov/PC_PROD/Inv_Fwd/
You will need to look through their code for specifics, but they calculate “ellipsoidal distance, the mark-to-mark distance, and the ellipsoid height difference” using lat/long/altitude.
From their website: