sgp4/Observer.cpp

66 lines
1.7 KiB
C++
Raw Normal View History

#include "Observer.h"
2011-03-30 16:03:52 +00:00
#include "Globals.h"
2011-04-09 19:03:58 +00:00
/*
* calculate lookangle between the observer and the passed in Eci object
*/
CoordTopographic Observer::GetLookAngle(const Eci &eci) {
/*
2011-04-09 19:03:58 +00:00
* update the observers Eci to match the time of the Eci passed in
* if necessary
*/
2011-04-09 19:03:58 +00:00
UpdateObserversEci(eci.GetDate());
2011-04-09 19:03:58 +00:00
/*
* calculate differences
*/
Vector range_rate = eci.GetVelocity().Subtract(observers_eci_.GetVelocity());
Vector range = eci.GetPosition().Subtract(observers_eci_.GetPosition());
2011-05-26 23:22:38 +00:00
range.w = range.GetMagnitude();
2011-04-09 19:03:58 +00:00
/*
* Calculate Local Mean Sidereal Time for observers longitude
*/
2011-05-26 23:10:31 +00:00
double theta = eci.GetDate().ToLocalMeanSiderealTime(geo_.longitude);
2011-05-26 23:10:31 +00:00
double sin_lat = sin(geo_.latitude);
double cos_lat = cos(geo_.latitude);
double sin_theta = sin(theta);
double cos_theta = cos(theta);
2011-05-26 23:22:38 +00:00
double top_s = sin_lat * cos_theta * range.x +
sin_lat * sin_theta * range.y -
cos_lat * range.z;
double top_e = -sin_theta * range.x +
cos_theta * range.y;
double top_z = cos_lat * cos_theta * range.x +
cos_lat * sin_theta * range.y +
sin_lat * range.z;
double az = atan(-top_e / top_s);
if (top_s > 0.0)
2011-05-20 21:09:23 +00:00
az += kPI;
if (az < 0.0)
2011-05-20 21:09:23 +00:00
az += 2.0 * kPI;
2011-05-26 23:22:38 +00:00
double el = asin(top_z / range.w);
double rate = range.Dot(range_rate) / range.w;
2011-04-09 19:03:58 +00:00
/*
* azimuth in radians
* elevation in radians
* range in km
* range rate in km/s
*/
CoordTopographic topo(az,
el,
2011-05-26 23:22:38 +00:00
range.w,
2011-04-09 19:03:58 +00:00
rate);
return topo;
}