
Calculate the Distance Between Points on the Earth’s Surface #27
Chapter 3, Mapping Your World
|
119
HACK
Geo::Distance has a few other nice features; see perldoc Geo::Distance for
more details.
Other Considerations
Conventional wisdom holds that this approach has one major drawback, in
that it relies on the mathematical properties of the inverse cosine function,
which suffers badly from rounding errors for distances separated by less
than a few degrees of arc. As an alternative, the formula given by the Law of
Cosines can be rewritten using various trigonometric identities to yield the
Haversine formula, which does not rely on the inverse cosine function to cal-
culate great-circle distances.
However, with the number of significant figures used in modern double-pre-
cision floating math, the rounding errors expected with the inverse cosine
function are actually not typically an issue. In fact, in temperate latitudes,
the inverse-cosine formula for great-circle distances appears to be substan-
tially more accurate than the Haversine formula. For distances wholly within
the polar latitudes, the Haversine formula may or may not be more accurate.
The attentive reader may have noticed one other potentially serious hitch,
which we have heretofore glossed over: although Earth is most certainly not
flat, it is not exactly round, either. Rather, Earth is an oblate spheroid,
slightly flattened at the poles.