Post Reply 
(20S and 21S) Great Circle
06-03-2017, 08:42 PM
Post: #1
(20S and 21S) Great Circle
The following program calculates the distance between two places on Earth (or any other planet) given the coordinates latitude (λ, east is positive) and longitude (ϕ, north is positive).

Inputs:
R1: longitude 1, R2: latitude 1
R4: longitude 2, R5: latitude 2
Enter the coordinates in DD.MMSSSS.

R1, R4: ϕ1, ϕ2; R2, R5: λ1, λ2

Distance, in miles, is stored in R0. Degrees mode is set.

Formula:

distance = acos( sin ϕ1 * sin ϕ2 + cos ϕ1 * cos ϕ2 * cos (λ2 – λ1) )* 3958.75 * π/180

On the HP 20S and HP 21S, can multiply by π/180 by executing the >RAD function.

HP 20S and HP 21S Program: Great Circle
Code:

STEP    CODE    KEY
01    61, 41, A    LBL A
02    61, 23     DEG
03    22, 1    RCL 1
04    51, 54    >HR
05    21, 1    STO 1
06    23    SIN
07    55    *
08    22, 4    RCL 4
09    51, 54    >HR
10    21, 4    STO 4
11    23    SIN
12    75    +
13    22, 1    RCL 1
14    24    COS
15    55    *
16    22, 4    RCL 4
17    24    COS
18    55    *
19    33    (
20    22, 2    RCL 2
21    51, 54    >HR
22    21, 2    STO 2
23    65    -
24    22, 5    RCL 5
25    51, 54    >HR
26    21, 5    STO 5
27    34    )
28    24    COS
29    74    =
30    51, 24    ACOS
31    55    *
32    3    3
33    9    9
34    5    5
35    8    8
36    73    .
37    7    7
38    5    5
39    74    =
40    61, 55    >RAD
41    21, 0    STO 0
42    61, 26    RTN


Example 1:
Los Angeles to Rome:
Los Angeles (ϕ1 = 34°13’, λ1 = -118°15’)
Rome (ϕ2 = 41°15’, λ2 = 12°30’)
Result: 6322.2196 mi

Example 2:
Dublin to Las Vegas:
Dublin (ϕ1 = 53°20’52”, λ1 = -6°15’35”)
Las Vegas (ϕ2 = 36°10’30”, λ2 = -115°08’11”)
Result: 4938.7520 mi
Visit this user's website Find all posts by this user
Quote this message in a reply
06-03-2017, 10:00 PM (This post was last modified: 06-03-2017 11:40 PM by Marcel.)
Post: #2
RE: (20S and 21S) Great Circle
Hi Eddie!

For an other planet, the user must change the numerical factor!!!.. the radius of the planet in miles or km.

Marcel
Find all posts by this user
Quote this message in a reply
06-04-2017, 03:37 PM (This post was last modified: 06-04-2017 07:08 PM by Dieter.)
Post: #3
RE: (20S and 21S) Great Circle
(06-03-2017 10:00 PM)Marcel Wrote:  For an other planet, the user must change the numerical factor!!!.. the radius of the planet in miles or km.

Since most planets are not perfect spheres there is not a single radius. For instance the WGS84 system (cf. GPS) works with an Earth radius of 6378,137 km in East-West direction and with 6356,7523 km for North-South.

Eddie's formula uses a constant radius of 3958,75 miles or 6371 km. This is a good choice that minimizes the error of the calculation (cf. here). Yet there still is a potential error of 0,5%. So the result should be rounded to at most three significant digits. For the given examples that's 6320 resp. 4940 miles.

A final hint: enter an angle, and 1 P→R simultaneously returns both sine (in Y) and cosine (in X).
Edit: this works on classic RPN calculators and probably cannot be used for the algebraic 20S and 21S.

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)