Created
September 16, 2014 14:44
-
-
Save hughes/2e8eda0cf05687ce95f1 to your computer and use it in GitHub Desktop.
Unicode variable names...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var R = 6371; // km | |
var φ1 = lat1.toRadians(); | |
var φ2 = lat2.toRadians(); | |
var Δφ = (lat2-lat1).toRadians(); | |
var Δλ = (lon2-lon1).toRadians(); | |
var a = Math.sin(Δφ/2) * Math.sin(Δφ/2) + | |
Math.cos(φ1) * Math.cos(φ2) * | |
Math.sin(Δλ/2) * Math.sin(Δλ/2); | |
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); | |
var d = R * c; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment