File indexing completed on 2024-04-14 03:46:45

0001 #ifndef _sgp4unit_
0002 #define _sgp4unit_
0003 /*     ----------------------------------------------------------------
0004 *
0005 *                                 sgp4unit.h
0006 *
0007 *    this file contains the sgp4 procedures for analytical propagation
0008 *    of a satellite. the code was originally released in the 1980 and 1986
0009 *    spacetrack papers. a detailed discussion of the theory and history
0010 *    may be found in the 2006 aiaa paper by vallado, crawford, hujsak,
0011 *    and kelso.
0012 *
0013 *                            companion code for
0014 *               fundamentals of astrodynamics and applications
0015 *                                    2007
0016 *                              by david vallado
0017 *
0018 *       (w) 719-573-2600, email dvallado@agi.com
0019 *
0020 *    current :
0021 *               3 Nov 08  david vallado
0022 *                           put returns in for error codes
0023 *    changes :
0024 *              29 sep 08  david vallado
0025 *                           fix atime for faster operation in dspace
0026 *                           add operationmode for afspc (a) or improved (i)
0027 *                           performance mode
0028 *              20 apr 07  david vallado
0029 *                           misc fixes for constants
0030 *              11 aug 06  david vallado
0031 *                           chg lyddane choice back to strn3, constants, misc doc
0032 *              15 dec 05  david vallado
0033 *                           misc fixes
0034 *              26 jul 05  david vallado
0035 *                           fixes for paper
0036 *                           note that each fix is preceded by a
0037 *                           comment with "sgp4fix" and an explanation of
0038 *                           what was changed
0039 *              10 aug 04  david vallado
0040 *                           2nd printing baseline working
0041 *              14 may 01  david vallado
0042 *                           2nd edition baseline
0043 *                     80  norad
0044 *                           original baseline
0045 *       ----------------------------------------------------------------      */
0046 
0047 #include <cmath>
0048 #include <cstdio>
0049 #define SGP4Version  "SGP4 Version 2008-11-03"
0050 
0051 #ifndef M_PI
0052 #define M_PI 3.14159265358979323846
0053 #endif
0054 
0055 // -------------------------- structure declarations ----------------------------
0056 typedef enum
0057 {
0058   wgs72old,
0059   wgs72,
0060   wgs84
0061 } gravconsttype;
0062 
0063 typedef struct elsetrec
0064 {
0065   long int  satnum;
0066   int       epochyr, epochtynumrev;
0067   int       error;
0068   char      operationmode;
0069   char      init, method;
0070 
0071   /* Near Earth */
0072   int    isimp;
0073   double aycof  , con41  , cc1    , cc4      , cc5    , d2      , d3   , d4    ,
0074          delmo  , eta    , argpdot, omgcof   , sinmao , t       , t2cof, t3cof ,
0075          t4cof  , t5cof  , x1mth2 , x7thm1   , mdot   , nodedot, xlcof , xmcof ,
0076          nodecf;
0077 
0078   /* Deep Space */
0079   int    irez;
0080   double d2201  , d2211  , d3210  , d3222    , d4410  , d4422   , d5220 , d5232 ,
0081          d5421  , d5433  , dedt   , del1     , del2   , del3    , didt  , dmdt  ,
0082          dnodt  , domdt  , e3     , ee2      , peo    , pgho    , pho   , pinco ,
0083          plo    , se2    , se3    , sgh2     , sgh3   , sgh4    , sh2   , sh3   ,
0084          si2    , si3    , sl2    , sl3      , sl4    , gsto    , xfact , xgh2  ,
0085          xgh3   , xgh4   , xh2    , xh3      , xi2    , xi3     , xl2   , xl3   ,
0086          xl4    , xlamo  , zmol   , zmos     , atime  , xli     , xni;
0087 
0088   double a      , altp   , alta   , epochdays, jdsatepoch       , nddot , ndot  ,
0089          bstar  , rcse   , inclo  , nodeo    , ecco             , argpo , mo    ,
0090          no;
0091 } elsetrec;
0092 
0093 
0094 // --------------------------- function declarations ----------------------------
0095 bool sgp4init
0096      (
0097        gravconsttype whichconst,  char opsmode,  const int satn,     const double epoch,
0098        const double xbstar,  const double xecco, const double xargpo,
0099        const double xinclo,  const double xmo,   const double xno,
0100        const double xnodeo,  elsetrec& satrec
0101      );
0102 
0103 bool sgp4
0104      (
0105        gravconsttype whichconst, elsetrec& satrec,  double tsince,
0106        double r[3],  double v[3]
0107      );
0108 
0109 double  gstime
0110         (
0111           double jdut1
0112         );
0113 
0114 void getgravconst
0115      (
0116       gravconsttype whichconst,
0117       double& tumin,
0118       double& mu,
0119       double& radiusearthkm,
0120       double& xke,
0121       double& j2,
0122       double& j3,
0123       double& j4,
0124       double& j3oj2
0125      );
0126 
0127 #endif
0128