The great-circle distance, orthodromic distance, or spherical distance is the distance between two points on a sphere, measured along the great-circle arc between them. This arc is the shortest path between the two points on the surface of the sphere. (By comparison, the shortest path passing through the sphere's interior is the chord between the points.)
On a curved surface, the concept of straight lines is replaced by a more general concept of geodesics, curves which are locally straight with respect to the surface. Geodesics on the sphere are great circles, circles whose center coincides with the center of the sphere.
Any two distinct points on a sphere that are not antipodal (diametrically opposite) both lie on a unique great circle, which the points separate into two arcs; the length of the shorter arc is the great-circle distance between the points. This arc length is proportional to the central angle between the points, which if measured in radians can be scaled up by the sphere's radius to obtain the arc length. Two antipodal points both lie on infinitely many great circles, each of which they divide into two arcs of length times the radius.
The determination of the great-circle distance is part of the more general problem of great-circle navigation, which also computes the azimuths at the end points and intermediate way-points. Because the Earth is nearly spherical, great-circle distance formulas applied to longitude and geodetic latitude of points on Earth are accurate to within about 0.5%.
Let
λ1,\phi1
λ2,\phi2
\Deltaλ,\Delta\phi
\Delta\sigma
\Delta\sigma=\arccosl(\sin\phi1\sin\phi2+\cos\phi1\cos\phi2\cos\Deltaλr).
The problem is normally expressed in terms of finding the central angle
\Delta\sigma
d=r\Delta\sigma.
The central angle
\Delta\sigma
\Delta\sigmac
\begin{align} \Delta\sigma&=2\arcsin
\Delta\sigmac | |
2 |
,\\ \Delta\sigmac&=2\sin
\Delta\sigma | |
2 |
. \end{align}
For short-distance approximation (
|\Delta\sigmac|\ll1
\Delta\sigma=\Delta\sigmac\left(1+
1 | |
24 |
2 | |
\left(\Delta\sigma | |
c\right) |
+ … \right).
On computer systems with low floating point precision, the spherical law of cosines formula can have large rounding errors if the distance is small (if the two points are a kilometer apart on the surface of the Earth, the cosine of the central angle is near 0.99999999). For modern 64-bit floating-point numbers, the spherical law of cosines formula, given above, does not have serious rounding errors for distances larger than a few meters on the surface of the Earth.[2] The haversine formula is numerically better-conditioned for small distances by using the chord-length relation:[3]
\begin{align} \Delta\sigma&=\operatorname{archav}\left(\operatorname{hav}\left(\Delta\phi\right)+\left(1-\operatorname{hav}(\Delta\phi)-\operatorname{hav}(\phi1+\phi2)\right)\operatorname{hav}\left(\Deltaλ\right)\right). \end{align}
Historically, the use of this formula was simplified by the availability of tables for the haversine function:
\operatorname{hav}\theta=\sin2
\theta | |
2 |
\operatorname{archav}x=2\arcsin\sqrt{x}
The following shows the equivalent formula expressing the chord length explicitly:
| ||||
\begin{align}\Delta\sigma | ||||
c&=2\sqrt{\sin |
\right)+\cos{\phi1} ⋅ \cos{\phi
| ||||
2} ⋅ \sin |
\right)} ,\\ &=2\sqrt{\left(\sin
\Deltaλ | |
2 |
2 | |
\cos\phi | |
rm{m}\right) |
+\left(\cos
\Deltaλ | |
2 |
\sin
\Delta\phi | |
2 |
\right)2} , \end{align}
\phim=\tfrac12(\phi1+\phi2)
Although this formula is accurate for most distances on a sphere, it too suffers from rounding errors for the special (and somewhat unusual) case of antipodal points. A formula that is accurate for all distances is the following special case of the Vincenty formula for an ellipsoid with equal major and minor axes:[4]
\begin{align} \Delta\sigma={\operatorname{atan2}}l(&\sqrt{\left(
2 | |
\cos\phi | |
2\sin\Deltaλ\right) |
+ \left(\cos\phi1\sin\phi2-\sin\phi1\cos\phi2\cos\Deltaλ \right)2},\\ & {\sin\phi1\sin\phi2+\cos\phi1\cos\phi2\cos\Deltaλ}r), \end{align}
where is the two-argument arctangent. Using atan2 ensures that the correct quadrant is chosen.
Another representation of similar formulas, but using normal vectors instead of latitude and longitude to describe the positions, is found by means of 3D vector algebra, using the dot product, cross product, or a combination:[5]
\begin{align} \Delta\sigma&=\arccos\left(n1 ⋅ n2\right)\\ &=\arcsin\left|n1 x n2\right|\\ &=\arctan
\left|n1 x n2\right| | |
n1 ⋅ n2 |
\\ \end{align}
where
n1
n2
A line through three-dimensional space between points of interest on a spherical Earth is the chord of the great circle between the points. The central angle between the two points can be determined from the chord length. The great circle distance is proportional to the central angle.
The great circle chord length,
\Delta\sigmac
\begin{align} \Delta{X}&=\cos\phi2\cosλ2-\cos\phi1\cosλ1;\\ \Delta{Y}&=\cos\phi2\sinλ2-\cos\phi1\sinλ1;\\ \Delta{Z}&=\sin\phi2-\sin\phi1;\\ \Delta\sigmac&=\sqrt{(\Delta{X})2+(\Delta{Y})2+(\Delta{Z})2}. \end{align}
Substituting
λ1=-\tfrac12\Deltaλ
λ2=\tfrac12\Deltaλ
See main article: Earth radius. The shape of the Earth closely resembles a flattened sphere (a spheroid) with equatorial radius
a
b
For distances smaller than 500 kilometers and outside of the poles, an Euclidean approximation of an ellipsoidal Earth (FCC's formula) is both simpler and more accurate (to 0.1%).