[comp.sys.handhelds] Computing Great Circle Distance

ebergman@isis.cs.du.edu (Eric Bergman-Terrell) (11/06/90)

DIST for the HP 48SX:


Introduction:

This program calculates the great circle distance in statute miles 
between two cities, given their latitude and longitude in degrees, 
minutes, and seconds format.


Caveats:

No correction is made for the Earth's equatorial bulge.  USE THIS 
SOFTWARE AT YOUR OWN RISK.


Method:  

EXPRESS LATITUDES NORTH OF THE EQUATOR AS POSITIVE NUMBERS, AND
LATITUDES SOUTH OF THE EQUATOR AS NEGATIVE NUMBERS.  EXPRESS 
LONGITUDES WEST OF GREENWICH AS POSITIVE NUMBERS, AND LONGITUDES
EAST OF GREENWICH AS NEGATIVE NUMBERS.

Convert the two latitudes and longitudes into spherical coordinate 
unit vectors.  The smallest angle between the vectors is calculated 
by taking the inverse cosine of the vectors' dot product.  
Multiplying this angle by 60 yields the nautical miles between the 
two cities.  Multiplying by 6080 and then dividing by 5280 yields 
statute miles.


Setup:

YOUR CALCULATOR MUST BE IN DEGREES MODE TO RUN THE PROGRAM.  To get
into degrees mode, use the DEG command.


Example:

Tokyo:	35d35'00" N 139d45'00" E
Denver:	39d44'58" N 104d59'22" W

Entering the following:

35.35
-139.45
39.4422
104.5922
DIST

leaves 5800 on the stack.  My almanac says that Denver is 5795
statute miles from Tokyo.


Program:

%%HP: T(3)A(R)F(.);
\<< 0 0 \-> LATA LONA
LATB LONB A B
  \<< -15 SF -16 SF 1
LONA HMS\-> 90 LATA
HMS\-> - \->V3 'A' STO
1 LONB HMS\-> 90 LATB
HMS\-> - \->V3 'B' STO
A B DOT ACOS 60 *
6080 * 5280 / -15
CF -16 CF
  \>>
\>>


Size/Checksum:

275 bytes
# 11808d checksum


Eric Bergman-Terrell