Mercator Sailing: Course and Distance

+- HP Forums (http://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: HP Prime Software Library (/forum-15.html)
+--- Thread: Mercator Sailing: Course and Distance (/thread-11196.html)



Mercator Sailing: Course and Distance - Eddie W. Shore - 08-09-2018 10:08 PM

Introduction

The following program MERCATOR calculates the course direction and distance in miles given two pairs of latitude (north/south) and longitude (east/west). Conversion to arc minutes will be required during calculation.

Code:

EXPORT MERCATOR()
BEGIN
// EWS 2018-08-10
// The Calculator Afloat

HAngle:=1; // degrees
LOCAL L1,L2,λ1,λ2,M1,M2;
LOCAL C,D;

INPUT({L1,λ1,L2,λ2},"Mercator",
{"L1:","λ1:","L2:","λ2:"},
{"Latitude 1",
"Longitude 1",
"Latitude 2",
"Longitude 2"});

M1:=7915.7045*LOG(TAN(45+L1/2))
-23.2689*SIN(L1);
M2:=7915.7045*LOG(TAN(45+L2/2))
-23.2689*SIN(L2);

LOCAL M;
C:=ABS(λ1-λ2)*60;
M:=ABS(M2-M1);
C:=ATAN(C/M);

D:=ABS(L2-L1)*60/COS(C);

RETURN {C,D};

END;

Example

Latitude 1: 43° 21’ 16” N = 43.3544444444°
Longitude 1: 102° 54’ 16” W = 102.9044444444°
Latitude 2: 42° 4’ 30” N = 42.075°
Longitude 2: 106° 3’ 8” W = 106.0522222222°

Results:

Course: 5.782390957°

Distance: 189.832588 mi

Source:

Henry H. Shufeldt and Kenneth E. Newcomer The Calculator Afloat: A Mariner’s Guide to the Electronic Calculator Naval Institute Press: Annapolis, Maryland. 1980