Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Spheroidal long-lat distance calculation
Message
From
15/02/2007 17:15:57
Dragan Nedeljkovich
Now officially retired
Zrenjanin, Serbia
 
 
To
15/02/2007 17:00:37
Mike Yearwood
Toronto, Ontario, Canada
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01196313
Message ID:
01196320
Views:
13
This message has been marked as the solution to the initial question of the thread.
>Hey all
>
>I've been trying to use the third formula on this page:
>
>http://en.wikipedia.org/wiki/Great-circle_distance
>
>The formula is unnamed, but is indicated as being the most accurate.
>
>My trig is pretty rusty, and I don't think I ever did it on a sphere. :)
>
>I'm plugging in the sample lat-long for BNA and LAX and I'm not getting the same results.
>
>I've converted everything to radians. They name a formula in the "worked example" but that name is not referenced elsewhere on the page, so I'm not even sure which formula they're trying to demonstrate.
>
>Can anyone show me what I'm missing?
>
>Thanks!
>
>
CLEAR
>SET DECIMALS TO 5
>
>m.lat1 = 36.12
>m.long1 = -86.67(SIN(m.rlat1) * SIN(m.rlat2)) + (COS(m.rlat1) * COS(m.rlat2) * COS(m.rDeltaLong))
>?"lat1",m.lat1,"long1",m.long1
>
>[snip]
>
>m.DeltaSigma = ;
>  atan( ;
>    SQRT(;
>      (COS(m.rlat2) * SIN(m.rDeltaLong))^2 + ;
>      (COS(m.rlat1) * SIN(m.rlat2) - SIN(m.rlat1) * COS(m.rlat2) * COS(m.rDeltaLong))^2;
>    ) ;
>    / ;
>      (SIN(m.rlat1) * SIN(m.rlat2)) + (COS(m.rlat1) * COS(m.rlat2) * COS(m.rDeltaLong)) ;
>  )
>
>return m.DeltaSigma
I think in the denominator you've prematurely closed the parenthesis after SIN(m.rlat2). The denominator line should be
(SIN(m.rlat1) * SIN(m.rlat2) + COS(m.rlat1) * COS(m.rlat2) * COS(m.rDeltaLong))

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform