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

TestKeplerian.cpp

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////////////////////////
00002 /*! \file TestKeplerian.cpp
00003  *  \brief Implementation of the Keplerian orbit state representation.
00004  *  \author $Author: jayhawk_hokie $
00005  *  \version $Revision: 1.2 $
00006  *  \date    $Date: 2006/08/25 15:50:37 $
00007  *//////////////////////////////////////////////////////////////////////////////////////////////////
00008 /* 
00009  *
00010  */
00011 //////////////////////////////////////////////////////////////////////////////////////////////////
00012 
00013 #include "TestKeplerian.h"
00014 #include "MappingMeanOsculatingOrbitElements.h"
00015 
00016 namespace O_SESSAME {
00017 
00018 /*! \brief Default Deconstructor */
00019 TestKeplerian::~TestKeplerian()
00020 {
00021 }
00022 
00023 
00024 /*! \brief Return a pointer to a new instance of a TestKeplerian orbit state representation type.
00025  *
00026  *  This is used to request memory for a new instance of a Keplerian. It is necessary 
00027  *      when attempting to get a pointer from the abstract data type OrbitStateRepresentation 
00028  *      and the actual representation type isn't known.
00029  * @return a pointer to a new allocation of memory for the Keplerian object.
00030  */
00031 TestKeplerian* TestKeplerian::NewPointer()
00032 {
00033     return new TestKeplerian();
00034 }
00035 
00036 
00037 /*! \brief Return a pointer to a copy of the Keplerian orbit state representation instance.
00038  *
00039  *  This is used to request memory for a copy of this instance of Keplerian. It is necessary 
00040  *      when attempting to get a pointer from the abstract data type OrbitStateRepresentation 
00041  *      and the actual representation type isn't known.
00042  * @return a pointer to a copy of the Keplerian object.
00043  */
00044 TestKeplerian* TestKeplerian::Clone()
00045 {
00046     return new TestKeplerian(*this);
00047 }
00048 
00049 
00050 /*! \brief Create a TestKeplerian orbit state representation and test the Keplerian functions.
00051  *
00052  */
00053 TestKeplerian::TestKeplerian() : m_OrbitalElementCheck( NUM_KEPLERIAN_ELEMENTS ), m_PositionVelocityCheck( NUM_KEPLERIAN_ELEMENTS )
00054 {
00055 }
00056 
00057 
00058 /*! \brief A function to check the Keplerian class.
00059  *
00060  */
00061 void TestKeplerian::Check()
00062 {
00063         /* Check the Keplerian Class */
00064         cout << "\nChecking the Keplerian Class... " << endl;
00065 
00066         /* First Check */
00067         cout << "Checking Low Earth Orbit: Keplerian -> ECI, then ECI -> Keplerian. " << endl;
00068 
00069         m_OrbitalElementCheck(1) = 6800 ;
00070         m_OrbitalElementCheck(2) = 0.05 ;
00071         m_OrbitalElementCheck(3) = Deg2Rad( 50.0 ) ;
00072         m_OrbitalElementCheck(4) = Deg2Rad( 60.0 ) ;
00073         m_OrbitalElementCheck(5) = Deg2Rad( 20.0 ) ;
00074         m_OrbitalElementCheck(6) = Deg2Rad( 10.0 ) ;
00075 
00076         /* Check conversion */
00077         Keplerian2ECI2Keplerian( );
00078 
00079 
00080 
00081         /* Second Check */
00082         cout << "\nChecking Low Earth Orbit Circular Orbit: Keplerian -> ECI, then ECI -> Keplerian. " << endl;
00083 
00084         m_OrbitalElementCheck(1) = 6800 ;
00085         m_OrbitalElementCheck(2) = 0.0 ;
00086         m_OrbitalElementCheck(3) = Deg2Rad( 30.0 ) ;
00087         m_OrbitalElementCheck(4) = Deg2Rad( 10.0 ) ;
00088         m_OrbitalElementCheck(5) = Deg2Rad( 0.0 ) ;
00089         m_OrbitalElementCheck(6) = Deg2Rad( 40.0 ) ;
00090 
00091         /* Check conversion */
00092         Keplerian2ECI2Keplerian( );
00093         
00094         /* Third Check */
00095         cout << "\nChecking Low Earth Equatorial Orbit: Keplerian -> ECI, then ECI -> Keplerian. " << endl;
00096 
00097         m_OrbitalElementCheck(1) = 6800 ;
00098         m_OrbitalElementCheck(2) = 0.1 ;
00099         m_OrbitalElementCheck(3) = Deg2Rad( 0.0 ) ;
00100         m_OrbitalElementCheck(4) = Deg2Rad( 0.0 ) ;
00101         m_OrbitalElementCheck(5) = Deg2Rad( 0.0 ) ;
00102         m_OrbitalElementCheck(6) = Deg2Rad( 10.0 ) ;
00103 
00104         /* Check conversion */
00105         Keplerian2ECI2Keplerian( );
00106         
00107         /* Forth Check */
00108         cout << "\nChecking Low Earth Circular Equatorial Orbit: Keplerian -> ECI, then ECI -> Keplerian. " << endl;
00109 
00110         m_OrbitalElementCheck(1) = 6800 ;
00111         m_OrbitalElementCheck(2) = 0.0 ;
00112         m_OrbitalElementCheck(3) = Deg2Rad( 0.0 ) ;
00113         m_OrbitalElementCheck(4) = Deg2Rad( 0.0 ) ;
00114         m_OrbitalElementCheck(5) = Deg2Rad( 0.0 ) ;
00115         m_OrbitalElementCheck(6) = Deg2Rad( 70.0 ) ;
00116 
00117         /* Check conversion */
00118         Keplerian2ECI2Keplerian( );
00119 
00120 
00121         /* Check OsculatingOrbitalElements Class */
00122         cout << "\n\nChecking the OsculatingOrbitalElements Class... " << endl;
00123 
00124         m_OrbitalElementCheck(1) = 6800 ;
00125         m_OrbitalElementCheck(2) = 0.1 ;
00126         m_OrbitalElementCheck(3) = Deg2Rad( 10.0 ) ;
00127         m_OrbitalElementCheck(4) = Deg2Rad( 20.0 ) ;
00128         m_OrbitalElementCheck(5) = Deg2Rad( 30.0 ) ;
00129         m_OrbitalElementCheck(6) = Deg2Rad( 40.0 ) ;
00130 
00131         Keplerian _Orbit;
00132         _Orbit.SetKeplerianRepresentationTrueAnomaly( m_OrbitalElementCheck );
00133 
00134         OsculatingOrbitalElements _OsculatingOrbit;
00135         _OsculatingOrbit.SetOsculatingOrbitalElements( _Orbit );
00136         
00137         Keplerian _meanOrbit;
00138         _meanOrbit = _OsculatingOrbit.GetMeanOrbitalElements( );
00139  
00140         _OsculatingOrbit.SetMeanOrbitalElements ( _meanOrbit );
00141         Keplerian _Orbit2;
00142         _Orbit2 = _OsculatingOrbit.GetOsculatingOrbitalElements( );
00143  
00144         cout << "Initial Osculating Keplerian Vector: " << endl;
00145         DisplayKeplerian( _Orbit );
00146         cout << "Final Osculating Keplerian Vector: " << endl;
00147         DisplayKeplerian( _Orbit2 );
00148         cout << "Previous Vectors should be the same if the Osculating functions are working" << endl;
00149         bool _status;
00150         _status = CompareKeplerian( _Orbit, _Orbit2 );
00151         ErrorCheck( _status );
00152 
00153         return;
00154 }
00155 
00156 
00157 void TestKeplerian::Keplerian2ECI2Keplerian( )
00158 {
00159         bool status;    
00160         Keplerian _check( m_OrbitalElementCheck );
00161 
00162         Vector positionVelocity(6);
00163         positionVelocity = _check.GetPositionVelocity(); // IJK frame
00164         
00165         Keplerian _compare;
00166         _compare.SetPositionVelocity( positionVelocity );
00167 
00168         /* Display Results */
00169         cout << "Keplerian Initial Vector: " << endl;
00170         DisplayKeplerian( _check );
00171         cout << "Position and Velocity conversion from Keplerian Vector: " << endl;
00172         DisplayPositionVelocity( positionVelocity );
00173         cout << "Keplerian Vector from position and velocity conversion: " << endl;
00174         DisplayKeplerian( _compare );
00175 
00176         status = CompareKeplerian( _check, _compare );
00177         ErrorCheck( status );
00178 
00179         return;
00180 }       
00181 
00182 bool TestKeplerian::CompareKeplerian( Keplerian _keplerianA, Keplerian _keplerianB )
00183 {
00184         if( abs( _keplerianA.GetSemimajorAxis() -  _keplerianB.GetSemimajorAxis() ) > 0.001 )
00185                 return false;  
00186         if( abs( _keplerianA.GetEccentricity() -  _keplerianB.GetEccentricity() ) > 0.001 )
00187                 return false;  
00188         if( abs( _keplerianA.GetInclination() -  _keplerianB.GetInclination() ) > 0.001 )
00189                 return false;  
00190         if( abs( _keplerianA.GetLongAscNode() -  _keplerianB.GetLongAscNode() ) > 0.001 )
00191                 return false;  
00192         if( abs( _keplerianA.GetArgPerigee() -  _keplerianB.GetArgPerigee() ) > 0.001 )
00193                 return false;  
00194         if( abs( _keplerianA.GetTrueAnomaly() -  _keplerianB.GetTrueAnomaly() ) > 0.001 )
00195                 return false;  
00196         if( abs( _keplerianA.GetEccentricAnomaly() -  _keplerianB.GetEccentricAnomaly() ) > 0.001 )
00197                 return false;  
00198         if( abs( _keplerianA.GetMeanAnomaly() -  _keplerianB.GetMeanAnomaly() ) > 0.001 )
00199                 return false;  
00200         else
00201                 return true;
00202 }
00203 
00204 void TestKeplerian::ErrorCheck( bool _status )
00205 {
00206         if ( _status == true )
00207                 cout << "------ Check Good ------ " << endl;
00208         else
00209                 cout <<  "********* WARNING: Check Bad *********** " << endl;
00210         return;
00211 }
00212 
00213 void TestKeplerian::DisplayKeplerian( Keplerian _keplerian )
00214 {
00215 
00216         cout << "Display of Keplerian Variables:\n " 
00217                 << "Semimajor Axis (km): "      << _keplerian.GetSemimajorAxis()
00218                 << " Eccentricity (~): "        << _keplerian.GetEccentricity()
00219                 << " Inclination (rad): "       << _keplerian.GetInclination()
00220                 << " Long Ascending Node (rad): " << _keplerian.GetLongAscNode()
00221                 << " Argument of Perigee (rad): " << _keplerian.GetArgPerigee()
00222                 << " True Anomaly (rad): "      << _keplerian.GetTrueAnomaly()
00223                 << " Eccentric Anomaly (rad): " << _keplerian.GetEccentricAnomaly()
00224                 << " Mean Anomaly (-): "        << _keplerian.GetMeanAnomaly()
00225                 << endl;
00226 }
00227 
00228 void TestKeplerian::DisplayPositionVelocity( Vector _positionVelocity )
00229 {
00230         cout << "ECI Reference Frame-\n Position (km): " 
00231                 << ~_positionVelocity( _(1,3) )
00232                 << " Velocity (km/s): " << ~_positionVelocity( _(4,6) )
00233                 << endl;
00234 
00235 }
00236 
00237 } // close namespace O_SESSAME
00238 
00239 // Do not change the comments below - they will be added automatically by CVS
00240 /*****************************************************************************
00241 *       $Log: TestKeplerian.cpp,v $
00242 *       Revision 1.2  2006/08/25 15:50:37  jayhawk_hokie
00243 *       Added tests for the OsculatingOrbitalElements Class.
00244 *       
00245 *       Revision 1.1  2006/08/23 21:49:52  jayhawk_hokie
00246 *       Initial submission.
00247 *       
00248 *
00249 *
00250 *
00251 ******************************************************************************/

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