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(lon2lon1))*6371
the formulae for initial track (bearing) is:
è =ATAN2(COS(lat1)*SIN(lat2)SIN(lat1)*COS(lat2)*COS(lon2lon1),
SIN(lon2lon1)*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.
