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

TwoBodyDynamics.h

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////////////////////////
00002 /*! \file TwoBodyDynamics.h
00003 *  \brief Dynamic equations and forces of two-body motion.
00004 *  \author $Author: jayhawk_hokie $
00005 *  \version $Revision: 1.2 $
00006 *  \date    $Date: 2005/06/10 12:53:28 $
00007 *//////////////////////////////////////////////////////////////////////////////////////////////////
00008 /* 
00009 */
00010 //////////////////////////////////////////////////////////////////////////////////////////////////
00011 
00012 #ifndef __OSESSAME_TWOBODYDYNAMICS_H__
00013 #define __OSESSAME_TWOBODYDYNAMICS_H__
00014 #include <matrix/Matrix.h>
00015 #include <utils/Integrator.h>
00016 #include <utils/Time.h>
00017 #include <orbit/Orbit.h>
00018 #include <orbit/OrbitState.h>
00019 #include <attitude/Attitude.h>
00020 #include <vector.h>
00021 using namespace std;
00022 using namespace O_SESSAME;
00023 
00024 /*! \brief Orbit state conversion function from Position and Velocity state vector.
00025 * \relates TwoBodyDynamics 
00026 *
00027 * This function converts a matrix of states from the TwoBodyDynamics right-hand
00028 * side function into an OrbitState object. This conversion function is necessary for propagators 
00029 * to store to an OrbitHistory object regardless of the equations of motion state vector being
00030 * used.
00031 * @param _meshPoint State vector from integration mesh point, [Position (3), Velocity (3)].
00032 * @param _convertedOrbitState OrbitState object that is converted from the mesh point vector. This function 
00033 *       just sets the position and velocity state representation and requires the user to set the 
00034 *       corresponding reference frame.
00035 */
00036 static void PositionVelocityConvFunc(const Matrix &_meshPoint, OrbitState &_convertedOrbitState)
00037 {
00038     static Vector tempPosVelVector(_meshPoint[MatrixColsIndex].getIndexBound() - 1);
00039     tempPosVelVector(_) = ~_meshPoint(_,_(MatrixIndexBase+1, _meshPoint[MatrixColsIndex].getIndexBound()));
00040     _convertedOrbitState.GetStateRepresentation()->SetPositionVelocity(tempPosVelVector);
00041     return;
00042 }
00043 
00044 /*! \brief Orbit equation of motion using position and velocity.
00045 * @ingroup OrbitEquationsOfMotion
00046 *
00047 *
00048 * Calculate the new time rate of change of state (position & velocity) using two-body dynamics with disturbance forces
00049 \f[
00050 \ddot{\vec{r}}  =  -\frac{\mu}{r^{2}}\frac{\vec{r}}{r}\f]
00051 The returned state vector is:
00052 \f[
00053 \begin{bmatrix}
00054 \dot{\vec{r}}\\
00055 \dot{\vec{v}}
00056 \end{bmatrix}
00057  = 
00058 \begin{bmatrix}
00059 \vec{v}\\
00060 -\frac{\mu}{\left|\vec{r}\right|^{3}}\vec{r}
00061 \end{bmatrix}
00062 \f]
00063 * @param _time current time (in seconds)
00064 * @param _state vector of states, \f$\left[\vec{r},\vec{v}\right]^{T}\f$ (kilometers, kilometers/second)
00065 * @param _pOrbit pointer to the current Orbit instance
00066 * @param _pAttitude pointer to the current Attitude instance
00067 * @param _parameters additional parameters for integration \f$\left[\mu\right]\f$ 
00068 * @param _forceFuncPtr pointer to the force calculating function
00069 * @return 6x1 vector of time derivatives of state \f$\left[\dot{\vec{r}},\dot{\vec{v}}\right]^{T}\f$
00070 */
00071 static Vector TwoBodyDynamics(const ssfTime &_time, const Vector& _integratingState, Orbit *_pOrbit, Attitude *_pAttitude, const Matrix &_parameters, const Functor &_forceFunctorPtr)
00072 {
00073 //    _Orbit->SetStateObject(OrbitState(new PositionVelocity(_integratingState)));
00074     static Vector Forces(3);
00075     static Vector Velocity(3);
00076     static Vector stateDot(6);
00077     static AttitudeState tempAttState; // don't need this except to pass an empty one if there is no attitude
00078     static OrbitState orbState(new PositionVelocity);
00079 
00080     orbState.GetStateRepresentation()->SetPositionVelocity(_integratingState);
00081 
00082     if(_pAttitude)
00083         Forces = _forceFunctorPtr.Call(_time, orbState, _pAttitude->GetStateObject());
00084     else 
00085         Forces = _forceFunctorPtr.Call(_time, orbState, tempAttState);
00086 
00087     Velocity(_) = _integratingState(_(VectorIndexBase+3,VectorIndexBase+5));
00088     
00089 
00090     stateDot(_(VectorIndexBase, VectorIndexBase+2)) = Velocity(_);
00091     stateDot(_(VectorIndexBase+3, VectorIndexBase+5)) = Forces(_);
00092     return stateDot;
00093 }
00094 
00095 #endif
00096 // Do not change the comments below - they will be added automatically by CVS
00097 /*****************************************************************************
00098 *       $Log: TwoBodyDynamics.h,v $
00099 *       Revision 1.2  2005/06/10 12:53:28  jayhawk_hokie
00100 *       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).
00101 *       
00102 *       Revision 1.1.1.1  2005/04/26 17:41:00  cakinli
00103 *       Adding OpenSESSAME to DSACSS distrib to capture fixed version.
00104 *       
00105 *       Revision 1.8  2003/10/18 21:37:28  rsharo
00106 *       Removed "../utils" from all qmake project paths. Prepended "utils
00107 *       /" to all #include directives for utils. Removed ".h" extensions from STL header
00108 *       s and referenced STL components from "std::" namespace.  Overall, changed to be
00109 *       more portable.
00110 *       
00111 *       Revision 1.7  2003/06/12 18:02:37  nilspace
00112 *       Fixed evaluation.
00113 *       
00114 *       Revision 1.6  2003/05/22 21:03:26  nilspace
00115 *       Fixed to run faster with static variables.
00116 *       
00117 *       Revision 1.5  2003/05/20 17:47:59  nilspace
00118 *       Updated comments.
00119 *       
00120 *       Revision 1.4  2003/05/13 18:49:41  nilspace
00121 *       Fixed to get the StateObjects.
00122 *       
00123 *       Revision 1.3  2003/05/10 00:43:13  nilspace
00124 *       Updated the includes for Orbit.h and Attitude.h
00125 *       
00126 *       Revision 1.2  2003/04/22 20:25:44  simpliciter
00127 *       Updated LaTeX formulas for \ddot{r} and \dot{state vector} for
00128 *       proper display.
00129 *       
00130 *       Revision 1.1  2003/04/08 22:48:29  nilspace
00131 *       Initial Submission.
00132 *       
00133 *
00134 ******************************************************************************/

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