# Accurate Qibla calculator

## What do I do?

Click on your location on the map. The green path is the shortest route on the surface of the Earth between your location and the Kabaa in Mecca. The tab below the map reports the azimuth of this route (the Qibla) in decimal degrees east of true north and the distance from your location to the Kabaa in Mecca in kilometers.

## How does it work?

Qibla locator websites calculate the Qibla by approximating the Earth as a sphere and using formulas from spherical trigonometry. However, the figure of the Earth is closer to an ellipsoid than a sphere. I use GeographicLib to calculate the forward azimuth and length of the geodesic between a given map location and the Kabaa in Mecca on the WGS-84 ellipsoid.

(Formerly I used a slightly modified version of Chris Veness's implementation of Vincenty's inverse formula for this purpose. Thanks to Charles Karney for pointing out that Vincenty's inverse formula fails for nearly antipodal points and suggesting that I use his GeographicLib instead.)