Science & engineering

Ellipsoidal route cross-track error and nearest-point calculator

The nearest distance is minimized over the actual segment joining the two route endpoints.

Your numbers

Numeric JSON array. Follow the displayed column labels and units; example data are synthetic.
Numeric JSON array. Follow the displayed column labels and units; example data are synthetic.
Numeric JSON array. Follow the displayed column labels and units; example data are synthetic.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

A route leg ends at its two waypoints. The nearest point to a reported position can lie between them or at either endpoint. This calculator minimizes ellipsoidal distance along that finite geodesic segment, rather than extending a great circle indefinitely and reporting a perpendicular foot that may lie beyond the planned leg.

THE FORMULAMinimize WGS84 geodesic distance over finite route arc; Lipschitz branch-and-bound error certificate.

A worked example

The prefilled example gives Distance to finite leg NM = 59.70539339. This demonstration uses supplied example data, not an approved vessel operating condition.

Good to know

WGS84 GeographicLib direct/inverse geodesics; finite shortest leg. Lipschitz branch-and-bound certifies distance to entered tolerance, not a position-error bound. Signed lateral component is positive starboard; endpoint distance can include an along-track extension.

Measure distance to the actual finite leg

A route leg ends at its two waypoints. The nearest point to a reported position can lie between them or at either endpoint. This calculator minimizes ellipsoidal distance along that finite geodesic segment, rather than extending a great circle indefinitely and reporting a perpendicular foot that may lie beyond the planned leg.

The Earth model is WGS84, evaluated through the documented geodesic library. That makes the distance an ellipsoidal surface measurement rather than a spherical cross-track approximation or a flat-map offset. The distinction is especially useful when reviewing longer route legs, while the finite search and its numerical limits still need to be stated.

A finite equatorial leg has an interior meridian foot0° longitude10° longitudeQuery 1°N, 5°E110574.389 mFoot: 0°N, 5°E; port-side separation
Scroll across to see the full diagram.
For a WGS84 route from(0°,0°)to(0°,10°), query(1°,5°)has nearest point(0°,5°). Independent meridian integration gives110574.38856m distance and556597.45397m along the equator.

For a related reference calculation, see the Great circle intersection calculator from endpoint pairs.

Supply one geodesic leg and query position

Enter latitude and longitude for the start waypoint, end waypoint and query position using the same degree convention. Latitude is signed north-positive and longitude east-positive. The endpoint pair defines the selected shortest geodesic; coincident endpoints and ambiguous near-antipodal cases should be rejected or handled through a separately declared route definition.

Positions do not contain course, heading or timestamp information unless supplied separately. This page measures a geometric relationship, not how the vessel arrived there. It does not infer whether the query lies in navigable water, whether the route was intended to be a rhumb line or whether a displayed deviation is operationally acceptable.

Search the segment on the ellipsoid

First solve the inverse geodesic problem between the waypoints to obtain leg length and a distance-parameterized geodesic line. Candidate feet are positions along that line from zero distance to the full leg length. At each candidate, an inverse WGS84 calculation gives surface distance to the query.

A bounded numerical search compares interior candidates with both endpoints. The result should identify the minimizing position and its along-leg distance, with endpoint cases distinguished from an interior perpendicular-like projection. Near multiple minima or the geodesic cut locus, uniqueness is not universal; numerical convergence is not proof that every possible global configuration is supported.

A symmetric WGS84 reference check

Use an eastbound equatorial leg from0° longitude to10° longitude and query latitude1°N at longitude5°E. Symmetry places the nearest point at0° latitude,5°E. Along-leg distance is the WGS84 equatorial radius multiplied by five degrees in radians, approximately556,597.454metres.

The query-to-foot distance is the WGS84 meridian arc from0° to1° latitude, approximately110,574.389metres. That value can be independently obtained by integrating the ellipsoid’s meridional radius of curvature. A spherical one-degree distance would be different, making this example useful for detecting an accidental spherical fallback in the implementation.

Read sign and endpoint behavior separately

With a right-of-route positive convention, a point north of an eastbound equatorial leg is to port and receives a negative lateral sign. Reversing the route direction reverses that sign while leaving nearest-point distance unchanged. The sign describes the declared route orientation, not an instruction about which direction a vessel should turn.

At an endpoint minimum, distance includes separation beyond the finite leg as well as any lateral component. A point exactly on the extension can therefore be a positive distance from the segment while having no meaningful port-or-starboard side. Keep the endpoint classification visible rather than interpreting every signed result as a perpendicular corridor width.

Numerical bounds and meaningful precision

The geodesic library supplies direct and inverse ellipsoidal calculations, but the finite projection still uses an optimization procedure. Its search domain, iteration budget and tolerance matter. For difficult geometry, a coarse scan followed by refinement should compare candidate minima and avoid claiming unsupported uniqueness merely because one bracket converged.

Coordinate uncertainty can exceed the final numerical tolerance by many orders of magnitude. Displaying millimetre-scale optimization precision does not make a rounded waypoint or uncertain position accurate to millimetres. Retain the input coordinate precision and any independent navigation uncertainty when interpreting the nearest point or comparing successive reported deviations.

Reference and interpretation boundary

The GeographicLib documentation describes the WGS84 inverse and geodesic-line operations used to evaluate the segment. The equatorial example is independently checked through ellipsoid geometry rather than copied from a generated display baseline. A useful figure distinguishes the finite route endpoints, interior foot, along-track distance and signed side of the query.

This educational calculation does not approve route deviation limits or replace chart and positioning procedures. It provides a reproducible geometric projection under a stated ellipsoid and bounded numerical method. Use separate vessel, corridor and uncertainty information before relating that distance to any real navigation assessment or corrective action. WGS84 GeographicLib direct/inverse geodesics; finite shortest leg. Lipschitz branch-and-bound certifies distance to entered tolerance, not a position-error bound. Signed lateral component is positive starboard; endpoint distance can include an along-track extension.

A few questions, answered

Why can the nearest point be an endpoint?

The leg is finite. The perpendicular-like foot on its extension may lie outside the allowed segment.

What does the sign mean?

The declared convention is positive to the route’s right and negative to its left; reversing route direction reverses that sign.

Does a small numerical tolerance mean accurate positioning?

No. Input coordinate and measurement uncertainty remain independent of optimization precision.

Is this a spherical cross-track formula?

No. Candidate positions and distances are evaluated on the WGS84 ellipsoid.

Find your calculator

Start typing to explore the library.