Re: [off topic] distance
- Posted by jiri babor <jbabor at PARADISE.NET.NZ> Dec 28, 2000
- 474 views
Kat, Since no-one else has moved so far, try the following function. It's pretty rough, but it should be reasonably accurate for distances up several hundred kilometers. If you want your answer in miles, just divide the returned value by 1.609. jiri -- earth.ex -- jbabor at paradise.net.nz -- 00-12-28 constant R = 6371.02 -- mean earth radius in km constant pi = 3.141593 -- close enough constant d2r = pi/180 -- degrees-to-radians (~0.0174533) constant c = d2r * R -- ~111.1953 km per degree latitude function distance(atom la1, atom lo1, atom la2, atom lo2) atom u,v u = (lo2-lo1) * (cos(d2r*la1) + cos(d2r*la2)) / 2 v = la2-la1 return c * sqrt(u*u + v*v) end function ? distance(41.3, 174.7, 37.0, 174.7) -- Wellington-Auckland ? distance(41.3, 174.7, 33.7, 151.3) -- Wellington-Sydney ----- Original Message ----- From: "Kat" <gertie at PELL.NET> To: <EUPHORIA at LISTSERV.MUOHIO.EDU> Sent: Thursday, December 28, 2000 5:28 PM Subject: [off topic] distance > Hi all, off topic question... does anyone already have code for determining > Earth surface distance, given latitude and longitude points of two locations? > > Kat >