Great-circle Distance - Formulas

Formulas

Let be the geographical latitude and longitude of two points (a base "standpoint" and the destination "forepoint"), respectively, and their absolute differences; then, the central angle between them, is given by the spherical law of cosines:

The distance d, i.e. the arc length, for a sphere of radius r and given in radians, is then


Note that using r = 6,371.009 metres is appropriate for calculating great-circle distances between points on the Earth's surface, in which case the result d will also be in metres.

This arccosine formula above can have large rounding errors if the distance is small (if the two points are a kilometer apart the cosine of the central angle comes out 0.99999999). An equation known as the haversine formula is numerically better-conditioned for small distances:

{\color{white}\frac{\bigg|}{|}}\Delta\widehat{\sigma}
=2\arcsin\left(\sqrt{\sin^2\left(\frac{\Delta\phi}{2}\right)+\cos{\phi_s}\cos{\phi_f}\sin^2\left(\frac{\Delta\lambda}{2}\right)}\right).\;\!

Historically, the use of this formula was simplified by the availability of tables for the haversine function: hav(θ) = sin2 (θ/2).

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 (on opposite ends of the sphere). A more complicated formula that is accurate for all distances is the following special case (a sphere, which is an ellipsoid with equal major and minor axes) of the Vincenty formula (which more generally is a method to compute distances on ellipsoids):

When programming a computer, one should use the atan2 function rather than the ordinary arctangent function (atan), in order to simplify handling of the case where the denominator is zero, and to compute unambiguously in all quadrants. Also, make sure that all latitudes and longitudes are in radians (rather than degrees) if that is what your programming language's sin, cos and atan2 functions expect (1 radian = 180 / π degrees, 1 degree = π / 180 radians).

Read more about this topic:  Great-circle Distance

Famous quotes containing the word formulas:

    You treat world history as a mathematician does mathematics, in which nothing but laws and formulas exist, no reality, no good and evil, no time, no yesterday, no tomorrow, nothing but an eternal, shallow, mathematical present.
    Hermann Hesse (1877–1962)

    That’s the great danger of sectarian opinions, they always accept the formulas of past events as useful for the measurement of future events and they never are, if you have high standards of accuracy.
    John Dos Passos (1896–1970)

    It is sentimentalism to assume that the teaching of life can always be fitted to the child’s interests, just as it is empty formalism to force the child to parrot the formulas of adult society. Interests can be created and stimulated.
    Jerome S. Bruner (20th century)