Skip to content

Instantly share code, notes, and snippets.

@vananth22
vananth22 / HaversineDistance.java
Created July 28, 2016 04:46
Java Implementation of Haversine Formula for distance calculation between two points
/**
* This is the implementation Haversine Distance Algorithm between two places
* @author ananth
* R = earths radius (mean radius = 6,371km)
Δlat = lat2lat1
Δlong = long2long1
a = sin²(Δlat/2) + cos(lat1).cos(lat2).sin²(Δlong/2)
c = 2.atan2(√a, √(1a))
d = R.c
*