Reputation: 850
var R = 6371e3; // metres
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;
Here in this code formula is used in JavaScript. But anyway, there is a and c used in the original formula as well. What do they mean?
Upvotes: 2
Views: 827
Reputation: 11469
In fact, c
is the angular distance between two points (in radians), and a
is the square of half the chord length between two points.
P. S. See here.
Upvotes: 3