Perlnav: Navigation in Perl

Andrew D. Lewis 17 March 1998

1 What is Perlnav?

Perlnav is a perl program which does various navigation computations. At the moment it is set up to do the following:

1. keep track of dead reckoning (DR) positions;

2. sight reduction;

3. latitude by meridian transit;

4. sailings;

5. distance off with sextant reading;

6. sextant corrections;

7. determining of times of events from their Greenwich time;

8. handling current computations.

There are also a few other little things which will either be described below, or you can discover by using the program.

It is worth mentioning that Perlnav is not a navigational calculator. It contains no almanac data. It merely serves to perform computations that would be done with lookup tables (e.g. H.O. 249) or by plotting.

2 Installing Perlnav

Modify the user configuration section of the Makefile to set the installation binary directory, the man page directory, the location of Perl binaries and libraries, and the location of the L^{A}TEX documentation. Be careful setting the Perl library directory that you do this properly. This may vary from system to system. Once you have this all figured out, make will build the scripts and man pages, make install will install the scripts, and make man will install the man pages.

Perlnav makes use of some libraries which Jim Radford put together for me. These handle trig functions which perl does not have. To build these libraries go make mathlib and make sure that all tests are okay. To install the libraries in the spots indicated in Makefile go make install.mathlib.

This should do the trick.

3 Entering Data

Provided you know how to provide input for the above computations, using Perlnav is a breeze. Help screens are available for entering angles, time, and distances and this information is also available in the Perlnav man page. Let us also give the particulars here.

1. Angles: These may be entered in two ways:

(a) xxxdyym where xxx is the number of degrees as a whole number and yy is a decimal representation of the number of minutes.

(b) xxx.xxd where xxx.xx is a decimal representation of the number of degrees.

To enter negative angles, put the minus sign on the “degrees” part of the angle. Thus to enter −12′ the proper entry is −0d12m.

If you just hit return when entering an angle, the angle will be taken to be zero.

Latitudes and longitudes must be entered in a manner which indicates whether they are north or south, or east or west. The rule is that north latitude is positive and south latitude is negative, and that west longitude is positive and east longitude is negative.

2. Time: This may be entered in two ways:

(a) xxxxhyys where xxxx is the military time and yy is the number of whole seconds past xxxx.

(b) xxxx.xxh where xxxx.xx is a decimal representation of the military time.

When we say time, we mean both time of day and elapsed time. For example, when performing updates to the DR position, you may need to enter the time elapsed since the previous DR position. This should be entered in the format described above.

3. Distances: Certain distance may be entered in feet, metres, or nautical miles. The way to do this is:

(a) To enter a distance in feet enter xxx.xxft.

(b) To enter a distance in metres enter xxx.xxm.

(c) To enter a distance in nautical miles enter xxx.xxnm.

When performing updates to DR position using course and distance, the distance must be in nautical miles.

4. Speeds: To enter a speed, just enter a positive number. All speeds are assumed to be in nautical miles per hour in the computations.

At times when entering data you remember that you need to do something else before it is possible to finish the computation. In these cases, it is helpful to be able to dump out of the current computation. This may be done at any time by entering r in response to a prompt for data. You will then be returned to the main menu.

4 A Detailed Description of Perlnavs Functions

The remainder of the manual is devoted to describing how Perlnav performs its various computations.

4.1 How Perlnav Keeps Track of Dead Reckoning Positions

When you start Perlnav for the first time, it knows nothing about where you are. However, it is possible to have Perlnav keep track of your current position. There are two ways to do this.

You may choose the menu option for setting the DR position for the current session. If there is no DR position set for the session, the position you enter is called the session DR position. If a session DR position exists, the newly entered position is called the updated DR position. If an updated DR position exists already, the previous updated DR position becomes the session DR position, and the newly entered position becomes the updated DR position. The old session DR position is lost.

Another way to update the DR positions arises when you are performing DR updates with that menu option. In this case, when the updated DR position is computed, you will be asked whether you wish to enter this position as a new DR position. The same rules described above for overwriting the previous session and updated DR positions apply here.

When you exit a Perlnav session where you have changed the DR settings, you will be asked whether you wish to retain any of the settings for the next startup. You have three choices here. Entering s saves the current session DR position to be read at startup the next time you use Perlnav. Entering u saves the current updated DR position. Just hitting return leaves the startup configuration as it was when the session was started. Note that you will only have a single DR position at the next startup if you choose to save the data. This position will become the new session’s session DR position.

The startup DR position for Perlnav is kept in the file .perlnavrc which is kept in the user’s home directory.

When entering data to certain of Perlnav’s functions, it is sometimes helpful to be able to directly enter one of the DR positions. Entering dr is response to a prompt for latitude will set that value to the current session DR latitude. Entering newdr is response to a prompt for latitude will set that value to the current updated DR latitude. Similar statements hold for longitude.

4.2 Sight Reduction

Perlnav will perform sight reduction computations. You will need to enter the name of the body, the DR position, and the GHA and declination of the body. Perlnav then uses the formulas

H_{c} = sin^{−1} (sin L sin d + cos L cos d cos LHA)

Z = cos^{−1} (\frac{sin d − sin L sin H_{c}}{cos L cos H_{c}} )

to determine the computed altitude and azimuth of the body. Here

L  DR latitude
d  declination of body
LHA Local hour angle

