NavList:
A Community Devoted to the Preservation and Practice of Celestial Navigation and Other Methods of Traditional Wayfinding
Re: Cap'n tips
From: Dennis Armstrong
Date: 1999 Feb 16, 06:24 EST
From: Dennis Armstrong
Date: 1999 Feb 16, 06:24 EST
Dan Hogan wrote:
> Steven:
>
> Sigh...where were you in 1988 when I gave away my MAC for M$ because
> there were not ant decent navigation programs for the MAC.
>
> I just changed my old Gateway box to Linux with RedHat 5.2. It will run
> most Unix programs. Besides the usual SR and DR stuff, I would like to
> see a program that has a Traverse Table built in and/or will print to a
> file Fixes and DR data in a Traverse style log, so that one has a
> continuous record of the voyage navigation. re that the current working
> window can be copied and pasted in addition to printed to a file. Right
> now I use Navig94 and a pair of HP 32SII's for Silicon Sea.
>
> > Incidently, I am rewriting my Mac navigation program for Windows and UNIX
> > and would be interested in suggestions for features.
> >
> > > --
>
> Cheers
> -Dan-
>
Steven
I have a library of marine functions written in C availiable under GNU
copyleft which you may be interested in using.
It compiles under solaris, linux, atari, comodore and microsoft C, it is
a library so you have to write the user interface on the platform you require.
I have attached the header file to give some idea of what is availiable
it's still work in progress but I use it with my tide calculation program.
regards
<PRE>
--
===============================SLO==================================
Dennis Armstrong email: dba@XXX.XXX
Isaac Newton Group Tel: +34 922 425423
Royal Greenwich Observatory FAX: +34 922 425401
Apartado 321, 38780 S/C La Palma, The Canary Islands, SPAIN
</PRE>
/*************************************************************************
* File : $Id: marinlib.h,v 1.3 1998/06/11 22:54:16 dba Exp $ @
* Language : C (POSIX.1-1990 compliant) *
* Description : marine library source file header *
* *
* Copyright : (C) 1998 D. B. Armstrong *
* Dennis.Armstrong@XXX.XXX *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Library General Public License as published *
* by the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; if not, write to:- *
* The Free Software Foundation Inc., *
* 675 Massachusetts Ave, Cambridge, MA 02139, USA. *
* *
* References : Admiralty method of Tidal Prediction (NP159) *
* Admiralty Tide Tables (NP401) *
* Admiralty Manual of Tides (NP120) *
* *
* Australian National Tide Tables *
* Australian Hydrographic Publication 11 *
* *
* Manual of Harmonic Analysis and Prediction of Tides. *
* Special Publication No. 98, Revised (1940) Edition. *
* United States Government Printing Office, 1941. *
* *
* Astronomical Algorithms *
* Jean Meeus ISBN 0-943396-35-2 *
* *
* Compact Data for Navigation and Astronomy 1996-2000 *
* Yallop and Hohenkerk ISBN 011-772467-X *
* *
* The Macmillan and Silk Cut Yachtsmans Handbook *
* Third Edition ISBN 0-333-58018-4 *
* *
* Multiyear Interactive Computer Almanac MICA *
* US Naval Observatory *
* ISBN 0-943396-56-5 *
* *
* The American Practical Navigator *
* Bowditch *
* Publication No 9 (1995) *
* Defense Mapping Agency Hydrographic/Topographic Center *
* DMA STOCK No NVPUB9V1 *
* *
* *
***************************************************************************/
/* $Log: marinlib.h,v $
* Revision 1.3 1998/06/11 22:54:16 dba
* added mar_calc_wchill prototype
*
* Revision 1.2 1998/06/05 21:40:50 dba
* added CVS Log variable
*
*
*/
#ifndef _MARINLIB_H
#define _MARINLIB_H
#include <limits.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <errno.h>
#ifndef PATH_MAX
#define PATH_MAX 255
#endif
#ifndef NAME_MAX
#define NAME_MAX 128
#endif
#define SUCCESS (0)
#define FAILURE (-1)
#ifndef PI
#define PI 3.14159265359
#endif
#define BUFSIZE 1024L
#define DEBUG
#define DBG_MARINLIB 0x0100
#define PORTNUM 7
#define PORTNLEN 38
#define MAX_PORTS 800
#define NUM_FACTORS 12
#define NUM_FACTORS_MAX 36
#define LLLEN 13
#define MAJ_VERSION 1 /*--- port file Major version number ---*/
#define MIN_VERSION 0 /*--- port file minor version number ---*/
#define TOLOCAL 1
#define TOGMT 2
#define NUM_TIMES 960 /* 24 hours * 40 = 1.5 minute intervals */
#define CH_SIZE 12 /* max number of time+height daily pairs */
#define LEAP 1
#define NOLEAP 0
#define TIDESTATIC 1 /* state of tide - rising - falling */
#define ASCENDING 2
#define DESCENDING 4
#define NMTYPE 0
#define SMTYPE 1
#define KMTYPE 3
#define SECDISP 1 /* required conversion type */
#define MINDISP 2
#define MAX_NOBS 4 /* max number of obs for a fix */
/* tide constants (TK_) */
#define TK_M2 28.9841042
#define TK_S2 30.0000000
#define TK_K1 15.0410686
#define TK_O1 13.9430356
#define TK_SA 0.0410686
#define TK_SSA 0.0821373
#define TK_MM 0.5443747
#define TK_MSF 1.0158958
#define TK_MF 1.0980330
#define TK_S1 15.0000000
#define TK_Q1 13.3986609
#define TK_P1 14.9589314
#define TK_N2 28.4397295
#define TK_NU2 28.5125832
#define TK_K2 30.0821373
#define TK_L2 29.5284789
#define TK_2N2 27.8953549
#define TK_MU2 27.9682085
#define TK_T2 29.9589333
#define TK_M4 57.9682085
#define TK_MS4 58.9841042
#define TK_2MS6 87.9682085
#define TK_MN4 57.4238338
#define TK_SIG1 12.9271398
#define TK_J1 15.5854433
#define TK_OO1 16.1391017
#define TK_M8 115.9364169
#define TK_2Q1 12.8542862
#define TK_RHO1 13.4715145
#define TK_CHI1 14.5695476
#define TK_PI1 14.9178647
#define TK_PSI1 15.0821353
#define TK_PHI1 15.1232059
#define TK_THE1 15.5125897
#define TK_LDA2 29.4556253
#define TK_R2 30.0410667
#define TK_M3 43.4761564
#define TK_SO1 16.0569644
#define TK_SO3 43.9430356
#define TK_MK3 44.0251729
#define TK_SK3 45.0410686
#define TK_MK4 59.0662415
#define TK_S4 60.0000000
#define TK_2MN6 86.4079380
#define TK_M6 86.9523127
#define TK_2MK6 88.0503457
#define TK_2SM6 88.9841042
#define TK_2SM2 31.0158958
#define TK_EPS2 27.4238338
#define TK_ETA2 30.6265120
#define TK_MKS2 29.0662415
#define TK_MO3 42.9271398
#define TK_MSN6 87.4238338
#define TK_TAU1 14.0251729
#define TK_OP2 28.9019670
#define TK_OQ2 27.3416965
#define TK_MSK6 89.0662415
#define TK_MSN2 30.5443747
#define TK_SK4 60.0821373
#define TK_SN4 58.4397295
#define TK_NO1 14.4966940
#define NUM_TK 61
/*--- end of tide constants ---*/
#define NUM_ASBODY 66
/*--- warnings ---*/
#define MAR_W_MAXDAT -99
/*--- errors ---*/
#define MAR_E_INVF -100
#define MAR_E_NODAT -101
#define MAR_E_INVPNU -102
#define MAR_E_INVPNA -103
#define MAR_E_INVLAT -104
#define MAR_E_INVLON -105
#define MAR_E_INVTZ -106
#define MAR_E_INVFAC -107
#define MAR_E_NOTZ -108
#define MAR_E_INVPFV -109
#define MAR_E_INVZO -110
#define MAR_E_WDAT -111
#define MAR_E_INVCO -112
#define MAR_E_INVSPD -113
#define MAR_E_INVDST -114
#define MAR_E_INVDWE -115
#define MAR_E_INVHE -116
#define MAR_E_INVIE -117
#define MAR_E_INVNFX -118
#define MAR_E_INVBDY -119
#define MAR_E_INVHS -120
#define MAR_E_INVZ -121
#define MAR_E_INVYEAR -122
#define MAR_E_INVMON -123
#define MAR_E_INVDAY -124
#define MAR_E_INVHOUR -125
#define MAR_E_INVMIN -126
#define MAR_E_INVTEMP -127
#define MAR_E_INVPR -128
#define MAR_E_DATOOR -129
#define MAR_E_LRQD -130
#define MAR_E_INVLIM -131
#define MAR_E_UNKBODY -132
#define MAR_E_INVVER -133
#define MAR_E_INVPA -134
#define MAR_E_INVDAT -135
#define MAX_EMSG -135
#define NOLIMB 0
#define LL 1
#define UL 2
#define U_METRIC 0
#define U_IMPERIAL 1
/* defines for RISE/SET */
#define AS_NORMAL 0
#define AS_POLARDAY 1
#define AS_POLARNIGHT 2
static char const mar_head_rcsid[] = "$Id: marinlib.h,v 1.3 1998/06/11 22:54:16 dba Exp $";
enum wfact {M2_A,M2_F,
S2_A,S2_F,
K1_A,K1_F,
O1_A,O1_F,
F4_A,F4_F,
F6_A,F6_F};
enum obsbod {SATURN = -6, JUPITER, MARS, VENUS, SUN, MOON,
LANDMARK, ALPHERATZ, ANKAA, SCHEDAR, DIPHDA, ACHERNAR,
HAMAL, ACAMAR, MENKAR, MIRFAK, ALDEBARAN, RIGEL,
CAPELLA, BELLATRIX, ELNATH, ALNILAM, BETELGEUSE, CANOPUS,
SIRIUS, ADHARA, PROCYON, POLLUX, AVIOR, SUHAIL,
MIAPLACIDUS, ALPHARD, REGULUS, DUBHE, DENEBOLA, GIENAH,
ACRUX, GACRUX, ALIOTH, SPICA, ALKAID, HADAR,
MENKENT, ARTURUS, RIGIL_KENTAURUS, ZUBENELGENUBI,
KOCHAB, ALPHECCA, ANTARES, ATRIA, SABIK, SHAULA,
RASALHAGUE, ELTANIN, KAUS_AUSTRALIS, VEGA, NUNKI,
ALTAIR, PEACOCK, DENEB, ENIF, AL_NAIR, FORMALHAUT,
MARKAB, POLARIS, OCTANTIS
};
/*--- structure definitions ---*/
typedef struct factors {
double fa[NUM_FACTORS];
double fb[NUM_FACTORS];
} TAAFF;
typedef struct fact {
double a;
double f;
} TAF;
typedef struct pos {
double lat; /* lat = Latitude */
double lon; /* lon = Longitude */
} POSITION;
typedef struct comp {
double t; /* true course */
double v; /* variation */
double m; /* magnetic course */
double d; /* deviation */
double c; /* compass course */
} COMPASS;
typedef struct mvm {
double Co; /* course bearing */
double Spd; /* speed */
double Dst; /* distance */
} MOVEMENT;
typedef struct lop {
struct pos p; /* lat Latitude */
/* lon Longitude */
struct mvm m; /* Co bearing (az) */
/* Spd speed (not used) */
/* Dst distance (to/away) */
struct tm t; /* int tm_sec */
/* int tm_min */
/* int tm_hour */
/* int tm_mday */
/* int tm_mon */
/* int tm_year */
/* int tm_wday */
/* int tm_yday */
/* int tm_isdst */
} LOP;
typedef struct pdat {
char num[PORTNUM+1];
char name[PORTNLEN+1];
struct pos port;
} PORTDATA;
/*--- port data file header information ---*/
typedef struct pfdata {
char area[PORTNLEN+1];
int ntkf;
double nlat;
double slat;
double wlon;
double elon;
int vmaj;
int vmin;
} PFILEDATA;
typedef struct pf {
PORTDATA p;
double Tz;
double Zo;
double factor[NUM_FACTORS];
TAF fac[NUM_FACTORS_MAX];
} PORTFACTOR;
/*--- tidal vector structures ---*/
typedef struct tv {
double rate; /*--- tidal rate (knots) ---*/
double dir; /*--- tidal direction (0 - 360 degrees) ---*/
} TV;
typedef struct tvect {
char num[PORTNUM+1]; /*--- reference port number ---*/
char cr[PORTNUM+1]; /*--- chart reference (tidal diamond) ---*/
int chart; /*--- chart number (BA list) ---*/
POSITION tp; /*--- tidal vector position (lat,long) ---*/
TV v[13]; /*--- tidal vectors ---*/
} TVECT;
/*--- tidal time and height structures ---*/
typedef struct ttd {
double Ttt; /*-- time of high and low water ---*/
double Tth; /*-- height of high and low water ---*/
} TIMETAB;
typedef struct mt {
TIMETAB t[CH_SIZE];
} MTB;
typedef struct dtd {
TIMETAB Dy[4];
} DAYTAB;
/*--- definition for the monthly tide table data ---*/
typedef struct tidetab {
DAYTAB ti[31]; /*-- times of high and low water ---*/
char dys[31][3]; /*-- day of week string for the month ---*/
double mn[31]; /*-- moon phase ---*/
char mnth[12];
} MONTHTAB;
/*--- astro nav structures ---*/
typedef struct bod {
int bdnum; /* observed body num */
char *bdnam; /* observed body name */
double ra; /* Right Ascension at J2000.0 (dec hours) */
double dec; /* Declination at J2000.0 (dec degrees) */
double pmra; /* proper motion in R.A at J2000.0 (sec/julian_cent) */
double pmd; /* proper motion in Dec. at J2000.0 (arcsec/julian_cent)*/
double par; /* Parallax (arcsec) */
double radvel; /* Radial Velocity (Km/sec) */
double mag; /* Magnitude */
} BOD;
/*--- observations or sextant readings ---*/
typedef struct sex {
int body; /* observed body num */
int lim; /* limb none = 0 L=1 U=2 */
double Hsd; /* deg 0 to +89 or lat */
double Hsm; /* min 0 to +59.9 or long */
double Z; /* Az Bearing 0 - 360 */
struct tm dwt; /* int tm_sec (GMT) */
/* int tm_min */
/* int tm_hour */
/* int tm_mday */
/* int tm_mon */
/* int tm_year */
/* int tm_wday */
/* int tm_yday */
/* int tm_isdst */
} SEXREAD;
/*--- fix ---*/
typedef struct sfx {
POSITION fx; /* double lat */
/* double lon */
MOVEMENT m; /* vessel movement vectors*/
/* course bearing (deg) */
/* speed (knots) */
/* distance (Nm) */
MOVEMENT ti; /* tidal movement vectors */
/* direction (deg) */
/* rate (knots) */
/* distance (Nm) */
struct tm fxt; /* int tm_sec (GMT) */
/* int tm_min */
/* int tm_hour */
/* int tm_mday */
/* int tm_mon */
/* int tm_year */
/* int tm_wday */
/* int tm_yday */
/* int tm_isdst */
int dwe; /* deck watch error (sec) */
double Tz; /* time zone */
double He; /* Height of eye (meters) */
double Ie; /* Index error */
double temp; /* Temperature (deg C) */
double pr; /* Pressure (mb) */
SEXREAD sr[MAX_NOBS]; /* sextant readings */
} FIX;
typedef struct astrotm {
PORTDATA p; /* char num[] */
/* char name[] */
/* double port.lat */
/* double port.lon */
struct tm t; /* int tm_sec */
/* int tm_min */
/* int tm_hour */
/* int tm_mday */
/* int tm_mon */
/* int tm_year */
/* int tm_wday */
/* int tm_yday */
/* int tm_isdst */
double Tz; /* time zone */
struct tm ras; /* int tm_hour Rise Hours Astro */
/* int tm_min Rise Minutes Astro */
struct tm rna; /* int tm_hour Rise Hours Naut */
/* int tm_min Rise Minutes Naut */
struct tm rci; /* int tm_hour Rise Hours Civil */
/* int tm_min Rise Minutes Civil */
struct tm rsu; /* int tm_hour Rise Hours Sun */
/* int tm_min Rise Minutes Sun */
struct tm sas; /* int tm_hour Set Hours Astro */
/* int tm_min Set Minutes Astro */
struct tm sna; /* int tm_hour Set Hours Naut */
/* int tm_min Set Minutes Naut */
struct tm sci; /* int tm_hour Set Hours Civil */
/* int tm_min Set Minutes Civil */
struct tm ssu; /* int tm_hour Set Hours Sun */
/* int tm_min Set Minutes Sun */
int aspv; /* polar day, polar night or normal rise/set */
} ASTROTIME;
/* Prototypes for functions defined in MAR_ASTRO.C */
void astro_A_to_T(struct tm *, double a);
void astro_T_to_A(struct tm, double *);
void lon_to_eq(double, double *, double *);
void eq_to_altaz(double,double,double, double, double, double *, double *);
void jd_to_calender(int *, int *, int *, double);
int astro_calc(ASTROTIME *);
int day_month(struct tm *);
int mar_calc_mnGHA(char *, double *, double *, double *, struct tm *);
int mar_calc_spGHA(char *, double *, double *, double *, int, struct tm *);
int mar_calc_starGHA(char *, double *, double *, int, struct tm *);
int mar_el_days(int *, unsigned long int, struct tm *);
int rise_set(double, double, double, double *, double *, double *, double *);
int sunsh(double, double, double, double);
double julian_date(int, int, double);
double astro_riseset(double, double, double, double *);
double solar_declination(double);
double solar_lon(double);
double acos_deg(double);
double asin_deg(double);
double atan_q_deg(double, double);
double atan_deg(double);
double sin_deg(double);
double cos_deg(double);
double tan_deg(double);
double gmst(double, double);
double lst_to_gst(double, double);
double lst_to_gmt(double, double, int, double, double);
/* Prototypes for functions defined in MAR_TIDE.C */
void mar_calc_range(struct pf, double *, double *);
int mar_calc_tide( int, double, double dht[], struct pf, struct factors);
int mar_day_data( char *, struct tm *, struct factors *);
int mar_hl_calc( int, double *, int, struct ttd xx[], int *);
int mar_mtide( char *, struct tm , struct mt *, struct pf, int);
int mar_p_factors( char *, struct pf *, int, struct tm *);
int mar_ports( char *, struct pdat *, int *, struct pfdata *);
int mar_tvd_factors( char *, struct tvect *, int);
/* Prototypes for functions defined in MAR_GENR.C */
void mar_a2t( struct tm *, double);
void mar_calc_altandaz( struct pos, double, double, double *, double *);
void mar_calc_abst( struct tm *, struct tm *, double, double);
void mar_cvt_dts( char *, struct tm);
void mar_cvt_std( const char *, struct tm *);
void mar_dh_to_hms( double, int *, int *, int *);
void mar_geod_dist( struct pos, struct pos, double *);
void mar_lathms( double, char *, int);
void mar_ll2UTM( struct pos, double *, double *);
void mar_lonhms( double, char *, int);
void mar_t2a( struct tm, double *);
void mar_update_fix( struct pos, struct mvm, struct mvm, struct pos *);
int mar_ISO_cvt( const char*, char *, int, unsigned char *);
int mar_calc_lop( struct sfx, struct lop *, int);
int mar_calc_wchill( double, double, double *);
int mar_checkleap( struct tm);
int mar_cvtgmt( struct tm *, struct tm *, double, int);
int mar_export_swp( char *, int, int, struct pdat *, struct tm);
int mar_read_1fix( char *, struct sfx *, int *);
int mar_save_1fix( char *, struct sfx , int);
int mar_SMG(struct pos p1, struct pos p2, struct tm *t1, struct tm *t2, double *smg);
double mar_A( struct pos, double);
double mar_H( double, double, double, double);
double mar_Ha( double, double, double);
double mar_Ho( double, double, double);
double mar_Rcor( double, double, double);
double mar_Rp( double, double);
double mar_Rt( double, double);
double mar_Z( double, double, double, double);
double mar_adj360(double);
double mar_adj24(double);
double mar_calc_dist( struct tm , struct tm , double);
double mar_delta_Hmin( double, double);
double mar_delta_Hsec( double, double);
double mar_delta_Zm( double, double, double, double);
double mar_dip( double, double);
double mar_dipf( double);
double mar_dipm( double);
double mar_dip_shortf( double, double);
double mar_dip_shortm( double, double);
double mar_dist2hornm( double);
double mar_dist2horsm( double);
double mar_dist_off2( double, double, double);
double mar_dist_sexa( double, double);
double mar_dist_shorth( double, double);
double mar_doff( double, double);
double mar_hms_to_dh( int, int, int);
double mar_in2mb( double);
double mar_mb2in( double);
double mar_mm2mb( double);
double mar_sa_cor( double, double, double);
double mar_sail2wwd( double, double);
double mar_sail_dw( double, double);
#endif
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=
=-= TO UNSUBSCRIBE, send this message to majordomo@XXX.XXX: =-=
=-= navigation =-=
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=






