-
-
Save cordellcp3/61dc8a65f9fc8fb662e3 to your computer and use it in GitHub Desktop.
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
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