geoprimsField-grade geospatial math

3D distance between two points

The straight-line distance between two points with heights, such as a drone and its ground station, through Earth-centered coordinates, with the ground distance, height difference, and elevation angle.

Planning and education aid. Not for primary navigation. Full disclaimer

2,003.694m

The points are 2,003.694 m apart in a straight line, and 2,000 m apart on the ground.

Ground distance
Height difference
Elevation angle
Azimuth
Flat-Earth distance
Flat-Earth elevation angle
Provenance
Computed by
navigation.vector.distance-3d 1.0.0, core 0.1.0
Model
Both points to WGS 84 ECEF (sea-level heights first become ellipsoidal, h = H + N, with EGM96); straight-line distance = |ΔECEF|; elevation and azimuth from the east-north-up frame at the first point; ground distance by the Karney geodesic inverse
Accuracy
Exact geometry for the heights given. A sea-level height carries the geoid's error, about 0.5-1 m for EGM96.
Notes
None
Cites
Karney, C. F. F., GeographicLib, GeographicLib Geocentric and LocalCartesian classes

Something look off?

Your values

Showing an example. Change anything.
More options 3
Run many at once from a CSV

Loading…

How we got thisFormula, worked example, sources, and proof

Model: Both points to WGS 84 ECEF (sea-level heights first become ellipsoidal, h = H + N, with EGM96); straight-line distance = |ΔECEF|; elevation and azimuth from the east-north-up frame at the first point; ground distance by the Karney geodesic inverse

Show your work

  1. Ground distance

    geodesic inverse on WGS 84

    40°, -105° to 40.018012°, -105° = 2,000 m

  2. Straight-line distance

    √(ΔX² + ΔY² + ΔZ²) in Earth-centered coordinates

    √(309.021² + 1,153.282² + 1,609.11²) = 2,003.694 m

The same steps an agent gets from the MCP server with explain: true.

Accuracy: Exact geometry for the heights given. A sea-level height carries the geoid's error, about 0.5-1 m for EGM96.

When to use this: Use this for the straight-line distance between two points at different heights -- a drone and its ground station, an aircraft and a transmitter, a summit and a valley floor. It also gives the ground distance, the elevation angle and the azimuth, and the flat-earth answer beside them so you can see what curvature costs.

Limitations: Say which kind of height each is. A GPS height is above the ellipsoid and a map height is above sea level, and they differ by tens of metres; give `msl` and the tool converts through EGM96, which carries about half a metre to a metre of its own. This is geometry, not visibility: it says where the target is, not whether you can see it -- terrain, buildings and the Earth's curve are the look-angles tool next door. And the flat-earth figures are there for comparison, not for use; over a hundred kilometres they are wrong by enough to matter.

Worked example: A ground station at 250 m and a drone 2,000 m north at 370 m. Source: add-navigation-and-geometry drone scenario: straight-line 2,003.694 m, elevation 3.4245°; flat Earth 2,003.597 m and 3.4336°. It is golden test vector v001, and every build checks the tool still gives its answer within its tolerance.

You enter

First point height
250 m
Second point height
370 m
First point latitude
40 deg
Second point latitude
40.018012369978514 deg
First point longitude
-105 deg
Second point longitude
-105 deg

You get

Straight-line distance
2,003.694 m
Ground distance
2,000 m
Height difference
120 m
Elevation angle
3.4245°
Azimuth
0°
Flat-Earth distance
2,003.597 m
Flat-Earth elevation angle
3.4336°
Heights used
Both heights above the WGS 84 ellipsoid

Review: Not yet independently reviewed by a geodesist.

Last verified: 2026-09-18, when a maintainer last confirmed this tool's sources at the issuer. See the sources ledger.

Status: version 1.0.0, core 0.1.0. See this tool in the verification report.

Checked against: 20 golden test vectors (download the test vectors, each with its source and tolerance). See how results are checked and every source.

Constants this tool assumes

Values you do not enter, and where each comes from.

WGS 84 semi-major axis
6378137 m — Department of Defense World Geodetic System 1984
WGS 84 inverse flattening
298.257223563 — Department of Defense World Geodetic System 1984

Sources