Saturday, June 3, 2017

HP 20S and HP 21S Great Circle

HP 20S and HP 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

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

Eddie



This blog is property of Edward Shore, 2017.