> For the complete documentation index, see [llms.txt](https://docs.distance.tools/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.distance.tools/features/calculation.md).

# Calculation

## Airline distance calculation <a href="#airline-distance-calculation" id="airline-distance-calculation"></a>

Calculating accurate distances between two points on the Earth's surface is essential for applications like routing and mapping. Common methods include the [Haversine formula](#haversine-formula) and [Great-circle distance](#great-circle-distance-method) for fast [spherical approximations](#spherical-earth-model), and[ Vincenty's formulae](#vincentys-formulae) and [Karney's algorithm](#karneys-algorithm) for precise geodesic distances on an [ellipsoidal Earth model](#ellipsoidal-earth-model).

### Spherical Earth Model

The **Spherical Earth Model** is a simplified way of representing the Earth as a **perfect sphere** with a constant radius (usually around **6371 km**).

#### **Haversine Formula** <a href="#haversine-formula" id="haversine-formula"></a>

* **Simplicity:** The Haversine formula is simpler and computationally less intensive than Vincenty's formulae, making it easier to implement.
* **Accuracy:** While accurate for short distances, the Haversine formula may exhibit limitations for long distances, as it assumes a spherical Earth model and does not account for the Earth's ellipsoidal shape.
* **Popular Use:** The Haversine formula is commonly used in applications where simplicity and speed are prioritized over extreme precision, such as in web and mobile applications.

{% embed url="<https://en.wikipedia.org/wiki/Haversine_formula>" %}

#### **Great-circle Distance Method** <a href="#great-circle-distance-method" id="great-circle-distance-method"></a>

* **Concept:** The Great-circle distance method calculates the shortest distance between two points on the surface of a sphere, traveling along the surface of the sphere.
* **Accuracy:** It provides good accuracy for most practical purposes, especially for shorter distances.
* **Applicability:** The Great-circle distance method assumes a spherical Earth model, which simplifies calculations. It is suitable for applications where a balance between accuracy and computational efficiency is required.

{% embed url="<https://en.wikipedia.org/wiki/Great-circle_distance>" %}

### Ellipsoidal Earth Model

The **Ellipsoidal Earth Model** represents the Earth as an **oblate spheroid** — slightly flattened at the poles and bulging at the equator. It is **more accurate** than the spherical model.

#### **Vincenty's Formulae** <a href="#vincentys-formulae" id="vincentys-formulae"></a>

* **Accuracy:** Vincenty's formulae are known for their higher accuracy compared to the Haversine formula, especially for long distances and over ellipsoidal surfaces.
* **Applicability:** Vincenty's formulae are suitable for calculating distances on an ellipsoidal Earth model, making them more precise for geodetic calculations.
* **Complexity:** These formulae are more complex mathematically than the Haversine formula.

{% embed url="<https://en.wikipedia.org/wiki/Vincenty's_formulae>" %}

#### **Karney’s Algorithm**

* **Accuracy**: Karney’s algorithm offers even higher accuracy than Vincenty's formulae, achieving sub-millimeter precision by using exact solutions on the ellipsoidal Earth model. It is highly reliable even for edge cases like antipodal points.
* **Applicability**: This algorithm is ideal for precise geodetic calculations, particularly in global navigation, GIS, and surveying, where robustness and accuracy are critical.
* **Complexity**: Karney’s method involves advanced series expansions and geodesic integrals, making it more mathematically sophisticated, but it is implemented efficiently in libraries like GeographicLib.

{% embed url="<https://link.springer.com/article/10.1007/s00190-012-0578-z>" %}
