OrbitState.cpp

Go to the documentation of this file.
00001 
00002 
00008 /* 
00009 *
00010 */
00012 
00013 #include "OrbitState.h"
00014 namespace O_SESSAME {
00015 
00016 OrbitState::OrbitState(): m_pOrbitStateRepresentation(NULL), m_pOrbitFrame(NULL)
00017 {
00018 
00019 }
00020 
00021 OrbitState::OrbitState(const OrbitState &_OrbStateCopy)
00022 {
00028     // If there is a current representation or frame, delete it to free the memory
00029     //  then copy the data members of the orbit state to be copied.
00030     if(_OrbStateCopy.m_pOrbitStateRepresentation)
00031         m_pOrbitStateRepresentation = _OrbStateCopy.m_pOrbitStateRepresentation->Clone();
00032     if(_OrbStateCopy.m_pOrbitFrame)
00033         m_pOrbitFrame = _OrbStateCopy.m_pOrbitFrame->Clone();
00034     
00035 }
00036 
00037 OrbitState::~OrbitState()
00038 {
00040 /*
00041     if(m_pOrbitStateRepresentation)
00042         delete m_pOrbitStateRepresentation;
00043     if(m_pOrbitFrame)
00044         delete m_pOrbitFrame;
00045 */
00046 }
00047 OrbitState::OrbitState(OrbitStateRepresentation* _pOrbRep, OrbitFrame* _pOrbFrame)
00048 {
00049     SetOrbitFrame(_pOrbFrame);
00050     SetStateRepresentation(_pOrbRep);
00051 }
00052 void OrbitState::SetOrbitFrame(OrbitFrame* _pNewOrbitFrame)
00053 { 
00054     if(_pNewOrbitFrame)
00055     {
00056         if(m_pOrbitFrame)
00057             delete m_pOrbitFrame;
00058         m_pOrbitFrame = _pNewOrbitFrame->Clone();
00059     }
00060     return;
00061 }
00062 
00063 OrbitFrame* OrbitState::GetOrbitFrame() const
00064 {
00065     return m_pOrbitFrame;
00066 }
00067 void OrbitState::SetStateRepresentation(OrbitStateRepresentation* _pStateRep)
00068 {
00069     if(_pStateRep)
00070     {
00071         if(m_pOrbitStateRepresentation)
00072             delete m_pOrbitStateRepresentation;
00073         m_pOrbitStateRepresentation = _pStateRep->Clone();
00074     }
00075 }
00076 
00077 void OrbitState::SetStateRepresentation(OrbitStateRepresentation* _pStateRep,  OrbitFrame* _pOrbFrame)
00078 {
00079     SetStateRepresentation(_pStateRep);
00080     SetOrbitFrame(_pOrbFrame);
00081 }
00082 
00083 OrbitStateRepresentation* OrbitState::GetStateRepresentation() const
00084 {
00085     return m_pOrbitStateRepresentation;
00086 }
00087 
00088 double OrbitState::GetOrbitAngularMomentum() const
00089 {
00090     Vector Position(3);
00091     Vector Velocity(3);
00092     m_pOrbitStateRepresentation->GetPositionVelocity(Position, Velocity);
00093     return norm2(skew(Position) * Velocity);
00094 }
00095 
00096 
00097 void OrbitState::SetState(const Vector &_State)
00098 {
00099     if(m_pOrbitStateRepresentation)
00100         m_pOrbitStateRepresentation->SetState(_State); 
00101     return;
00102 }
00103 Vector OrbitState::GetState() const
00104 {
00105     if(m_pOrbitStateRepresentation)
00106         return m_pOrbitStateRepresentation->GetState();
00107     else
00108         return Vector(3);
00109 }
00110 
00111 OrbitState OrbitState::operator= (const OrbitState& _OrbStateCopy)
00112 {
00113     // If there is a current representation or frame, delete it to free the memory
00114     //  then copy the data members of the orbit state to be copied.
00115     if(_OrbStateCopy.GetStateRepresentation())
00116     {
00117         if( m_pOrbitStateRepresentation)
00118             delete m_pOrbitStateRepresentation;
00119         m_pOrbitStateRepresentation = _OrbStateCopy.GetStateRepresentation()->Clone();
00120     }
00121     if(_OrbStateCopy.GetOrbitFrame())
00122     {
00123         if(m_pOrbitFrame)
00124             delete m_pOrbitFrame;
00125         m_pOrbitFrame = _OrbStateCopy.GetOrbitFrame()->Clone();
00126     }
00127     return (*this);
00128 }
00129 } // close namespace O_SESSAME
00130 
00131 // Do not change the comments below - they will be added automatically by CVS
00132 /*****************************************************************************
00133 *       $Log: OrbitState.cpp,v $
00134 *       Revision 1.9  2003/06/12 23:08:20  nilspace
00135 *       Fixed to calculate angular momentum.
00136 *       
00137 *       Revision 1.8  2003/06/12 18:02:15  nilspace
00138 *       Added GetAngularVelocity() function.
00139 *       
00140 *       Revision 1.7  2003/05/22 14:37:32  nilspace
00141 *       Return *this in operator=
00142 *       
00143 *       Revision 1.6  2003/05/20 17:47:59  nilspace
00144 *       Updated comments.
00145 *       
00146 *       Revision 1.5  2003/05/13 18:46:28  nilspace
00147 *       Checked pointers if they were initialized before calling.
00148 *       
00149 *       Revision 1.4  2003/04/29 20:56:24  nilspace
00150 *       Update to work with Propagator.
00151 *       
00152 *       Revision 1.3  2003/04/29 18:47:31  nilspace
00153 *       Added copy constructor and operator= functions.
00154 *       
00155 *       Revision 1.2  2003/04/27 21:14:01  nilspace
00156 *       Added to the namespace O_SESSAME.
00157 *       Moved function definitions outside of the class interface definition.
00158 *       
00159 *       Revision 1.1  2003/04/25 14:01:28  nilspace
00160 *       Recommited to fix capitalization.
00161 *       
00162 *       Revision 1.1  2003/04/23 16:26:03  nilspace
00163 *       Updated directory structure & default parameters.
00164 *       
00165 *
00166 ******************************************************************************/

Generated on Wed Aug 6 12:58:50 2003 for Open-Sessame Framework by doxygen1.3