00001 #pragma ident "$Id: ENUUtil.cpp 2535 2011-03-25 15:58:06Z ccutlip $"
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 #include "ENUUtil.hpp"
00031
00032 namespace gpstk
00033 {
00034
00035
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 }