QuaternionAngVelDynamics.h

Go to the documentation of this file.
00001 
00002 
00008 /* 
00009 */
00011 
00012 #ifndef __OSESSAME_ATTDYN_QUATANGVEL_H__
00013 #define __OSESSAME_ATTDYN_QUATANGVEL_H__
00014 #include "matrix/Matrix.h"
00015 #include "Integrator.h"
00016 #include "Time.h"
00017 #include "Orbit.h"
00018 #include "OrbitState.h"
00019 #include "Attitude.h"
00020 #include <vector.h>
00021 using namespace std;
00022 using namespace O_SESSAME;
00023 
00034 static void QuaternionAngVelConvFunc(const Matrix &_meshPoint, AttitudeState &_convertedAttitudeState)
00035 {
00036     static Vector tempQ(4); 
00037     static Vector tempAngVel(3); 
00038     
00039     tempQ(_) = ~_meshPoint(_,_(2, 5));
00040     tempAngVel(_) = ~_meshPoint(1, _(6, 8));
00041     _convertedAttitudeState.SetState(Rotation(Quaternion(tempQ)), tempAngVel);
00042     return;
00043 }
00044 
00093 static Vector AttituteDynamics_QuaternionAngVel(const ssfTime &_time, const Vector& _integratingState, Orbit *_Orbit, Attitude *_Attitude, const Matrix &_parameters, const Functor &_torqueFuncPtr)
00094 {
00095     static Vector stateDot(7);
00096     static Matrix bMOI(3,3); 
00097     static Matrix invMOI(3,3);
00098     static Matrix qtemp(4,3); 
00099     static Vector Tmoment(3);
00100     static Vector qIn(4); 
00101     static Vector wIn(3);
00102     qIn = _integratingState(_(VectorIndexBase,VectorIndexBase + 3));
00103     wIn = _integratingState(_(VectorIndexBase + 4,VectorIndexBase + 6));
00104     qIn /= norm2(qIn);
00105 
00106 //    _attitudeState->SetState(Rotation(Quaternion(qIn)), wIn);  // Need to speed up in some way
00107     qtemp(_(VectorIndexBase+0,VectorIndexBase+2),_(VectorIndexBase+0,VectorIndexBase+2)) = skew(qIn(_(VectorIndexBase+0,VectorIndexBase+2))) + qIn(VectorIndexBase+3) * eye(3);
00108     qtemp(VectorIndexBase+3, _(VectorIndexBase+0,VectorIndexBase+2)) = -(~qIn(_(VectorIndexBase+0,VectorIndexBase+2)));
00109 
00110     bMOI = _parameters(_(MatrixIndexBase+0,MatrixIndexBase+2),_(MatrixIndexBase+0,MatrixIndexBase+2));
00111     invMOI = _parameters(_(MatrixIndexBase+3,MatrixIndexBase+5),_(MatrixIndexBase+0,MatrixIndexBase+2));
00112     Tmoment = _torqueFuncPtr.Call(_time, _Orbit->GetStateObject(), _Attitude->GetStateObject());
00113     
00114     stateDot(_(VectorIndexBase,VectorIndexBase + 3)) = 0.5 * qtemp * wIn;
00115     stateDot(_(VectorIndexBase + 4,VectorIndexBase + 6)) = (invMOI * (Tmoment - skew(wIn) * (bMOI * wIn)));
00116     return stateDot;
00117 }
00118 
00119 #endif
00120 // Do not change the comments below - they will be added automatically by CVS
00121 /*****************************************************************************
00122 *       $Log: QuaternionAngVelDynamics.h,v $
00123 *       Revision 1.2  2003/06/12 20:51:14  nilspace
00124 *       Requires a precomputer MOI inverse.
00125 *       
00126 *       Revision 1.1  2003/06/12 19:17:42  nilspace
00127 *       Initial Submission.
00128 *       
00129 *
00130 ******************************************************************************/

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