Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Global $fLocation1[2], $fLocation2[2]
- ;~ Location 1
- $fLocation1[0] = 52.918862
- $fLocation1[1] = -1.474920
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;~ Location 2
- $fLocation2[0] = 53.519629
- $fLocation2[1] = -1.129435
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- $fDistance = Distance($fLocation1[0], $fLocation1[1], $fLocation2[0], $fLocation2[1])
- MsgBox(0,0, $fDistance)
- Func Distance($_Lat1, $_Lon1, $_Lat2, $_Lon2) ; I translated this from a javascript recommendation.
- Local $RadiusOfEarth = 6371.008 ;6371 is the volumetric mean average radius of earth.
- Local $_dLat = Deg2Rad($_Lat2 - $_Lat1) ; No clue...
- Local $_dLon = Deg2Rad($_Lon2 - $_Lon1) ; No clue...
- Local $_a = (Sin($_dLat / 2) * Sin($_dLat / 2)) + (Cos(Deg2Rad($_Lat1)) * Cos(Deg2Rad($_Lat2))) * _ ; No clue...
- (Sin($_dLon / 2) * Sin($_dLon / 2)) ; No clue...
- Local $_C = 2 * ATan2(Sqrt($_a), Sqrt(1 - $_a)) ; No clue...
- Local $_d = $RadiusOfEarth * $_C ; No clue...
- Return Round(($_d * 1000) * 0.000621371192237, 3) ; I added this to convert meters to miles and returns this figure to the caller, rounded to 3 decimal places.
- EndFunc ;==>Distance
- Func Deg2Rad($_input) ; I translated this from a javascript recommendation (There was no such function in AutoIt, so I had to search for one)
- Local $Pi = 3.1415926535897932384626433832795
- Return $_input * $Pi / 180
- EndFunc ;==>Deg2Rad
- Func ATan2($y, $x) ; Taken from the AutoIt forum, where someone else needed the ATan2 function. This was the best, fastest option of the two provided.
- Return (2 * ATan($y / ($x + Sqrt($x * $x + $y * $y))))
- EndFunc ;==>ATan2
Add Comment
Please, Sign In to add comment