The Haversine formula calculates the shortest distance between two points on a sphere using their latitudes and longitudes measured along the surface. It is important for use in navigation. The haversine can be expressed in trignometric function as:
The haversine of the central angle (which is d/r) is calculated by the following formula:
where r is the radius of earth(6371 km), d is the distance between two points, is latitude of the two points and is longitude of the two points respectively.
Solving d by applying the inverse haversine or by using the inverse sine function, we get:
The distance between Big Ben in London (51.5007° N, 0.1246° W) and The Statue of Liberty in
New York (40.6892° N, 74.0445° W) is 5574.8 km. This is not the exact measurement because the
formula assumes that the Earth is a perfect sphere when in fact it is an oblate spheroid.
Below is the implementation of the above formulae:
- Sum of Manhattan distances between all pairs of points
- Find the altitude and area of an isosceles triangle
- Program to find the surface area of the square pyramid
- Program to find the Radius of the incircle of the triangle
- Area of largest triangle that can be inscribed within a rectangle
- Area of a square inscribed in a circle which is inscribed in an equilateral triangle
- Program to find the Centroid of the triangle
- Check if any square (with one colored cell) can be divided into two equal parts
- Check if it is possible to reach vector B by rotating vector A and adding vector C to it
- Check if a point is inside, outside or on the parabola
- Check if a point is inside, outside or on the ellipse
- Check if the given 2-D points form T-shape or not
- Area of a circle inscribed in a regular hexagon
- Find area of triangle if two vectors of two adjacent sides are given
- Program to find the Volume of an irregular tetrahedron
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.