Spherical Trigonometry and Geodetic Distance
Calculating distances and bearings on Earth requires spherical trigonometry because the Earth is roughly spherical. The shortest distance between two points on a sphere is a great-circle distance.
To calculate this, we use the Haversine formula, which computes the great-circle distance between two points on a sphere given their longitudes and latitudes. Let the coordinates of point 1 be (φ_1, λ_1) and point 2 be (φ_2, λ_2), where φ represents latitude and λ represents longitude in radians. Let the differences be Δ φ = φ_2 - φ_1 and Δ λ = λ_2 - λ_1. The haversine function hav(θ) = sin^2(θ/2) is applied to formulate the spherical distance: a = sin^2(Δ φ / 2) + cos(φ_1)cos(φ_2)sin^2(Δ λ / 2), then c = 2 × atan2(√(a), √(1-a)).
The geodetic distance d is then computed as the product of the Earth's mean radius R (approximately 6,371,000 meters or 3,959 miles) and the central angle c: d = R × c. This formula is highly accurate for geocaching purposes, with errors under 0.5% due to the Earth's slight ellipsoidal flattening.