The other day I was looking for a longitude and Latitude command for a game I play thats based on real countries. I couldnt find one anywhere.
I made 5 alias's, not one of them worked... Mainly because I didnt realise I was messing up the input (It was meant to be lng1,lat1,lng2,lat2 whereas I had it the other way round) but yeah, so basically to save anyone ever having the trouble of finding one, ive made this one.
The distance is in km... The vars of %cos1 etc are there because when I was debugging the calculation got really, really long.
alias distance {
;;@@Params $distance(LONGITUDE1,LATITUDE1,LONGITUDE2,LATITUDE2)
var %rad $calc(180 / 3.14159265)
var %cos1 $cos($calc((90 - $2) / %rad))
var %cos2 $cos($calc((90 - $4) / %rad))
var %sin1 $sin($calc((90 - $2) / %rad))
var %sin2 $sin($calc((90 - $4) / %rad))
var %cos3 $cos($calc(($1 - $3) / %rad))
var %dis $calc(3960 * $acos($calc((%cos1 * %cos2) + (%sin1 * %sin2) * %cos3)))
return $floor($round($calc(%dis * 1.609344),2))
}