ocssw  1.0
/disk01/web/ocssw/build/inc/osmiinc/orbit.h (r8090/r2592)
Go to the documentation of this file.
00001 /*
00002  *----------------------------------------------------------------------
00003  *  @(#) orbit.h    1.03    5 May 95    <shc>
00004  *  Copyright (c) 1993, CSIRO Division of Oceanography.
00005  *----------------------------------------------------------------------
00006  *
00007  *  Various structures, constants and macros used in the orbit
00008  *  package routines.
00009  *
00010  * History:
00011  *  1.0 18 Oct 93   <shc>
00012  *      Initial version.
00013  *
00014  *  1.01    12 Dec 94   <shc>
00015  *      Added errstr stuff for integration with Python
00016  *
00017  *  1.02    27 Jan 95   <shc>
00018  *      Added SGP4 stuff.
00019  *
00020  *  1.03    5 May 95    <shc>
00021  *      Added TLE_VALUES struct and prototypes for tle.c
00022  *
00023  *  1.04    24 Jan 96   <shc>
00024  *      Modified SGP4 struct so secular rates are more accessible,
00025  *      changed rates from rad/min to rad/sec for conformance with
00026  *      package standards.
00027  *
00028  *----------------------------------------------------------------------
00029  */
00030 
00031 #ifndef __ORBIT__
00032 #define __ORBIT__
00033 
00034 #include <stdint.h>
00035 #include <math.h>
00036 #include <time.h>
00037 #ifndef NULL
00038 #include <stdio.h>
00039 #endif
00040 
00041 #include "earth.h"
00042 #include "lunsol.h"
00043 
00044 #define DPI     3.14159265358979323846
00045 #define D2PI        6.28318530717958647692
00046 #define D3PI        9.42477796076937971538
00047 
00048 #define FP_ERRVAL   -1.0e-20    /* Error value from f.p. routines */
00049 
00050 /* Degrees to radians */
00051 #define DTOR(X) ((X) * DPI/180.0)
00052 
00053 /* Radians to degrees */
00054 #define RTOD(X) ((X) * 180.0/DPI)
00055 
00056 /* Fold an angle to the range [0..2 Pi] radians */
00057 #define AN2PI(X) fmod(fmod((X), D2PI) + D2PI, D2PI)
00058 
00059 /* Fold an angle to the range [-Pi .. Pi] radians */
00060 #define ANPI(X) (fmod(fmod((X), D2PI) + D3PI, D2PI) - DPI)
00061 
00062 /* Fold an angle to the range [0..360] degrees */
00063 #define AN360(X) fmod(fmod((X), 360.0) + 360.0, 360.0)
00064 
00065 /* Arc-seconds to radians */
00066 #define ASTOR(X) ((X) * DPI/(180.0 * 3600.0))
00067 
00068 /* Arc-seconds per century to radians per day */
00069 #define ASPCTORPD(X) ((X) * DPI/(180.0 * 3600.0 * 36525.0))
00070 
00071 /* Epoch(s) in my time scheme (JD % 2400000) */
00072 #define J2000   (51545.0)
00073 
00074 
00075 /*
00076  * Struct for defining the attitude (orientation) of a satellite
00077  * or satellite scanner vector.  Angles are in radians.
00078  */
00079 
00080 struct ATTITUDE  {
00081     double pitch;
00082     double roll;
00083     double yaw;
00084 };
00085 
00086 
00087 /*
00088  * Structure used by the Brouwer routines.  The first 6 structure
00089  * members, which are set by the user, are Brouwer mean elements.
00090  * The remaining elements are initialised by blinit() for subsequent use by
00091  * blosc().  Of these, only "darp", "dran" and "dman", which are the time
00092  * derivatives of "arp", "ran" and "man", are independently useful.
00093  */
00094 
00095 struct BROUWER {
00096     double  sma,    /* Semi-major axis (metres) */
00097         ecc,    /* Eccentricity */
00098         inc,    /* Inclination (radians) */
00099         arp,    /* Argument of perigee (radians) */
00100         ran,    /* Right ascension of the ascending node (radians) */
00101         man;    /* Mean anomaly (radians) */
00102 
00103     double  darp,   /* Secular rate of "arp" (radians/sec) */
00104         dran,   /* Secular rate of "ran" (radians/sec) */
00105         dman;   /* Secular rate of "man" (radians/sec) */
00106 
00107     /* You really don't want to know about these. */
00108     double  a20, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10,
00109         b11, b12, b13, b14, b15, edp2, eta, eta2, eta3,
00110         eta6, gm2, gmp2, sidp, sidph, cidph, theta, theta2;
00111 };
00112 
00113 
00114 /*
00115  * Structure for specifying geodetic coordinates (e.g. an observer's
00116  * location).
00117  */
00118 
00119 struct GEODETIC {
00120     double lat; /* Geodetic latitude (radians) */
00121     double lon; /* Longitude (radians) */
00122     double height;  /* Height above the geoid (metres) */
00123 };
00124 
00125 
00126 /*
00127  * Structure for transfer of Keplerian orbital elements.
00128  */
00129 
00130 struct KEPLER {
00131     double  sma,    /* Semi-major axis (metres) */
00132         ecc,    /* Eccentricity */
00133         inc,    /* Inclination (radians) */
00134         arp,    /* Argument of perigee (radians) */
00135         ran,    /* Right ascension of the ascending node (radians) */
00136         man;    /* Mean anomaly (radians) */
00137 };
00138 
00139 
00140 /*
00141  * Structure for specifying nutation angles (radians).
00142  */
00143 struct NUTATION {
00144     double mood;        /* Mean obliquity of date */
00145     double nutlon;      /* Nutation in longitude */
00146     double nutobl;      /* Nutation in obliquity */
00147 };
00148  
00149 
00150 /*
00151  * Structure for specifying precession angles (radians).
00152  */
00153 struct PRECESSION {
00154         double zeta;
00155         double z;
00156         double theta;
00157 };
00158  
00159 
00160 /*
00161  * Structure for specifying right ascension and declination (radians).
00162  */
00163 struct RADEC {
00164         double ra;
00165         double dec;
00166 };
00167 
00168 
00169 /*
00170  * Structure used by the SGP4 routines.  The first 7 members are the
00171  * orbital elements at epoch + the drag coefficient.  The remaining
00172  * members are initialised by sgp4_init() for subsequent use by
00173  * sgp4_pred().
00174  */
00175 
00176 struct SGP4 {
00177     double  xno,        /* Mean motion (radians/sec) */
00178         eo,     /* Eccentricity */
00179         xincl,      /* Inclination (radians) */
00180         omegao,     /* Argument of perigee (radians) */
00181         xnodeo,     /* Longitude of ascending node (radians) */
00182         xmo,        /* Mean anomaly (radians) */
00183         bstar;      /* Drag coefficient */
00184 
00185     double  omgdot,     /* Secular rate of omega (radians/sec) */
00186         xnodot,     /* Secular rate of xnode (radians/sec) */
00187         xmdot;      /* Secular rate of xm    (radians/sec) */
00188 
00189     /* You probably don't want to know about these. */
00190     int isimp;
00191     double  aodp, aycof, c1, c1sq, c4, c5, cosio, d2, d3, d4, delmo,
00192         eta, omgcof, sinio, sinmo, t2cof, t3cof, t4cof, t5cof,
00193         x1mth2, x3thm1, x7thm1, xhdot1, xlcof, xmcof, xnodcf, xnodp;
00194 };
00195 
00196 
00197 /*
00198  * Two-line-element values.  The function tle_parse() can be used to
00199  * read the values from an element set into this structure.
00200  */
00201 
00202 struct TLE_VALUES {
00203     int satellite_number;   /* NORAD satellite number */
00204     char    designator[9];      /* International designator */
00205     int year;           /* Last two digits of year */
00206     double  dayofyr;        /* Day of year (1 origin) */
00207     double  mmdt;           /* First derivative of mean motion */
00208     double  mmdt2;          /* Second derivative of mean motion */
00209     double  bstar;          /* B* drag term */
00210     int ephem_type;
00211     int element_number;
00212     double  incl;           /* Inclination (deg) */
00213     double  raan;           /* Right ascension of asc node (deg) */
00214     double  ecc;            /* Eccentricity */
00215     double  argp;           /* Argument of perigee (deg) */
00216     double  manom;          /* Mean anomaly (deg) */
00217     double  mmotion;        /* Mean motion (revs/day) */
00218     int revolution;     /* Epoch orbit number */
00219 };
00220 
00221 
00222 /*
00223  * Structure for specifying topocentric coordinates.
00224  */
00225 
00226 struct TOPOCENTRIC {
00227     double az;  /* Azimuth (radians) */
00228     double el;  /* Elevation (radians) */
00229     double range;   /* Range (metres) */
00230 };
00231 
00232 
00233 
00234 /*
00235  * Function prototypes.
00236  */
00237 
00238 /* brouwer.c */
00239 int blinit(struct BROUWER *bp, char **errstr);
00240 int blosc(struct BROUWER *bp, double delt, struct KEPLER *kp,
00241           char **errstr);
00242 
00243 /* ctogd.c */
00244 void    ctogd(double r[3], double gha, struct GEODETIC *geod,
00245           double dgeod[3][3]);
00246 
00247 /* ctok.c */
00248 int ctok(double r[6], struct KEPLER *keplr, char **errmsg);
00249 
00250 /* ctotc.c */
00251 void    ctotc(double r[3], struct GEODETIC *obs, double gha,
00252           struct TOPOCENTRIC *top, double daer[3][3]);
00253 
00254 /* eanom.c */
00255 double  eanom(double manom, double ecc, char **errstr);
00256 
00257 /* efitoeci.c */
00258 int efitoeci(double r[6], double gha, double rp[6]);
00259 
00260 /* efrtoeci.c */
00261 int efrtoeci(double r[6], double gha, double rp[6]);
00262 
00263 /* ecitoefi.c */
00264 int ecitoefi(double r[6], double gha, double rp[6]);
00265 
00266 /* ecitoefr.c */
00267 int ecitoefr(double r[6], double gha, double rp[6]);
00268 
00269 /* gmha.c */
00270 double  gmha(double tjd);
00271 double  gmhadot(double tjd);
00272 
00273 /* julian.c */
00274 void    caldat(int32_t julian, int *year, int *month, int *day);
00275 double  itojul(int32_t date, int32_t time);
00276 int32_t julday(int year, int month, int day);
00277 void    jultoi(double tjd, int32_t *date, int32_t *time);
00278 void    jultotm(double tjd, struct tm *time);
00279 double  tmtojul(struct tm *time);
00280 
00281 /* ktoc.c */
00282 int ktoc(struct KEPLER *kp, double r[6], char **errstr);
00283 
00284 /* ktosgp4.c */
00285 int ktosgp4(struct KEPLER *kepler, struct SGP4 *sgp4, char **errmsg);
00286 
00287 /* locate.c */
00288 int locate(double r[6], struct ATTITUDE *sat,
00289            struct ATTITUDE *scanner, double loc[3]);
00290 
00291 /* moonpos.c */
00292 void    moonpos(double tjd, double r[3]);
00293 
00294 /* nutate.c */
00295 void    nut_angles(double tjd, struct NUTATION *angles, struct NUTATION *rates);
00296 void    nut_matrix(double tjd, double a[3][3]);
00297 
00298 /* obliq.c */
00299 void    obliq(double tjd, double *mood, double *dmood);
00300 
00301 /* precess.c */
00302 void    pre_angles(double tjd0, double tjd1, struct PRECESSION *angles);
00303 void    pre_reduce(double tjd0, struct RADEC *rad0,
00304            double tjd1, struct RADEC *rad1);
00305 
00306 /* rdtotc.c */
00307 void    rdtotc(struct RADEC *rad, struct GEODETIC *obs,
00308            double gmha, struct TOPOCENTRIC *top);
00309 
00310 /* refract.c */
00311 double  refract(double alt, double temp, double pressure);
00312 double  unrefract(double alt, double temp, double pressure);
00313 
00314 /* sgp4.c */
00315 int sgp4_init(struct SGP4 *sgp4, char **errstr);
00316 int sgp4_pred(struct SGP4 *sgp4, double tsince, double rect[6],
00317           char **errstr);
00318 double  sgp4_orbit(struct SGP4 *sgp4, struct TLE_VALUES *tv, double tsince);
00319 int sgp4_tle(double *epoch, struct SGP4 *sgp4, char *line1,
00320          char *line2, char **errstr);
00321 
00322 /* sunpos.c */
00323 int sunpos(double tjd, double r[3], char **errstr);
00324 
00325 /* tconv.c */
00326 double  tconv(double tjd, char conv[], char **errstr);
00327 int tcset(double x, char what[], char **errstr);
00328 
00329 /* tle.c */
00330 int tle_parse(char *line1, char *line2, struct TLE_VALUES *tv,
00331           char **errstr);
00332 
00333 #endif /* __ORBIT__ */