Professional Documents
Culture Documents
Abstract
During a casual conversation with one of my students, he asked me how one could go about computing the
distance between two points on the surface of the Earth, in terms of their respective latitudes and longitudes.
This is an interesting exercise in spherical coordinates, and relates to the so-called haversine.
The calculation of the distance between two points on the surface of the
Earth proceeds in two stages: (1) to
compute the straight-line Euclidean
distance these two points (obtained by
burrowing through the Earth), and (2)
to convert this distance to one measured along the surface of the Earth.
Figure 1 depicts the spherical coordinates we shall use.1 We orient this
coordinate system so that
Spherical coordinates
z
x=Rcoscos
y=Rcossin
z=Rsin
x
Figure 1: Spherical Coordinates
is depicted are not the usual spherical coordinates, as the angle is usually measure from the zenith, or z-axis.
Thus, we assume that we are given two points P1 and P2 determined by their
respective lattitude-longitude pairs: P1 (1 , 1 ), P2 (2 , 2 ). In cartesian coordinates we have P1 = P1 (x1 , y1 , z1 ) and P2 = P2 (x2 , y2 , z2 ), where x, y, and z are
determined by the spherical coordinates through the familiar equations:
x = R cos cos
y = R cos sin
z = R sin
The Euclidean distance d between P1 and P2 is given by the three-dimensional
Pythagorean theorem:
d2 = (x1 x2 )2 + (y1 y2 )2 + (z1 z2 )2 .
The bulk of our work will be in computing this distance in terms of the spherical
coordinates. Converting the cartesian coordinates to spherical coordinates, we
get
d2 /R2 = (cos 1 cos 1 cos 2 cos 2 )2
+(cos 1 sin 1 cos 2 sin 2 )2
+(sin 1 sin 2 )2
= cos2 1 cos2 1 2 cos 1 cos 1 cos 2 cos 2 + cos2 2 cos2 2
+ cos2 1 sin2 1 2 cos 1 sin 1 cos 2 sin 2 + cos2 2 sin2 2
+ sin2 1 2 sin 1 sin 2 + sin2 2
= 2 2 cos 1 cos 2 cos(1 2 ) 2 sin 1 sin 2
P1
R
d
,
2R
d/2
d/2
sin = 2 sin(/2) cos(/2)
s
2
R
d
d
=
1
R
2R
P2
p
d
=
4R2 d2 .
Figure 2: Arc Length
2R2
Therefore, in terms of d and R, the distance D
is given by
p
d
4R2 d2 ,
D = R = R sin1
2
2R
which, in principle, concludes this narrative.
The distance is often represented in terms of the so-called haversine function,
defined by
1 cos A
2 A
haversin A = sin
=
.
2
2
This says that cos A = 1 2 haversin A.
Returning to the formula for d above, we continue, feeding in the new notation:
d2 /R2 =
=
=
=
and so
haversin = haversin (1 2 ) + cos 1 cos 2 haversin (1 2 ),
Finally, we have (refer to Figure 2)
2
d
= haversin (1 2 )+cos 1 cos 2 haversin (1 2 ), sin2 (/2) = haversin ,
2R
meaning that
1
D = R = 2R sin
haversin .