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

OrbitState.cpp

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////////////////////////
00002 /*! \file OrbitState.cpp
00003 *  \brief Implementation of the Orbit State Interface Class.
00004 *  \author $Author: jayhawk_hokie $
00005 *  \version $Revision: 1.2 $
00006 *  \date    $Date: 2007/08/02 21:21:06 $
00007 *//////////////////////////////////////////////////////////////////////////////////////////////////
00008 /* 
00009 *
00010 */
00011 //////////////////////////////////////////////////////////////////////////////////////////////////
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 {
00023     /*! \todo Determine if the OrbitState copy function is req'd or hacked. */
00024     /*! \bug if OrbitFrame is not set, but a vector::push_back function is called, 
00025         * _OrbStateCopy.m_pOrbitFrame = 0xffffffff, which indicates a failure. Need 
00026         * to fix this.
00027         */
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 {
00039     /*! \todo determine how to delete OrbitState pointers */
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 { /** \todo add conversion of OrbitStateRepresentation to the new frame */
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.2  2007/08/02 21:21:06  jayhawk_hokie
00135 *       Fixed Warning
00136 *       
00137 *       Revision 1.1.1.1  2005/04/26 17:40:59  cakinli
00138 *       Adding OpenSESSAME to DSACSS distrib to capture fixed version.
00139 *       
00140 *       Revision 1.9  2003/06/12 23:08:20  nilspace
00141 *       Fixed to calculate angular momentum.
00142 *       
00143 *       Revision 1.8  2003/06/12 18:02:15  nilspace
00144 *       Added GetAngularVelocity() function.
00145 *       
00146 *       Revision 1.7  2003/05/22 14:37:32  nilspace
00147 *       Return *this in operator=
00148 *       
00149 *       Revision 1.6  2003/05/20 17:47:59  nilspace
00150 *       Updated comments.
00151 *       
00152 *       Revision 1.5  2003/05/13 18:46:28  nilspace
00153 *       Checked pointers if they were initialized before calling.
00154 *       
00155 *       Revision 1.4  2003/04/29 20:56:24  nilspace
00156 *       Update to work with Propagator.
00157 *       
00158 *       Revision 1.3  2003/04/29 18:47:31  nilspace
00159 *       Added copy constructor and operator= functions.
00160 *       
00161 *       Revision 1.2  2003/04/27 21:14:01  nilspace
00162 *       Added to the namespace O_SESSAME.
00163 *       Moved function definitions outside of the class interface definition.
00164 *       
00165 *       Revision 1.1  2003/04/25 14:01:28  nilspace
00166 *       Recommited to fix capitalization.
00167 *       
00168 *       Revision 1.1  2003/04/23 16:26:03  nilspace
00169 *       Updated directory structure & default parameters.
00170 *       
00171 *
00172 ******************************************************************************/
00173 

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