Cellular forums Home > Archive > GPS > March 2006 > Re: Distance between two sets of GPS coordinates...









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Distance between two sets of GPS coordinates...
Graydon

2006-03-19, 11:48 pm

A goggle search found this..it is a basic spherical astronomy
calculation:


const pi = 3. 14159265358979323846


Function distance(lat1, lon1, lat2, lon2, unit)
Dim theta, dist
theta = lon1 - lon2
dist = sin(deg2rad(lat1)) * sin(deg2rad(lat2)) + cos(deg2rad(lat1))
* cos(deg2rad(lat2)) * cos(deg2rad(theta))
dist = acos(dist)
dist = rad2deg(dist)
distance = dist * 60 * 1.1515
Select Case ucase(unit)
Case "K"
distance = distance * 1.609344
Case "N"
distance = distance * 0.8684
End Select
End Function


'
' This function get the arccos function from arctan function
'
Function acos(rad)
If Abs(rad) <> 1 Then
acos = pi/2 - Atn(rad / Sqr(1 - rad * rad))
ElseIf rad = -1 Then
acos = pi
End If
End function


'
' This function converts decimal degrees to radians
'
Function deg2rad(Deg)
deg2rad = cdbl(Deg * pi / 180)
End Function

'
' This function converts radians to decimal degrees
'
Function rad2deg(Rad)
rad2deg = cdbl(Rad * 180 / pi)
End Function


On Mon, 20 Mar 2006 00:41:17 GMT, "Marcus Fox"
<please-reply-via-newsgroup-th@-i-posted-to.com> wrote:

>Is there any program available that will give me the distance in specified
>units between two sets of latitude/longtitude coordinates? Or can someone
>perhaps explain how I can program something in Excel - have rows and colums
>of placenames listed by coordinates and the distances between them in the
>respective cells where the rows and colums converge.
>
>Marcus
>

LinkBot





Other Archives: Real Estate forum archive | Web Design archive | Software support archive | PC Hardware reviews archive | Medical topics archive

Copyright 2004 - 2008 cellphonetopics.com