ENUUtil.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: ENUUtil.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 // gpstk
00030 #include "ENUUtil.hpp"
00031 
00032 namespace gpstk
00033 {
00034 
00035 //using namespace std; 
00036 
00037 ENUUtil::ENUUtil(const double refLatRad,
00038                  const double refLonRad)
00039 {
00040    compute( refLatRad, refLonRad ); 
00041 }
00042 
00043 //
00044 //
00045 void ENUUtil::compute( const double refLat,
00046                        const double refLon )
00047 {
00048    rotMat.resize(3,3);
00049    rotMat (0,0) =  -std::sin(refLon);
00050    rotMat (1,0) =  -std::sin(refLat)*std::cos(refLon);
00051    rotMat (2,0) =   std::cos(refLat)*std::cos(refLon);
00052    rotMat (0,1) =   std::cos(refLon);
00053    rotMat (1,1) =  -std::sin(refLat)*std::sin(refLon);
00054    rotMat (2,1) =   std::cos(refLat)*std::sin(refLon);
00055    rotMat (0,2) =   0.0;
00056    rotMat (1,2) =   std::cos(refLat);
00057    rotMat (2,2) =   std::sin(refLat);
00058 }
00059 
00060 void ENUUtil::updatePosition( const double refLatRad,
00061                               const double refLonRad )
00062 {
00063    compute( refLatRad, refLonRad );
00064 }
00065 
00066 
00067 gpstk::Vector<double> ENUUtil::convertToENU( const gpstk::Vector<double>& inV ) const
00068 {
00069    gpstk::Vector<double> outV(3);
00070 
00071    if (inV.size()!=3)
00072    {
00073       gpstk::Exception e("Incompatible dimensions for Vector");
00074       GPSTK_THROW(e);
00075    }
00076    outV = rotMat * inV;
00077    return(outV);
00078 }
00079    
00080 gpstk::Triple ENUUtil::convertToENU( const gpstk::Triple& inVec ) const
00081 {
00082    gpstk::Vector<double> v(3); 
00083    v[0] = inVec[0];
00084    v[1] = inVec[1];
00085    v[2] = inVec[2];
00086    
00087    gpstk::Vector<double> vOut = convertToENU( v );
00088    gpstk::Triple outVec( vOut[0], vOut[1], vOut[2] );
00089    return(outVec);
00090 }
00091    
00092 gpstk::Xvt ENUUtil::convertToENU( const gpstk::Xvt& in ) const
00093 {
00094    gpstk::Xvt out;
00095    out.dtime = in.dtime;
00096    out.ddtime = in.ddtime;
00097    out.x = convertToENU( in.x );
00098    out.v = convertToENU( in.v );
00099    return(out);
00100 }
00101 }     // end namespace gpstk

Generated on Wed Feb 8 03:30:59 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1