Start of code for Observer / Eci
parent
bd8bacff55
commit
69acbc8c54
|
@ -0,0 +1,38 @@
|
|||
#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_.ToLMST(longitude);
|
||||
|
||||
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);
|
||||
|
||||
position_.SetX(achcp * cos(theta));
|
||||
position_.SetY(achcp * sin(theta));
|
||||
|
||||
position_.SetZ((Globals::XKMPER() * s + altitude) * sin(latitude));
|
||||
position_.SetW(sqrt(pow(position_.GetX(), 2.0) + pow(position_.GetY(), 2.0) + pow(position_.GetZ(), 2.0)));
|
||||
|
||||
velocity_.SetX(-mfactor * position_.GetY());
|
||||
velocity_.SetY(mfactor * position_.GetX());
|
||||
velocity_.SetZ(0.0);
|
||||
velocity_.SetW(sqrt(pow(velocity_.GetX(), 2.0) + pow(velocity_.GetY(), 2.0)));
|
||||
}
|
||||
|
||||
Eci::Eci(const Julian &date, const Vector &position, const Vector &velocity)
|
||||
: date_(date), position_(position), velocity_(velocity) {
|
||||
|
||||
}
|
||||
|
||||
Eci::~Eci(void) {
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
#ifndef ECI_H_
|
||||
#define ECI_H_
|
||||
|
||||
#include "Coord.h"
|
||||
#include "Vector.h"
|
||||
#include "Julian.h"
|
||||
|
||||
class Eci {
|
||||
public:
|
||||
Eci(const Julian &date, const CoordGeodetic &geo);
|
||||
Eci(const Julian &date, const Vector &position, const Vector &velocity);
|
||||
virtual ~Eci(void);
|
||||
|
||||
Vector GetPosition() const {
|
||||
return position_;
|
||||
}
|
||||
|
||||
Vector GetVelocity() const {
|
||||
return velocity_;
|
||||
}
|
||||
|
||||
Julian GetDate() const {
|
||||
return date_;
|
||||
}
|
||||
|
||||
private:
|
||||
Vector position_;
|
||||
Vector velocity_;
|
||||
Julian date_;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
18
Globals.h
18
Globals.h
|
@ -8,6 +8,24 @@ public:
|
|||
Globals(void);
|
||||
~Globals(void);
|
||||
|
||||
static const double F() {
|
||||
/*
|
||||
* earth flattening
|
||||
*/
|
||||
return 1.0 / 298.26;
|
||||
}
|
||||
|
||||
static const double OMEGA_E() {
|
||||
/*
|
||||
* earth rotation per sideral day
|
||||
*/
|
||||
return 1.00273790934;
|
||||
}
|
||||
|
||||
static const double XKMPER() {
|
||||
return 6378.135;
|
||||
}
|
||||
|
||||
static const double PI() {
|
||||
return 3.14159265358979323846264338327950288419716939937510582;
|
||||
}
|
||||
|
|
15
Observer.cpp
15
Observer.cpp
|
@ -1,6 +1,19 @@
|
|||
#include "Observer.h"
|
||||
|
||||
Observer::Observer(void) {
|
||||
#include "Globals.h"
|
||||
|
||||
/*
|
||||
* in degrees!
|
||||
*/
|
||||
Observer::Observer(const double latitude, const double longitude, const double altitude) {
|
||||
geo_.SetLatitude(Globals::Deg2Rad(latitude));
|
||||
geo_.SetLongitude(Globals::Deg2Rad(longitude));
|
||||
geo_.SetAltitude(altitude);
|
||||
}
|
||||
|
||||
Observer::Observer(const CoordGeodetic &geo)
|
||||
: geo_(geo) {
|
||||
|
||||
}
|
||||
|
||||
Observer::~Observer(void) {
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
|
||||
class Observer {
|
||||
public:
|
||||
Observer(void);
|
||||
Observer(const double latitude, const double longitude, const double altitude);
|
||||
Observer(const CoordGeodetic &geo);
|
||||
virtual ~Observer(void);
|
||||
|
||||
void SetLocation(const CoordGeodetic& geo) {
|
||||
|
|
Loading…
Reference in New Issue