RACRotation.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: RACRotation.cpp 81 2006-08-10 16:45:12Z ehagen $"
00002 
00003 
00004 
00005 
00006 //============================================================================
00007 //
00008 //  This file is part of GPSTk, the GPS Toolkit.
00009 //
00010 //  The GPSTk is free software; you can redistribute it and/or modify
00011 //  it under the terms of the GNU Lesser General Public License as published
00012 //  by the Free Software Foundation; either version 2.1 of the License, or
00013 //  any later version.
00014 //
00015 //  The GPSTk is distributed in the hope that it will be useful,
00016 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 //  GNU Lesser General Public License for more details.
00019 //
00020 //  You should have received a copy of the GNU Lesser General Public
00021 //  License along with GPSTk; if not, write to the Free Software Foundation,
00022 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023 //  
00024 //  Copyright 2004, The University of Texas at Austin
00025 //
00026 //============================================================================
00027 
00028 
00029 
00030 
00031 //
00032 //
00033 //#include <stdio.h>
00034 
00035 // gpstk
00036 #include "RACRotation.hpp"
00037 
00038 namespace gpstk
00039 {
00040 
00041 //using namespace std; 
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 //  Given the SV position vector and the SV velocity vector, 
00058 //  compute a rotation from ECEF XYZ to ECEF Radial, 
00059 //  Along-Track, Cross-Track (RAC).
00060 //
00061 //  Let the SV position vector be represented by R
00062 //  Let the SV velocity vector be represented by V
00063 //  1.) Form the unit vector R^ = R / |R|.
00064 //  2.) Compute vector C = R^ cross V and unit vector C^ = C / |C|.  C^ is
00065 //      perpendiculat to the RV plane
00066 //  3.) Compute A^ = C^ corss R^. 
00067 //  4.) [R^, A^, C^] is an orthonormal triad and the rotation matrix between
00068 //      XYZ and RAC is the matrix where R^, C^, and A^ are each a row of the
00069 //      matrix.
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       My goal was to use the following statement.
00097    outV =  this * inV;
00098       However, for some reason, gcc refuses to recognize RACRotation as a 
00099       Matrix subclass.  Therefore, I've incorporated the matrix multiply
00100       as a temporary kludge.
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    /* end kludge */
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 }     // end namespace gpstk

Generated on Fri Feb 3 03:31:03 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1