Post Reply 
Mercator Sailing: Course and Distance
08-24-2018, 07:21 PM (This post was last modified: 08-24-2018 08:23 PM by Gene222.)
Post: #4
RE: Mercator Sailing: Course and Distance
Two weeks and no response. I guess Eddie is not following his own post.

I bought Calculator Afloat in the late 80s or early 90s to learn more about geodetic calculations. It's a good book, but it does not go into much detail about the signage for the latitude and longitude calculations. You perform the calculations first then mentally apply the proper signage to the results.

I modified Eddie's program where South latitudes and West longitudes must be entered as negative numbers in degrees, but I ran into a problem when the two points have the same latitude, such as

Lat 40 N, Long 25 W
Lat 40 N, Long 30 W

In this case, the course and distance equations give division by zero error messages. How do you calculate the course and distance on a parallel?

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 in degrees, +N, -S",
"Longitude 1 in degrees, +E, -W",
"Latitude 2 in degrees, +N, -S",
"Longitude 2 in degrees, +E, -W"});

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,DLo,l,θ;
DLo:=(λ2-λ1)*60; //difference in longitude in minutes
m:=(M2-M1);      //difference in meridional parts in minutes
θ:=ATAN(DLo/m);  //course in degrees relative to North (+ or -) or South (+ or -)
l:=(L2-L1)*60;   //difference in latitude in minutes

IF DLo>=0 AND m>=0 THEN
  C:=θ;
END;

IF DLo<0 AND m>=0 THEN 
  C:=360+θ; 
END;

IF DLo<0 AND m<0 THEN
  C:= 180+θ;
END;

IF DLo>=0 AND m<0 THEN
  C:=180+θ;
END;

D:=ABS(l/COS(θ));

RETURN {C,D};

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


Messages In This Thread
RE: Mercator Sailing: Course and Distance - Gene222 - 08-24-2018 07:21 PM



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