Re: Distance between geographic poimts Message #2 Posted by Thomas Okken on 18 Mar 2007, 3:12 p.m., in response to message #1 by Sam Levy
I have an HP42S program that computes Great Circle Distance here. Should be easy to adapt to the HP65 or HP67 or any other RPN scientific.
It takes coordinates in decimal degrees, so you may want to add >HMS commands at a few places; it calculates the distance in kilometers, but that is easy enough to change to nautical miles by changing the final multiplication to 21600.
The formula used is
dist = acos(cos(lat1)*cos(lat2)*cos(lon1lon2)+sin(lat1)*sin(lat2))
Where dist is an angle on the Great Circle passing through the two points. Assuming the calculator is in DEG mode, multiply by 60 to get nautical miles, etc. This formula works for any pair of coordinates  no issues with crossing the equator or passing over the poles or anything like that.
UPDATE: There is more information, and more accurate formulae, here.
 Thomas
00 { 101Byte Prgm }
01>LBL "GC"
02 MVAR "LAT1"
03 MVAR "LON1"
04 MVAR "LAT2"
05 MVAR "LON2"
06 MVAR "DIST"
07 DEG
08 RCL "LAT1"
09 COS
10 RCL "LAT2"
11 COS
12 ×
13 RCL "LON1"
14 RCL "LON2"
15 COS
16 ×
17 RCL "LAT1"
18 SIN
19 RCL "LAT2"
20 SIN
21 ×
22 +
23 ACOS
24 360
25 ÷
26 40076
27 ×
28 RCL "DIST"
29 .END.
Edited: 18 Mar 2007, 5:07 p.m.
