I am kinda new on this. I am about to convert math equation to code lately. So I started practicing on simple formulas such as Fibonacci numbers and haversine formula.
But I am kinda confused with the haversine code on the following references;
- Using the Haversine Formula in Javascript
- Calculate distance between two latitude-longitude points? (Haversine formula)
Generally, what they do is,
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;
And I have the reference of original haversine formula from here.
Then, notice of this line,
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
Which part of it that comes from original haversine formula that is in wikipedia? I haven't found any Tangent at all on those graphs. Am I missing something here? Any suggestion is appreciated.