--- YodaProfiler/inc/sgp4.h 2006/10/20 11:39:34 1.1 +++ YodaProfiler/inc/sgp4.h 2007/02/06 13:01:03 1.4 @@ -3,12 +3,13 @@ // #ifndef sgp4_h #define sgp4_h -#pragma once + +#if !defined(__CINT__) || defined(__MAKECINT__) //#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers #include //#include - +#include #include #include #include @@ -378,4 +379,242 @@ cJulian m_date; VecUnits m_VecUnits; }; +// +// cNoradBase.h +// +// This class provides a base class for the NORAD SGP4/SDP4 +// orbit models. +// +// Copyright (c) 2003 Michael F. Henry +// +#pragma once + +////////////////////////////////////////////////////////////////////////////// + +class cEci; +class cOrbit; + +////////////////////////////////////////////////////////////////////////////// + +class cNoradBase +{ +public: + cNoradBase(const cOrbit&); + virtual ~cNoradBase() {}; + + virtual bool getPosition(double tsince, cEci &eci) = 0; + +protected: + cNoradBase& operator=(const cNoradBase&); + + void Initialize(); + bool FinalPosition(double incl, double omega, double e, + double a, double xl, double xnode, + double xn, double tsince, cEci &eci); + + const cOrbit &m_Orbit; + + // Orbital parameter variables which need only be calculated one + // time for a given orbit (ECI position time-independent). + double m_satInc; // inclination + double m_satEcc; // eccentricity + + double m_cosio; double m_theta2; double m_x3thm1; double m_eosq; + double m_betao2; double m_betao; double m_aodp; double m_xnodp; + double m_s4; double m_qoms24; double m_perigee; double m_tsi; + double m_eta; double m_etasq; double m_eeta; double m_coef; + double m_coef1; double m_c1; double m_c2; double m_c3; + double m_c4; double m_sinio; double m_a3ovk2; double m_x1mth2; + double m_xmdot; double m_omgdot; double m_xhdot1; double m_xnodot; + double m_xnodcf; double m_t2cof; double m_xlcof; double m_aycof; + double m_x7thm1; +}; +// +// cOrbit.h +// +// This is the header file for the class cOrbit. This class accepts a +// single satellite's NORAD two-line element set and provides information +// regarding the satellite's orbit such as period, axis length, +// ECI coordinates/velocity, etc., using the SGP4/SDP4 orbital models. +// +// Copyright (c) 2002-2003 Michael F. Henry +// +#pragma once + +#include "math.h" + +using namespace std; +////////////////////////////////////////////////////////////////////////////// + +class cVector; +class cGeoCoord; +class cEci; + +////////////////////////////////////////////////////////////////////////////// +class cOrbit +{ +public: + cOrbit(const cTle &tle); + virtual ~cOrbit(); + + // Return satellite ECI data at given minutes since element's epoch. + bool getPosition(double tsince, cEci *pEci) const; + + double Inclination() const { return radGet(cTle::FLD_I); } + double Eccentricity() const { return m_tle.getField(cTle::FLD_E); } + double RAAN() const { return radGet(cTle::FLD_RAAN); } + double ArgPerigee() const { return radGet(cTle::FLD_ARGPER); } + double BStar() const { return m_tle.getField(cTle::FLD_BSTAR) / AE;} + double Drag() const { return m_tle.getField(cTle::FLD_MMOTIONDT); } + double mnMotion() const { return m_tle.getField(cTle::FLD_MMOTION); } + double mnAnomaly() const { return radGet(cTle::FLD_M); } + double mnAnomaly(cJulian t) const; // mean anomaly (in radians) at time t + + cJulian Epoch() const { return m_jdEpoch; } + + double TPlusEpoch(const cJulian &t) const; // time span [t - epoch] in secs + + string SatName(bool fAppendId = false) const; + + // "Recovered" from the input elements + double SemiMajor() const { return m_aeAxisSemiMajorRec; } + double SemiMinor() const { return m_aeAxisSemiMinorRec; } + double mnMotionRec() const { return m_mnMotionRec; } // mn motion, rads/min + double Major() const { return 2.0 * SemiMajor(); } // major axis in AE + double Minor() const { return 2.0 * SemiMinor(); } // minor axis in AE + double Perigee() const { return m_kmPerigeeRec; } // perigee in km + double Apogee() const { return m_kmApogeeRec; } // apogee in km + double Period() const; // period in seconds + +protected: + double radGet(cTle::eField fld) const + { return m_tle.getField(fld, cTle::U_RAD); } + + double degGet(cTle::eField fld) const + { return m_tle.getField(fld, cTle::U_DEG); } + +private: + cTle m_tle; + cJulian m_jdEpoch; + cNoradBase *m_pNoradModel; + + // Caching variables; note units are not necessarily the same as tle units + mutable double m_secPeriod; + + // Caching variables recovered from the input TLE elements + double m_aeAxisSemiMinorRec; // semi-minor axis, in AE units + double m_aeAxisSemiMajorRec; // semi-major axis, in AE units + double m_mnMotionRec; // radians per minute + double m_kmPerigeeRec; // perigee, in km + double m_kmApogeeRec; // apogee, in km +}; + +// +// cNoradSGP4.h +// +// This class implements the NORAD Simple General Perturbation 4 orbit +// model. This model provides the ECI coordiantes/velocity of satellites +// with orbit periods less than 225 minutes. +// +// Copyright (c) 2003 Michael F. Henry +// +#pragma once + +class cOrbit; + +////////////////////////////////////////////////////////////////////////////// +class cNoradSGP4 : public cNoradBase +{ +public: + cNoradSGP4(const cOrbit &orbit); + virtual ~cNoradSGP4() {}; + + virtual bool getPosition(double tsince, cEci &eci); + +protected: + double m_c5; + double m_omgcof; + double m_xmcof; + double m_delmo; + double m_sinmo; +}; + +// +// cNoradSDP4.h +// +// This class implements the NORAD Simple Deep Perturbation 4 orbit +// model. This model provides the ECI coordinates/velocity of satellites +// with periods >= 225 minutes. +// +// Copyright (c) 2003 Michael F. Henry +// +#pragma once + +class cOrbit; + +////////////////////////////////////////////////////////////////////////////// +class cNoradSDP4 : public cNoradBase +{ +public: + cNoradSDP4(const cOrbit &orbit); + virtual ~cNoradSDP4() {}; + + virtual bool getPosition(double tsince, cEci &eci); + +protected: + bool DeepInit(double *eosq, double *sinio, double *cosio, double *m_betao, + double *m_aodp, double *m_theta2, double *m_sing, double *m_cosg, + double *m_betao2,double *xmdot, double *omgdot, double *xnodott); + + bool DeepSecular(double *xmdf, double *omgadf,double *xnode, double *emm, + double *xincc, double *xnn, double *tsince); + bool DeepCalcDotTerms (double *pxndot, double *pxnddt, double *pxldot); + void DeepCalcIntegrator(double *pxndot, double *pxnddt, double *pxldot, + const double &delt); + bool DeepPeriodics(double *e, double *xincc, double *omgadf, + double *xnode, double *xmam); + double m_sing; + double m_cosg; + + // Deep Initialization + double eqsq; double siniq; double cosiq; double rteqsq; double ao; + double cosq2; double sinomo; double cosomo; double bsq; double xlldot; + double omgdt; double xnodot; + + // Deep Secular, Periodic + double xll; double omgasm; double xnodes; double _em; + double xinc; double xn; double t; + + // Variables shared by "Deep" routines + double dp_e3; double dp_ee2; double dp_savtsn; double dp_se2; + double dp_se3; double dp_sgh2; double dp_sgh3; double dp_sgh4; + double dp_sghs; double dp_sh2; double dp_sh3; double dp_si2; + double dp_si3; double dp_sl2; double dp_sl3; double dp_sl4; + double dp_xgh2; double dp_xgh3; double dp_xgh4; double dp_xh2; + double dp_xh3; double dp_xi2; double dp_xi3; double dp_xl2; + double dp_xl3; double dp_xl4; double dp_xqncl; double dp_zmol; + double dp_zmos; + + double dp_atime; double dp_d2201; double dp_d2211; double dp_d3210; + double dp_d3222; double dp_d4410; double dp_d4422; double dp_d5220; + double dp_d5232; double dp_d5421; double dp_d5433; double dp_del1; + double dp_del2; double dp_del3; double dp_fasx2; double dp_fasx4; + double dp_fasx6; double dp_omegaq; double dp_sse; double dp_ssg; + double dp_ssh; double dp_ssi; double dp_ssl; double dp_step2; + double dp_stepn; double dp_stepp; double dp_thgr; double dp_xfact; + double dp_xlamo; double dp_xli; double dp_xni; + + bool dp_iresfl; + bool dp_isynfl; + + // DeepInit vars that change with epoch + double dpi_c; double dpi_ctem; double dpi_day; double dpi_gam; + double dpi_stem; double dpi_xnodce; double dpi_zcosgl; double dpi_zcoshl; + double dpi_zcosil; double dpi_zsingl; double dpi_zsinhl; double dpi_zsinil; + double dpi_zx; double dpi_zy; + +}; + #endif +#endif +