Mercator Sailing: Course and Distance
09-04-2018, 07:19 PM (This post was last modified: 09-04-2018 07:21 PM by Dieter.)
Post: #21
 Dieter Senior Member Posts: 2,397 Joined: Dec 2013
RE: Mercator Sailing: Course and Distance
(09-03-2018 10:10 PM)Gene222 Wrote:  Thanks for your comments on the program. I definitely bit off more than I could chew with this program. The revised program is attached.

Thank you, the results look good to me.

Maybe you can remove the "this check box is not used" part. Unless there is something I haven't realized yet. ;-)

Finally we got another example of this forum's power: in a collaborative effort we now got a solution that also handles East-West courses that even some online calculators don't calculate correctly.

Dieter
09-05-2018, 05:46 PM (This post was last modified: 09-11-2019 12:12 AM by Gene222.)
Post: #22
 Gene222 Member Posts: 107 Joined: Feb 2015
RE: Mercator Sailing: Course and Distance
FYI. The book "The Calculator Afloat" was written by H. H. Shufeldt and Kenneth E Newcomer. A review of the book (below) was printed in the December 1980 HP Key Notes. It says Newcomer worked for HP and developed the HP-65 Navigation Pac. I never bought the Nav Pac for my HP-41, but I eventually did buy the book.

09-22-2018, 11:37 PM
Post: #23
 Eddie W. Shore Senior Member Posts: 1,405 Joined: Dec 2013
RE: Mercator Sailing: Course and Distance
(08-12-2018 05:13 PM)Dieter Wrote:
(08-10-2018 03:08 AM)Eddie W. Shore Wrote:  Latitude 1: 102° 54’ 16” W = 102.9044444444°
Longitude 1: 43° 21’ 16” N = 43.3544444444°
Latitude 2: 106° 3’ 8” W = 106.0522222222°
Longitude 2: 42° 4’ 30” N = 42.075°

Results:

Course: 5.782390957°

Distance: 189.832588 mi

Eddie, I think you confused latitudes and longitudes here. There are no latitudes > 90°.

I also wonder how you get these results. For the given data I get a distance of 159,03 nmi and a course of 61,14° Southwest (241,14° true course). This matches the result of an online calculator where I checked the results.

Finally, what sign convention does your program use? Are West and South positions entered with negative sign?

Dieter

I always get latitude and longitude mixed up. Going by the book's examples (pg. 78), north and west were entered as positives.
09-22-2018, 11:39 PM
Post: #24
 Eddie W. Shore Senior Member Posts: 1,405 Joined: Dec 2013
RE: Mercator Sailing: Course and Distance
(08-24-2018 07:21 PM)Gene222 Wrote:  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;

My apologizes for not following subscribing to the program posts I put up; something I will do from now on. I appreciate all the comments and modifications.

Eddie
09-10-2022, 03:17 PM
Post: #25
 Albert Chan Senior Member Posts: 2,096 Joined: Jul 2018
RE: Mercator Sailing: Course and Distance
(08-26-2018 07:18 AM)Dieter Wrote:  Hint: the expression ln(tan(45°+x/2)) in the "book" formula is equivalent to artanh(sin(x)).

FYI, atanh(sin(x)) = asinh(tan(x)) = gd-1(x) = x + x^3/6 + x^5/24 + ...

https://en.wikipedia.org/wiki/Gudermannian_function
The Secret Connection between Hyperbolic and Trigonometric Functions

12-21-2022, 08:31 PM
Post: #26
 VadimV Junior Member Posts: 1 Joined: Dec 2022
RE: Mercator Sailing: Course and Distance
(08-31-2018 05:46 AM)Dieter Wrote:
(08-31-2018 02:15 AM)Gene222 Wrote:  I see what I am doing wrong. The course is 270 (due west) on a Mercator map. I was looking a polar map. I guess starpath.com online Mercator calculator was right.

For the record: my 35s program returns 1875,78 miles and a course exactly West, true course 270°.

By the way, the result 1875,4003 nm of the starpath.com Mercator Calculator simply is 180°·60·cos(80°). This is a simplified formula that ignores (!) the ellipsoid's eccentricity. That's why there is another factor in my same-latitude-formula – which returns the correct result.

(08-31-2018 02:15 AM)Gene222 Wrote:  I still have errors in my program. The Latitude difference for the above problem is 600' and the Meridional parts for point 1 and 2 are not the same.

This really sounds like there are errors. ;-)
For 80° the meridional parts (WGS84) should be 8352,48.

Your results of –3456,8203 and –4507,4040 are the meridional part values for latitudes of –50° and –60°, respectively. Maybe this helps finding the error.

(08-31-2018 02:15 AM)Gene222 Wrote:  My procedure for East-West courses needs to be cleaned up, which should be easy to do.

I can't read your program (no Prime here), but from what I see when I open it in a text editor the program distinguishes various cases for different hemispheres. For instance in one case the absolute values of the meridional parts are added. I don't think this is required – the sign convention handles this automatically. Try it.

Here is the way I do the calculation, in pseudocode. I hope I got it right. ;-)

Code:
e=0,08181919... M1=Meridionalparts(lat1)     M2=Meridionalparts(lat2) DMP=M2-M1 dlong=long2-long1 if dlong < -180 then dlong=dlong+360 if dlong > +180 then dlong=dlong-360    // edit: corrected this line dlongminutes=60*dlong dlatminutes=60*(lat2-lat1) if DMP=0 then    course=0    distance=abs(dlongminutes)*cos(lat1)*(1-e^2*sin^2(lat1))/(1-e^2) else    course=arctan(abs(dlongminutes/DMP))    distance=abs(dlatminutes)/cos(course) end

Finally the true course is calculated. I do it wih the 35s "ARG" command which returns something like ATAN2 in some programming languages, a quadrant-adjusted angle (0...180 for Q1 and Q2, 0...-180 for Q3 and Q4, in this case add 360°), and it also works for DMP=0. You'll know how to do it on the Prime. ;-)

Dieter

Dieter,

Thank you for this. Using your equations (in Excel) for MP and dLon when MP=0, namely: