haversinv
Haversine is a mathematical function used to calculate the great-circle distance between two points on a sphere, such as the Earth. The term originates from the Latin *haversinus*, a trigonometric function derived from the sine function, which simplifies distance calculations on spherical surfaces. The haversine formula is widely employed in navigation, geography, and computer science for applications like GPS systems, mapping, and geospatial analysis.
The basic haversine formula is expressed as:
d = 2r × arcsin(√(hav(a) + hav(b) - 2 × hav(a) × hav(b) × cos(Δλ)))
- *d* is the distance between the two points,
- *r* is the radius of the sphere (e.g., Earth’s mean radius of approximately 6,371 km),
- *hav(a)* and *hav(b)* are the haversine values of the latitudes of the two points,
- *Δλ* is the difference in longitude between the points,
- *hav(x)* is defined as sin²(x/2).
The haversine function itself is defined as *hav(x) = sin²(x/2)*. This formulation avoids numerical instability issues that
While the haversine formula is precise for spherical models, modern geospatial applications often use more complex