The azimuth is properly corrected to give the true azimuth.

4.3 Latitude by Meridian Transit

A common celestial navigation technique is latitude by meridian transit. The simple computations for determining latitude may be performed using Perlnav. Enter the corrected sextant reading, the declination of the body, and the direction of the body at the time of the sight (north or south). The latitude will be returned to you. You will have the option of updating the session DR latitude settings with this computed latitude.

4.4 Using Perlnav to Prepare for Star Sights

Often it is helpful to determine the approximate altitude and azimuth for a set of stars before sights are taken. To assist in this Perlnav will print all available navigational stars at a certain position at a certain time. Of course, you need to do a bit of almanac work. You must enter the latitude and longitude for the sights, the GHA of Aries at the time of the sights, and you can also specify a magnitude for stars above which Perlnav will not give you data. (Remember that the higher the magnitude, the dimmer the star.) After entering the data Perlnav will display one-by-one the stars which are above the horizon with the data you entered. Generally there will be a lot of stars available, so it may take a while to go through the list. It’s up to you to record the data as it comes up.

Of course, you may also use the above procedure to assist in identifying an unknown star which was sighted.

You may also edit the perlnav executable and add stars of your own to the list. Right now the navigational stars only are entered.

4.5 The Sailings

The sailings is a general term given to determining course and distance from a given point of departure and destination. In Perlnav there are three methods you may use to determine course and distance. Each asks that you enter the latitude and longitude for the point of departure and the destination.

4.5.1 Mid-Latitude Sailing

In mid-latitude sailing, the earth is assumed to be a plane and the longitude is scaled by the latitude midway between the point of departure and the destination. This method is adequate for sailing short distances.

4.5.2 Mercator Sailing

Mercator sailing gives the course and distance for the rhumb line route between the point of departure and the destination. In this method, the latitudes are converted to meridian distance using a formula. The data is tabulated in Bowditch, but Perlnav uses the formula

7915.704 log_{10} (tan (45 + L/2)) − 23.013 sin L − 0.051 sin^{3} L

which may be found in Alton B. Moody’s Navigation Afloat.^{1} The differences between this formula and the tabulated data in Bowditch are negligible.

4.5.3 Great Circle Sailing

As you might guess, great circle sailings give the great circle course and distance between the point of departure and the destination. These computations are given by

D = 60 cos^{−1} (sin L_{0} sin L_{1} + cos L_{0} cos L_{1} cos t)
C_{0} = cos^{−1} (\frac{sin L_{1} − sin L_{0} cos D}{cos L_{0} sin D} )
C_{1} = cos^{−1} (\frac{sin L_{0} − sin L_{1} cos D}{cos L_{1} sin D} )

Since the course generally changes continually along a great circle route, Perlnav will give only the initial and final courses, C_{0} and C_{1}. These are corrected from the above formulas to give the proper values depending on the relative positions of the point of departure and the destination.

4.6 Distance Off

In piloting, one way to obtain a line (in fact a circle) of position is by using the distance off formula. One simply enters the sextant reading to the top of the object and the charted height of the object, and the radius of the circle of position is returned.

4.7 Sextant Corrections

When a sextant reading is taken, it must be corrected for various factors. Perlnav will perform these corrections for you if you enter the proper data. This data is 1. the sextant reading,

1van Nostrand Reinhold Company, New York, New York, 1980

2. the index error,

3. the height above sea level,

4. a semi-diameter correction,

5. a correction for horizontal parallax, and

6. a correction for refraction.

Recall that a negative angle is specified by putting the minus sign on the “degrees.” Thus −12′ is entered as −0d12m.

4.8 Determining the Zone Time of Phenomenon

If you know when something happens at Greenwich and you know your longitude, you can determine when that something will happen at your position. (By something I mean a celestial event.) Perlnav will do these calculations for you.

4.9 Dead Reckoning UpDates

You will often wish to determine your position given an initial position, and a course and distance travelled. In Perlnav there are two ways to do this. You can make the updates using either mid-latitude or Mercator computations. See the sailings above for a description of these methods. In each case you will be asked to enter the previous dead reckoning position, the true course, and either the distance travelled, or the time and speed. The new DR position will be output and you will have the option of using it to update the current session or updated DR position.

4.10 Current Problems

When the set and drift of a current is known, it is possible to determine various information about the boat’s progress in the presence of this current. There are three problems which Perlnav will solve.

1. Given the current’s set and drift, the desired course over ground, and the boat speed, you may determine the course to be steered and the speed of advance.

2. Given the current’s set and drift, and the boat’s speed and course, the course and speed of advance may be computed.

3. Given the boat’s speed and course, and the course and speed made good, the current’s set and drift may be determined.

4.11 Getting Help While Using Perlnav

In the main menu, there is a help option. Selection this option will give you another menu of various help topics. Some of these describe how to enter data, and other describe certain Perlnav functions. I also put little notes to myself about things I find hard to remember (e.g. deviation and variation corrections).

4.12 Miscellany

In the Perlnav package is a directory forms which contains a L^{A}TEX file forms.tex. This will create a few forms which I find helpful for organising computations.

I have not checked every aspect of Perlnav and am making it available so it can be tested and perfected. So use it at your own risk. However, as is often the case with navigation computations, errors are normally obvious.

Please send any comments and errors to: andrew@mast.queensu.ca.