00001 #pragma ident "$Id: AstronomicalFunctions.cpp 2944 2011-10-27 08:04:41Z yanweignss $" 00002 00008 //============================================================================ 00009 // 00010 // This file is part of GPSTk, the GPS Toolkit. 00011 // 00012 // The GPSTk is free software; you can redistribute it and/or modify 00013 // it under the terms of the GNU Lesser General Public License as published 00014 // by the Free Software Foundation; either version 2.1 of the License, or 00015 // any later version. 00016 // 00017 // The GPSTk is distributed in the hope that it will be useful, 00018 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 // GNU Lesser General Public License for more details. 00021 // 00022 // You should have received a copy of the GNU Lesser General Public 00023 // License along with GPSTk; if not, write to the Free Software Foundation, 00024 // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00025 // 00026 // Dagoberto Salazar - gAGE ( http://www.gage.es ). 2007 00027 // 00028 //============================================================================ 00029 00030 00031 #include "AstronomicalFunctions.hpp" 00032 00033 00034 namespace gpstk 00035 { 00036 00037 /* Function to change from CIS to CTS(ECEF) coordinate system 00038 * (coordinates in meters) 00039 * @param posCis Coordinates in CIS system (in meters). 00040 * @param t Epoch 00041 * 00042 * @return Triple in CTS(ECEF) coordinate system. 00043 */ 00044 Triple CIS2CTS(const Triple posCIS, 00045 const DayTime& t) 00046 { 00047 00048 // Angle of Earth rotation, in radians 00049 double ts( UTC2SID(t)*TWO_PI/24.0 ); 00050 00051 Triple res; 00052 00053 res.theArray[0] = ::cos(ts)*posCIS.theArray[0] + 00054 ::sin(ts)*posCIS.theArray[1]; 00055 00056 res.theArray[1] = -::sin(ts)*posCIS.theArray[0] + 00057 ::cos(ts)*posCIS.theArray[1]; 00058 00059 res.theArray[2] = posCIS.theArray[2]; 00060 00061 return res; 00062 } // End CIS2CTS() 00063 00064 00065 /* Function to convert from UTC to sidereal time 00066 * @param t Epoch 00067 * 00068 * @return sidereal time in hours. 00069 */ 00070 double UTC2SID(const DayTime& t) 00071 { 00072 00073 double y(t.year()-1.0); 00074 double m(13.0); 00075 double d(t.DOY()); 00076 00077 // Hours of day (decimal) 00078 double h(t.secOfDay()/3600.0); 00079 00080 // Fraction of day 00081 double frofday (t.secOfDay()/86400.0); 00082 00083 // Compute Julian Day, including decimals 00084 double jd(t.JD()); 00085 00086 // Temporal value, in centuries 00087 double tt( (jd - 2451545.0)/36525.0 ); 00088 00089 double sid( 24110.54841 + tt*( (8640184.812866) + 00090 tt*( (0.093104) - (6.2e-6*tt)) ) ); 00091 00092 sid = sid/3600.0 + h; 00093 sid = ::fmod(sid,24.0); 00094 00095 if (sid < 0.0) 00096 { 00097 sid+=24.0; 00098 } 00099 00100 return sid; 00101 } 00102 00103 } // end namespace gpstk
1.3.9.1