Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages | Examples

Keplerian.h

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////////////////////////
00002 /*! \file Keplerian.h
00003 *  \brief Implementation of the Keplerian Orbit State Representation Class.
00004 *  \author $Author: jayhawk_hokie $
00005 *  \version $Revision: 1.6 $
00006 *  \date    $Date: 2007/05/21 17:25:29 $
00007 *//////////////////////////////////////////////////////////////////////////////////////////////////
00008 /* 
00009 * \todo include conversion functions
00010 */
00011 //////////////////////////////////////////////////////////////////////////////////////////////////
00012 
00013 #ifndef __SSF_KEPLERIAN_H__
00014 #define __SSF_KEPLERIAN_H__
00015 #include <matrix/Matrix.h>
00016 #include <orbit/orbitstaterep/OrbitStateRepresentation.h>
00017 #include <string>
00018 #include <stdlib.h>
00019 #include <sstream>
00020 using namespace std;
00021 
00022 // Defined Values
00023 #define MU 3.986012e5   // Gravitational Parameter for Earth (km^3/s^2)
00024 #define Re 6378.145     // Radius of the Earth (km)
00025 #define J2 0.00108263  // gravitational perturbation constant
00026 #define EARTH_ANGULAR_RATE 7.292115856e-5       // Earth's angular rate (rad/s)
00027 
00028 #ifndef PI
00029 #include <math.h>
00030 #define PI M_PI
00031 #endif
00032 
00033 namespace O_SESSAME {
00034 
00035 /*! \ingroup OrbitStateRepresentation @{ */
00036 #define NUM_KEPLERIAN_ELEMENTS 6 /*!< number of elements in a Keplerian state representation */
00037 const int SEMIMAJOR_AXIS        = VectorIndexBase + 0; /*!< position of the Semimajor axis, \f$a\f$, in the element vector */
00038 const int ECCENTRICITY          = VectorIndexBase + 1; /*!< position of the eccentricity, \f$e\f$, in the element vector */
00039 const int INCLINATION           = VectorIndexBase + 2; /*!< position of the inclination, \f$i\f$, in the element vector */
00040 const int LONG_ASC_NODE         = VectorIndexBase + 3; /*!< position of the longitude of the ascending node, \f$\Omega\f$, in the element vector */
00041 const int ARG_PERIGEE           = VectorIndexBase + 4; /*!< position of the argument of perigee, \f$\omega\f$, in the element vector */
00042 const int TRUE_ANOMALY          = VectorIndexBase + 5; /*!< position of the true anomaly, \f$\nu\f$, in the element vector */
00043 
00044 #define NUM_KEPLERIAN_PARAMETERS 7 /*!< number of parameters */
00045 const int ECCENTRIC_ANOMALY     = VectorIndexBase + 0; /*!< position of the Eccentric Anomaly, \f$E\f$, in the element vector */
00046 const int ECCENTRIC_ANOMALY_0   = VectorIndexBase + 1; /*!< position of the Initial Eccentric Anomaly, \f$E_o\f$, in the element vector */
00047 const int MEAN_ANOMALY          = VectorIndexBase + 2; /*!< position of the Mean Anomaly, \f$M\f$, in the element vector */
00048 const int MEAN_ANOMALY_0        = VectorIndexBase + 3; /*!< position of the Initial Mean Anomaly, \f$M\f$, in the element vector */
00049 const int ARG_LATTITUDE         = VectorIndexBase + 4; /*!< position of the Argument of Latitude, \f$\theta\f$, in the element vector */
00050 const int LONG_PERIGEE          = VectorIndexBase + 5; /*!< position of the Longitude of Perigee, \f$\Pi\f$, in the element vector */
00051 const int TRUE_LONGITUDE        = VectorIndexBase + 6; /*!< position of the True Longitude, \f$\ell\f$, in the element vector */
00052 
00053 /*! @} */
00054 
00055 typedef struct tleStruct {
00056         string  satName;                                /*!< Satellite Name, from Line Zero */
00057         int             satNumber;                              /*!< Satellite Number, from Line One */
00058         char    satClassification;              /*!< Almost always "U"nclassified (L1) */
00059         int             launchYear;                             /*!< Launched in... (L1) */
00060         int             launchNumber;                   /*!< Which launch of that year... (L1) */
00061         string  launchPiece;                    /*!< Which piece of that launch... (L1) */
00062         int             epochYear;                              /*!< Epoch year for this TLE (L1) */
00063         double  epochDay;                               /*!< Epoch day and time for this TLE (L1) */
00064         double  meanmotion1stDeriv;             /*!< \f$\dot{meanMotion}\f$ (L1) */
00065         double  meanmotion2ndDeriv;             /*!< \f$\ddot{meanMotion}\f$ (L1) */
00066         double  bstarDrag;                              /*!< B* drag term (L1) */
00067         int             ephemerisType;                  /*!< The type of ephemeris data (L1) */
00068         int             elementNumber;                  /*!< The TLE # (L1) */
00069         int             checksumLine1;                  /*!< Checksum for L1 */
00070         double  meanAnomaly;                    /*!< The TLE reports Mean Anomaly (L2) */
00071         double  eccentricAnomaly;               /*!< We calculate Eccentric Anomaly */
00072         double  meanMotion;                             /*!< We calculate Mean Motion */
00073         int             revolutionNumber;               /*!< How many orbits at epoch? (L2) */
00074         int             checksumLine2;                  /*!< Checksum for L2 */
00075 };
00076 
00077                 
00078                 
00079 /*! \brief Keplerian orbital element representation of the orbital position.
00080  * \ingroup OrbitStateRepresentation 
00081  *
00082  * The Keplerian class stores the orbital elements of an orbital position.
00083  *
00084  *      \par Example:
00085  *      
00086  */ 
00087 class Keplerian : public OrbitStateRepresentation
00088 {
00089 public:
00090     
00091         virtual ~Keplerian();
00092 
00093         virtual Keplerian* NewPointer();
00094 
00095         virtual Keplerian* Clone();
00096 
00097                 Keplerian();
00098     
00099         Keplerian(const Vector& _Elements);
00100 
00101         Keplerian KeplerianCopy( );
00102 
00103         void SetKeplerianRepresentationMeanAnomaly( const Vector& _OrbitalElements );
00104 
00105         void SetKeplerianRepresentationEccentricAnomaly( const Vector& _OrbitalElements );
00106 
00107         void SetKeplerianRepresentationTrueAnomaly( const Vector& _OrbitalElements );           
00108 
00109         void SetPositionVelocity(const Vector& _Position, const Vector& _Velocity);
00110 
00111         void SetPositionVelocity(const Vector& _PositionVelocity);
00112 
00113         void SetPositionVelocity(const Vector& _Position, const Vector& _Velocity, const OrbitFrame& _OrbFrame);
00114     
00115         void SetPositionVelocity(const Vector& _PositionVelocity, const OrbitFrame& _OrbFrame);
00116 
00117         Vector GetPositionVelocity() const;
00118 
00119         Vector GetPositionVelocity(const OrbitFrame& _TargetOrbFrame) const;
00120 
00121         void GetPositionVelocity(Vector& _Position, Vector& _Velocity) const;
00122   
00123         void GetPositionVelocity(Vector& _Position, Vector& _Velocity, const OrbitFrame& _TargetOrbFrame) const;
00124 
00125         Vector GetPositionVelocityPQW() const;
00126 
00127         double GetEccentricAnomalyFromMeanAnomaly(const double& _MeanAnomaly);
00128         
00129         void GetTrueAnomalyFromEccentricAnomaly(const double& _EccentricAnomaly);
00130         
00131         tleStruct ReadTwoLineElementSet(const string& _TwoLineElementSet);
00132 
00133         double GetEccentricAnomalyFromTrueAnomaly();
00134 
00135         double GetMeanAnomalyFromEccentricAnomaly();
00136 
00137         double GetArgLattitude();
00138 
00139         double GetLongPerigee();
00140 
00141         double GetTrueLongitude();
00142 
00143 
00144 /* ********* KEPLERIAN SPECIFIC FUNCTIONS ********* */    
00145 
00146 /*! @defgroup ElementAccessFunctions Element Access functions 
00147  * \ingroup OrbitStateRepresentation
00148  * \brief Functions to access the specific elements of the Keplerian Orbital Elements.
00149  * @{ 
00150  */
00151 /*! \brief Compute and return the Semiparameter \f$p\f$ of the orbit position.
00152  * @return the semiparameter: \f$p = a * (1-e^{2})\f$. (km)
00153  */
00154     inline double GetSemiParameter() const {return GetSemimajorAxis() * (1 - pow(GetEccentricity(),2));};
00155 
00156 /*! \brief Return the Semimajor Axis \f$a\f$ of the orbit position. (km) */
00157     inline double GetSemimajorAxis() const {return m_OrbitalElements(SEMIMAJOR_AXIS);};
00158 
00159 /*! \brief Return the Eccentricity \f$e\f$ of the orbit position. (-) */
00160     inline double GetEccentricity() const {return m_OrbitalElements(ECCENTRICITY);};
00161 
00162 /*! \brief Return the Inclination \f$i\f$ of the orbit position. (-) */
00163     inline double GetInclination() const {return m_OrbitalElements(INCLINATION);};
00164 
00165 /*! \brief Return the Longitude of the Ascending Node \f$\Omega\f$ of the orbit position. (rad) */
00166     inline double GetLongAscNode() const {return m_OrbitalElements(LONG_ASC_NODE);};
00167 
00168 /*! \brief Return the Argument of Perigee \f$\omega\f$ of the orbit position. (rad) */
00169     inline double GetArgPerigee() const  {return m_OrbitalElements(ARG_PERIGEE);};
00170 
00171 /*! \brief Return the True Anomaly \f$\nu\f$ of the orbit position. (rad) */
00172         inline double GetTrueAnomaly() const {return m_OrbitalElements( TRUE_ANOMALY );};
00173 
00174 /*! \brief Return the Mean orbital motion \f$n\f$ of the orbit position. (rad/s) */
00175         inline double GetMeanMotion() const  {return sqrt(MU/pow(GetSemimajorAxis(),3));};
00176 
00177 /*! \brief Return the Eccentric Anomaly \f$E\f$ of the orbit position. (rad) */
00178         inline double GetEccentricAnomaly() const {return m_OrbitalParameters( ECCENTRIC_ANOMALY );};
00179 
00180 /*! \brief Return the Mean Anomaly \f$M\f$ of the orbit position. (-) */
00181         inline double GetMeanAnomaly() const {return m_OrbitalParameters( MEAN_ANOMALY );};
00182 /*! @} */
00183     
00184 /* ********* ********* ******** ********* ********* */    
00185         
00186         
00187         
00188         
00189         
00190 /* ********* DEPRECATED FUNCTIONS ********* */    
00191 
00192     virtual void SetState(const Vector& _Elements);
00193 
00194     virtual Vector GetState() const;
00195         
00196     virtual void GetState(Vector& _Elements) const;
00197         
00198 /* ********* ********** ********* ********* */          
00199 
00200         
00201 
00202 private:
00203         /*! 6x1 vector of Keplerian orbital elements [a, e, i, \f$\Omega\f$, \f$\omega\f$, \f$\nu\f$ ] (km, -, rad, rad, rad, rad) */
00204         Vector m_OrbitalElements;
00205 
00206         /*! nx1 vector of Keplerian orbital elements [E, E_o, M, Mo  ] (rad, rad, -, - ) */
00207         Vector m_OrbitalParameters;
00208 
00209         /*! All of the non-orbital element data that's inside of a TLE. */
00210         tleStruct m_tleData;
00211 };
00212 } // close namespace O_SESSAME
00213 
00214 #endif
00215 
00216 // Do not change the comments below - they will be added automatically by CVS
00217 /*****************************************************************************
00218 *       $Log: Keplerian.h,v $
00219 *       Revision 1.6  2007/05/21 17:25:29  jayhawk_hokie
00220 *       *** empty log message ***
00221 *       
00222 *       Revision 1.5  2006/08/25 15:49:28  jayhawk_hokie
00223 *       Added set Keplerian representation for True Anomaly, Eccentric Anomaly, and Mean Anomaly.
00224 *       
00225 *       Revision 1.4  2006/08/23 21:45:11  jayhawk_hokie
00226 *       Updated ECI to Keplerian and Keplerian to ECI. Also tested functions for special eliptical orbits.
00227 *       
00228 *       Revision 1.3  2005/06/29 20:26:57  jayhawk_hokie
00229 *       Fixed COE equations due to being incomplete.
00230 *       
00231 *       Revision 1.2  2005/06/10 12:53:28  jayhawk_hokie
00232 *       Changed header file format to make it easier to link to the spacecraft code by only having to specify dsacss/dep/spacecraft/src (ex. "file.h" changed to <dir/file.h> where dir is a folder in src).
00233 *       
00234 *       Revision 1.1.1.1  2005/04/26 17:41:00  cakinli
00235 *       Adding OpenSESSAME to DSACSS distrib to capture fixed version.
00236 *       
00237 *       Revision 1.12  2003/08/24 20:59:13  nilspace
00238 *       Updated.
00239 *       
00240 *       Revision 1.11  2003/05/23 19:28:14  simpliciter
00241 *       Moved comments to implementation file, basic housekeeping.
00242 *       
00243 *       Revision 1.10  2003/05/20 20:49:42  simpliciter
00244 *       Added new functions for parsing TLEs:
00245 *         - GetEccentricAnomalyFromMeanAnomaly,
00246 *         - GetTrueAnomalyFromEccentricAnomaly,
00247 *         - ReadTwoLineElementSet.
00248 *       
00249 *       Revision 1.9  2003/05/13 18:47:56  nilspace
00250 *       Fixed comments for better formatting.
00251 *       
00252 *       Revision 1.8  2003/05/05 20:46:38  nilspace
00253 *       Added inertial Get/SetPositionVelocity to conform to new OrbitStateRepresentation abstract class.
00254 *       
00255 *       Revision 1.7  2003/05/02 16:16:46  nilspace
00256 *       Documented the API.
00257 *       
00258 *       Revision 1.6  2003/04/29 18:48:30  nilspace
00259 *       Added NewPointer and Clone functions to help in getting the correct memory allocation.
00260 *       
00261 *       Revision 1.5  2003/04/24 21:14:23  nilspace
00262 *       const'd all Get() functions.
00263 *       
00264 *       Revision 1.4  2003/04/24 20:10:47  nilspace
00265 *       const'd all Get() functions.
00266 *       
00267 *       Revision 1.3  2003/04/23 18:52:29  nilspace
00268 *       Updated to call correct OrbitFrame::GetRotation calls.
00269 *       Added temporary PI and MU values.
00270 *       Added K_Vector Values.
00271 *       
00272 *       Revision 1.2  2003/04/22 18:06:08  nilspace
00273 *       Added math for Matthew Berry.
00274 *       
00275 *       Revision 1.1  2003/04/08 22:47:35  nilspace
00276 *       Initial Submission.
00277 *
00278 ******************************************************************************/

Generated on Wed Sep 5 12:54:21 2007 for DSACSS Operational Code by  doxygen 1.3.9.1