NEDUtil.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: NEDUtil.cpp 2535 2011-03-25 15:58:06Z ccutlip $"
00002 
00003 //============================================================================
00004 //
00005 //  This file is part of GPSTk, the GPS Toolkit.
00006 //
00007 //  The GPSTk is free software; you can redistribute it and/or modify
00008 //  it under the terms of the GNU Lesser General Public License as published
00009 //  by the Free Software Foundation; either version 2.1 of the License, or
00010 //  any later version.
00011 //
00012 //  The GPSTk is distributed in the hope that it will be useful,
00013 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 //  GNU Lesser General Public License for more details.
00016 //
00017 //  You should have received a copy of the GNU Lesser General Public
00018 //  License along with GPSTk; if not, write to the Free Software Foundation,
00019 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 //  
00021 //  Copyright 2007, The University of Texas at Austin
00022 //
00023 //============================================================================
00024 
00025 
00026 
00027 
00028 //
00029 //
00030 //#include <stdio.h>
00031 
00032 // gpstk
00033 #include "NEDUtil.hpp"
00034 
00035 namespace gpstk
00036 {
00037 
00038 //using namespace std; 
00039 
00040 NEDUtil::NEDUtil(const double refLatRad,
00041                  const double refLonRad)
00042 {
00043    compute( refLatRad, refLonRad ); 
00044 }
00045 
00046 //
00047 //
00048 void NEDUtil::compute( const double refLat,
00049                        const double refLon )
00050 {
00051    rotMat.resize(3,3);
00052    rotMat (0,0) =  -std::sin(refLat)*std::cos(refLon);
00053    rotMat (1,0) =  -std::sin(refLon);
00054    rotMat (2,0) =  -std::cos(refLat)*std::cos(refLon);
00055    rotMat (0,1) =  -std::sin(refLat)*std::sin(refLon);
00056    rotMat (1,1) =   std::cos(refLon);
00057    rotMat (2,1) =  -std::cos(refLat)*std::sin(refLon);
00058    rotMat (0,2) =   std::cos(refLat);
00059    rotMat (1,2) =   0.0;
00060    rotMat (2,2) =  -std::sin(refLat);
00061 }
00062 
00063 void NEDUtil::updatePosition( const double refLatRad,
00064                               const double refLonRad )
00065 {
00066    compute( refLatRad, refLonRad );
00067 }
00068 
00069 gpstk::Vector<double> NEDUtil::convertToNED( const gpstk::Vector<double>& inV ) const
00070 {
00071    gpstk::Vector<double> outV(3);
00072 
00073    if (inV.size()!=3)
00074    {
00075       gpstk::Exception e("Incompatible dimensions for Vector");
00076       GPSTK_THROW(e);
00077    }
00078    outV = rotMat * inV;
00079    return(outV);
00080 }
00081    
00082 gpstk::Triple NEDUtil::convertToNED( const gpstk::Triple& inVec ) const
00083 {
00084    gpstk::Vector<double> v(3); 
00085    v[0] = inVec[0];
00086    v[1] = inVec[1];
00087    v[2] = inVec[2];
00088    
00089    gpstk::Vector<double> vOut = convertToNED( v );
00090    gpstk::Triple outVec( vOut[0], vOut[1], vOut[2] );
00091    return(outVec);
00092 }
00093    
00094 gpstk::Xvt NEDUtil::convertToNED( const gpstk::Xvt& in ) const
00095 {
00096    gpstk::Xvt out;
00097    out.dtime = in.dtime;
00098    out.ddtime = in.ddtime;
00099    out.x = convertToNED( in.x );
00100    out.v = convertToNED( in.v );
00101    return(out);
00102 }
00103 }     // end namespace gpstk

Generated on Tue May 22 03:31:00 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1