Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
public Double CalcDistanceOfTwoGpsCoordinates(Double latitudeA, Double longitudeA, Double latitudeB, Double longitudeB)
{
var pk = 180 / Math.PI;
var a1 = latitudeA / pk;
var a2 = longitudeA / pk;
var b1 = latitudeB / pk;
var b2 = longitudeB/ pk;
var t1 = Math.Cos(a1) * Math.Cos(a2) * Math.Cos(b1) * Math.Cos(b2);
var t2 = Math.Cos(a1) * Math.Sin(a2) * Math.Cos(b1) * Math.Sin(b2);
var t3 = Math.Sin(a1) * Math.Sin(b1);
var tt = Math.Acos(t1 + t2 + t3);
return 6366 * tt;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment