The following approximate distance calculations are relatively simple, but
can produce distance errors of 10% of more. These approximate
calculations are performed using latitude and longitude values in degrees. The first approximation requires only simple math functions:
Approximate distance in miles = sqrt(x * x + y * y)
where
x = 69.1 * (lat2 - lat1)
and
y = 53 * (lon2 - lon1)
You can improve the accuracy of this approximate distance calculation by
adding the cosine math function:
Approximate distance in miles = sqrt(x * x + y * y)
where
x = 69.1 * (lat2 - lat1)
and
y = 69.1 * (lon2 - lon1) * cos(lat1/57.3)
If you need greater accuracy, you must use the exact distance calculation.
The exact distance calculation requires use of spherical geometry, since the
Earth is a sphere. The exact distance calculation also requires a high level
of floating point mathematical accuracy - about 15 digits of accuracy
(sometimes called "double-precision"). In addition, the trig math
functions used in the exact calculation require conversion of the latitude
and longitude values from degrees to radians. To convert latitude or
longitude from degrees to radians, divide the latitude and longitude values
in this database by 180/pi, or 57.2958. The radius of the Earth is assumed to
be 6,371 kilometers, or 3,958.75 miles.
You must include the degrees-to-radians conversion in the
calculation. Substituting degrees for radians, the calculation is:
Exact distance in miles = 3958.75 * arccos[sin(lat1/57.2958) *
sin(lat2/57.2958) +
cos(lat1/57.2958) *
cos(lat2/57.2958) *
cos(lon2/57.2958 - lon1/57.2958)]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…