00001 #pragma ident "$Id: RACRotation.cpp 81 2006-08-10 16:45:12Z ehagen $"
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include "RACRotation.hpp"
00037
00038 namespace gpstk
00039 {
00040
00041
00042
00043 RACRotation::RACRotation( const gpstk::Triple& SVPositionVector,
00044 const gpstk::Triple& SVVelocityVector)
00045 : gpstk::Matrix<double>(3,3)
00046 {
00047 compute( SVPositionVector, SVVelocityVector );
00048 }
00049
00050 RACRotation::RACRotation(const gpstk::Xvt& xvt)
00051 : gpstk::Matrix<double>(3,3)
00052 {
00053 compute( xvt.x, xvt.v );
00054 }
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071 void RACRotation::compute( const gpstk::Triple& SVPositionVector,
00072 const gpstk::Triple& SVVelocityVector)
00073 {
00074
00075 gpstk::Triple unitR = SVPositionVector.unitVector();
00076 gpstk::Triple C = unitR.cross(SVVelocityVector);
00077 gpstk::Triple unitC = C.unitVector();
00078 gpstk::Triple unitA = unitC.cross(unitR);
00079
00080 (*this) (0,0) = unitR[0];
00081 (*this) (0,1) = unitR[1];
00082 (*this) (0,2) = unitR[2];
00083 (*this) (1,0) = unitA[0];
00084 (*this) (1,1) = unitA[1];
00085 (*this) (1,2) = unitA[2];
00086 (*this) (2,0) = unitC[0];
00087 (*this) (2,1) = unitC[1];
00088 (*this) (2,2) = unitC[2];
00089 }
00090
00091 gpstk::Vector<double> RACRotation::convertToRAC( const gpstk::Vector<double>& inV )
00092 {
00093 gpstk::Vector<double> outV(3);
00094
00095
00096
00097
00098
00099
00100
00101
00102 if (inV.size()!=3)
00103 {
00104 gpstk::Exception e("Incompatible dimensions for Vector");
00105 GPSTK_THROW(e);
00106 }
00107 size_t i, j;
00108 for (i = 0; i < 3; i++)
00109 {
00110 outV[i] = 0;
00111 for (j = 0; j < 3; j++)
00112 {
00113 double temp = (*this)(i,j) * inV[j];
00114 outV[i] += temp;
00115 }
00116 }
00117
00118 return(outV);
00119 }
00120
00121 gpstk::Triple RACRotation::convertToRAC( const gpstk::Triple& inVec )
00122 {
00123 gpstk::Vector<double> v(3);
00124 v[0] = inVec[0];
00125 v[1] = inVec[1];
00126 v[2] = inVec[2];
00127
00128 gpstk::Vector<double> vOut = convertToRAC( v );
00129 gpstk::Triple outVec( vOut[0], vOut[1], vOut[2] );
00130 return(outVec);
00131 }
00132
00133 gpstk::Xvt RACRotation::convertToRAC( const gpstk::Xvt& in )
00134 {
00135 gpstk::Xvt out;
00136 out.dtime = in.dtime;
00137 out.ddtime = in.ddtime;
00138 out.x = convertToRAC( in.x );
00139 out.v = convertToRAC( in.v );
00140 return(out);
00141 }
00142 }