The Museum of HP Calculators

HP Forum Archive 21

[ Return to Index | Top of Index ]

prime programming / great circle formulae
Message #1 Posted by geoff quickfall on 26 Sept 2013, 3:48 p.m.

Hello from an ABSOLUTE newbie to the Prime:

just got back from HHC2013 and of course the focus was on the Prime. Just so the 34S crowd does not get to upset I did pick up three new overlays from Eric: thanks Eric.

Plan on leaving one on the prize desk for next year fully loaded with IR, Clock ...

Back to the Prime; yes I can read the whole manual (I will) but I want to get to the programming and I learn that by looking at others examples.

The program is simple, I have done it in RPN, Basic, RPL, Fortran but not in Prime of course.

This would be a simple Great Circle program using four inputs,

LAT1
LON1
LAT2
LON2

being the departure(1) and the arrival (2) latitudes and longitudes.

the formulae for distance is:

=ACOS(SIN(lat1)*SIN(lat2)+COS(lat1)*COS(lat2)*COS(lon2-lon1))*6371

the formulae for initial track (bearing) is:

è =ATAN2(COS(lat1)*SIN(lat2)-SIN(lat1)*COS(lat2)*COS(lon2-lon1), 
       SIN(lon2-lon1)*COS(lat2))

*note that the formulae for bearing reverses the arguments to ATAN2 – see notes below

Since atan2 returns values in the range -ð ... +ð (that is, -180° ... +180°), to normalise the result to a compass bearing (in the range 0° ... 360°, with ve values transformed into the range 180° ... 360°), convert to degrees and then use (è+360) % 360, where % is modulo.

For final bearing, simply take the initial bearing from the end point to the start point and reverse it (using è = (è+180) % 360).

I am trying not to be lazy here but any takers?

Cheers, Geoff

Edited: 26 Sept 2013, 3:50 p.m.

      
Re: prime programming / great circle formulae
Message #2 Posted by David Hayden on 26 Sept 2013, 9:25 p.m.,
in response to message #1 by geoff quickfall

Quote:
the formulae for distance is:

=ACOS(SIN(lat1)*SIN(lat2)+COS(lat1)*COS(lat2)*COS(lon2-lon1))*6371


Geoff, I think you mentioned in your HHC2013 talk that your great circle distance calculations sometimes don't match the onboard computer and you attributed it to the large size (10 miles) of airports.

The calculation above appears to assume that the earth is perfectly round. In fact, it's oblong, stretched at the equator by centrifugal force. I know there's a more accurate equation in one of my astronomy books, but I can't find it at the moment.

Dave

            
Re: prime programming / great circle formulae
Message #3 Posted by Dave Shaffer (Arizona) on 26 Sept 2013, 11:11 p.m.,
in response to message #2 by David Hayden

This which leads to this lead you to the gory details!

                  
Re: prime programming / great circle formulae
Message #4 Posted by Geoff Quickfall on 27 Sept 2013, 12:17 a.m.,
in response to message #3 by Dave Shaffer (Arizona)

Both Dave's are correct.

The formula used is from the FAA charts and is very accurate over short distances, say between waypoints of 100 miles.

In the talk the gross navigational check between the two distant airports is accurate enough. A few compounding errors enter; is an oblate spheroid correction being used by the FMC, (i will look into that, the manual is 1500 pages) and which datum points are the start and terminus; centre of aerodrome or primary navigational fix?

Eddie, well done, I will enter this and use it as a teaching ( why is part of the word teaching; aching?) exercise. Should I place the calc in exam mode with blinking lights :-)

Thanks Eddie and thanks for the comments at your blog. It is fun to use the calcs at work. The 41CL will make it back to my lab when I get back to school.

Cheers, all

                        
Re: prime programming / great circle formulae
Message #5 Posted by Maximilian Hohmann on 27 Sept 2013, 4:26 a.m.,
in response to message #4 by Geoff Quickfall

Hello!

Quote:
... is an oblate spheroid correction being used by the FMC

Not in ours (Honeywell GNS-XL).

Quote:
...centre of aerodrome or primary navigational fix?

In ours: ARP (aerodrome reference point). Can be anywhere.

Regards, Max

      
Re: prime programming / great circle formulae
Message #6 Posted by Eddie W. Shore on 26 Sept 2013, 10:05 p.m.,
in response to message #1 by geoff quickfall

Will this work?

EXPORT GREATCIR(lat1, lon1, lat2, lon2)
BEGIN
LOCAL D,B;
// D=Distance
// B=Bearing
HAngle:=1;
// Sets the calculator to Degrees mode
// HAngle is found:  Vars, Home, 6. Settings, 1. HAngle

D:=ACOS(SIN(lat1)*SIN(lat2)+COS(lat1)* COS(lat2)*COS(lon2-lon1))*6371;

