sgp4/Eci.cpp

53 lines
1.6 KiB
C++
Raw Normal View History

2011-03-30 16:03:52 +00:00
#include "Eci.h"
Eci::Eci(const Julian &date, const CoordGeodetic &geo)
: date_(date) {
static const double mfactor = Globals::TWOPI() * (Globals::OMEGA_E() / Globals::SEC_PER_DAY());
const double latitude = geo.GetLatitude();
const double longitude = geo.GetLongitude();
const double altitude = geo.GetAltitude();
/*
* Calculate Local Mean Sidereal Time for observers longitude
*/
const double theta = date_.ToLocalMeanSiderealTime(longitude);
2011-03-30 16:03:52 +00:00
2011-04-09 18:56:35 +00:00
/*
* take into account earth flattening
*/
2011-03-30 16:03:52 +00:00
const double c = 1.0 / sqrt(1.0 + Globals::F() * (Globals::F() - 2.0) * pow(sin(latitude), 2.0));
const double s = pow(1.0 - Globals::F(), 2.0) * c;
const double achcp = (Globals::XKMPER() * c + altitude) * cos(latitude);
2011-04-09 18:56:35 +00:00
/*
* X position in km
* Y position in km
* Z position in km
* W magnitude in km
*/
2011-03-30 16:03:52 +00:00
position_.SetX(achcp * cos(theta));
position_.SetY(achcp * sin(theta));
position_.SetZ((Globals::XKMPER() * s + altitude) * sin(latitude));
2011-04-03 12:08:31 +00:00
position_.SetW(position_.GetMagnitude());
2011-03-30 16:03:52 +00:00
2011-04-09 18:56:35 +00:00
/*
* X velocity in km/s
* Y velocity in km/s
* Z velocity in km/s
* W magnitude in km/s
*/
2011-03-30 16:03:52 +00:00
velocity_.SetX(-mfactor * position_.GetY());
velocity_.SetY(mfactor * position_.GetX());
velocity_.SetZ(0.0);
2011-04-03 12:08:31 +00:00
velocity_.SetW(velocity_.GetMagnitude());
2011-03-30 16:03:52 +00:00
}
Eci::Eci(const Julian &date, const Vector &position, const Vector &velocity)
: date_(date), position_(position), velocity_(velocity) {
}
Eci::~Eci(void) {
}