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 = earth’s radius (mean radius = 6,371km)
Δlat = lat2− lat1
Δlong = long2− long1
a = sin²(Δlat/2) + cos(lat1).cos(lat2).sin²(Δlong/2)
c = 2.atan2(√a, √(1−a))
d = R.c
*