00001
00002
00003 #include "flux/Orbit.h"
00004
00005 #include "CLHEP/Random/RandFlat.h"
00006 #include "flux/GPS.h"
00007
00008 #include <cmath>
00009 #include <cassert>
00010
00011
00012 Orbit::Orbit(double asclon, double alt, double inc, double phs
00013 , double pitch , double yaw, double roll) :
00014
00015 m_ascendingLon(asclon),
00016 m_altitude(alt),
00017 m_period(1.6612e-4 * pow(alt+6371.2, 1.5)),
00018 m_startphase(phs)
00019
00020 {
00021 inclination( inc );
00022 }
00023
00024 void Orbit::inclination ( double inc )
00025 {
00026 m_inclination = inc;
00027 m_sini = (sin(m_inclination*M_2PI/360.));
00028 m_cosi = (cos(m_inclination*M_2PI/360.));
00029 }
00030
00031 void Orbit::ascendingLon ( double asc )
00032 {
00033 m_ascendingLon = asc;
00034 }
00035
00036 void Orbit::startphase ( double phs )
00037 {
00038 m_startphase = phs;
00039 }
00040
00041 double Orbit::latitude(double time) const {
00042
00043 return (360./M_2PI) * asin(m_sini * sin(M_2PI*time/m_period + startphase()));
00044 }
00045
00046 double Orbit::longitude(double time) const {
00047
00048
00049
00050 double phase = M_2PI * time / m_period + startphase();
00051 double lon = (360./M_2PI) * atan2(m_cosi*sin(phase), cos(phase)) -
00052 360.* time /1440. + m_ascendingLon;
00053 lon = fmod(lon, 360.);
00054 if (lon < 0.) lon += 360.;
00055 return lon;
00056 }
00057
00058 double Orbit::pitch (double time) const {
00059 return 0.;
00060 }
00061
00062 double Orbit::yaw (double time) const {
00063 return 0.;
00064 }
00065
00066 double Orbit::roll (double time) const {
00067 return 0.;
00068 }
00069
00070 double Orbit::phase (double time) const {
00071 double p = period();
00072 return (p == 0) ? 0. : time/p * 2*M_PI + startphase();
00073 }
00074
00075 std::pair<double,double> Orbit::coords(double time) const {
00076 return std::make_pair(latitude(time), longitude(time));
00077 }