00001 #pragma ident "$Id: NEDUtil.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
00031
00032
00033 #include "NEDUtil.hpp"
00034
00035 namespace gpstk
00036 {
00037
00038
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 }