## Documents

Qibla (Arabic: قبلة) for any location on the Earth is the direction toward Ka’ba in Mecca. This direction is of particular importance for Muslims as they need to face this direction in their prayers.

#### How to calculate qibla direction

By definition, the direction between two points on a sphere is along the shortest path that connects the two points on the surface of the sphere. It is known that such a shortest path lies on an arc of a great circle, i.e., a circle that passes through the two points and is centered at the center of the sphere.

Since Earth has a spherical shape, we can use the formula for great circle to find qibla direction for any point on the Earth. Indeed, this direction can be easily computed using the following one-line formula:

where (φ_{1}, λ_{1}) is the latitude-longitude of your location, and (φ_{2}, λ_{2}) = (21.42, 39.83) is the latitude-longitude of Ka’ba. The returned value, *α*, specifies the angle of qibla clockwise from true North.

#### Ambiguity on flat maps

When a path along a great circle is drawn on a flat map, it usually looks curved (see for example the red line in Figure 1, which represents a great circle route from Ottawa, Canada to Mecca). In this case, one might think that the direct line segment connecting the two points on the flat map has a shortest length (see the blue line in Figure 1).

If the flat map is based on a Mercator projection (like in Google maps), such a straight line is called a rhumb line. By definition, a line rhumb is a path of constant bearing. It means that if one travels in a constant compass direction on the surface of the Earth, s/he has followed a rhumb line. Because of this simple property, rhumb lines have been widely used in navigation, mainly before the invention of computer-based navigation systems.

While flat maps like Figure 1 might suggest that rhumb line routes are shorter than great circle routes, a 3D representation of the routes on the surface of a sphere can help to remove this ambiguity. For example, the two routes in Figure 1 are shown on a 3D sphere in Figure 2.

Figure 2 clearly shows that the great circle route (the red line) is shorter than the rhumb line route (the blue line). Therefore, the qibla direction for the specific location shown on the map is along the red line, not the blue line. It means that for locations in North America, the correct qibla direction is towards North/North East, not towards South East as suggested by the flat maps.

#### Try it yourself

You can use the following interactive map to see and compare the great circle routes and rhumb line routes in both 2 and 3 dimensions. To see the 3D map, simply change the map type to “Earth” (if it is available on your browser).

Loading Google Map…

#### References

- Great Circle, from mathworld
- Rhumb Line, from wikipedia
- Long Distance Measure, by Martin Brock