Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
17
Task/Haversine-formula/MiniScript/haversine-formula.mini
Normal file
17
Task/Haversine-formula/MiniScript/haversine-formula.mini
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// compute the distance between places using the Haversine formula
|
||||
|
||||
distance = function( th1Deg, ph1Deg, th2Deg, ph2Deg )
|
||||
toRadians = pi / 180
|
||||
ph1 = toRadians * ( ph1Deg - ph2Deg )
|
||||
th1 = toRadians * th1Deg
|
||||
th2 = toRadians * th2Deg
|
||||
dz = sin( th1 ) - sin( th2 )
|
||||
dx = cos( ph1 ) * cos( th1 ) - cos( th2 )
|
||||
dy = sin( ph1 ) * cos( th1 )
|
||||
return asin( sqrt( dx * dx + dy * dy + dz * dz ) / 2 ) * 2 * 6371
|
||||
end function
|
||||
|
||||
d = distance( 36.12, -86.67, 33.94, -118.4 )
|
||||
km = round( d )
|
||||
mi = round( d / 1.609344 )
|
||||
print( "distance: " + km + " km (" + mi + " mi.)" )
|
||||
Loading…
Add table
Add a link
Reference in a new issue