B:=ATAN((SIN(lon2-lon1)*COS(lat2))/ ((COS(lat1)*SIN(lat2)-SIN(lat1)*COS(lat2) *COS(lon2-lon1)));

B:=(B+180) MOD 360;

// Return distance and bearing to the home screen, in a list RETURN {D, B};

END;

            
Re: prime programming / great circle formulae
Message #7 Posted by Geoff Quickfall on 27 Sept 2013, 1:49 a.m.,
in response to message #6 by Eddie W. Shore

Hi Eddie,

Add another bracket after the last line before the semi colon.

B:=ATAN((SIN(lon2-lon1)*COS(lat2))/ ((COS(lat1)*SIN(lat2)-SIN(lat1)*COS(lat2) *COS(lon2-lon1))));

Also modified with HDigits:=0; and 60 instead of my initial 6371 for nm instead of meters.

I like this!

Thanks so much Eddie!

Geoff

                  
Re: prime programming / great circle formulae
Message #8 Posted by Eddie W. Shore on 27 Sept 2013, 9:35 a.m.,
in response to message #7 by Geoff Quickfall

You are welcome, Geoff. I am glad you find it useful. Just curious how where the 6,371 constant came from?

                        
Re: prime programming / great circle formulae
Message #9 Posted by Ken Shaw on 27 Sept 2013, 9:59 a.m.,
in response to message #8 by Eddie W. Shore

I think this is the assumed radius of the earth in Km (ignoring oblation).

Otherwise, the formula doesn't give a distance.

                              
Re: prime programming / great circle formulae
Message #10 Posted by Geoff Quickfall on 27 Sept 2013, 1:15 p.m.,
in response to message #9 by Ken Shaw

Correct!

      
Re: prime programming / great circle formulae
Message #11 Posted by hugh steers on 27 Sept 2013, 10:43 a.m.,
in response to message #1 by geoff quickfall

Here http://www.voidware.com/dist.html

            
Re: prime programming / great circle formulae
Message #12 Posted by Geoff Quickfall on 27 Sept 2013, 12:55 p.m.,
in response to message #11 by hugh steers

Hugh:

Will do Hugh. I have the whole weekend off in London during your next meeting. I will be there for the AGM and all day Sunday.

Max,

Try the following on your Honeywell:

When flying east to west or vice versus set up three lines of longitude at 90 degrees to your course with varying lengths, in front of your nose.

For example if flying from 60N60W to 60N70W set up the following when passing 60W. Create a disco after your destination airport and insert the following three lines along the same longitude, then create a disco after each line,

65N65W to 55N65W short line @ 600nm

75N65W to 20N65W longer line @ 3300nm

85N65W to 85S65W longest line @ 6000nm

Use Plan mode and 'step' to the new lines in the legs page. You will see three distinct lines! Since it is the same longitude 65W what gives? Interesting mind game with your fellow pilot.

These lines converge and are coincident when the aircraft crosses the 65W point then they diverge again. In fact it looks like the lines bisect the earth, the shortest line sitting near the surface, while the longer lines deeper under the surface. As you fly over the 65W longitude you are looking directly down on all three lines. It would seem that the shortest distance between to distant points is through the earth and not along the surface. For those of you to familiar with FMC/CDU operations we use much shorter distances. The longest distance between two ponts on my flight plans has been 900nm. Therefore the 'burrowing' earth track does not show up. Also, 1 degree of latitude is 60 mm.

Just my explanation, maybe a talk with Honeywell or you may come up with a better one!

Eddie,

Thanks, already learned enough for rudimentary programming inputs, now to fancy things up. A pleasure seeing you again.

Geoff

Edited: 27 Sept 2013, 1:00 p.m.

      
Re: prime programming / great circle formulae
Message #13 Posted by Jim Horn on 27 Sept 2013, 6:20 p.m.,
in response to message #1 by geoff quickfall

Wow, thank you Geoff and Daves! From 1981 through 1990 I was in charge of collecting and reducing the data for the CAFE air races held in California. To compute the distances involved, I used the algorithms in the RAND report "Hand Calculator Programs for Staff Officers" (1976) which used the oblate spheroid model. I added corrections for increased earth radius due to flight altitude and slant range increases due to climbing and descending. But I didn't know about or use the more recent algorithms or spheriod model you've pointed me to.

Fascinating! I'll have to play with the Prime emulator and try getting this to run on same. Should be both fun and informative.

Best to you, Maximilian and all pilots!

            
Re: prime programming / great circle formulae
Message #14 Posted by Geoff Quickfall on 27 Sept 2013, 7:11 p.m.,
in response to message #13 by Jim Horn

Missed you at the meet Jim.

I have always known that the altitude of the flight is not incorporated into the distance ACTUALLY flown. I just never took it to your level (pun intended) with corrections.

Of course I am just checking the ground based but adding 40,000' to the equation does make a difference to the radius!

Cheers

                  
Re: prime programming / great circle formulae
Message #15 Posted by Geoff Quickfall on 27 Sept 2013, 7:12 p.m.,
in response to message #14 by Geoff Quickfall

P.s. playing with the prime is fun! Now if it could only print on my infrared.

            
Re: prime programming / great circle formulae
Message #16 Posted by Kimberly Thompson on 27 Sept 2013, 7:16 p.m.,
in response to message #13 by Jim Horn

Loquitor

for the curious ...

Quote:
I used the algorithms in the RAND report "Hand Calculator Programs for Staff Officers" (1976) which used the oblate spheroid model

Link to Hand Calculator Programs for Staff Officers

... BEST!

SlideRule


[ Return to Index | Top of Index ]

Go back to the main exhibit hall