sgp4/main.cpp

134 lines
3.2 KiB
C++
Raw Normal View History

2011-03-24 15:55:10 +00:00
#include "Julian.h"
2011-03-24 16:08:24 +00:00
#include "Tle.h"
2011-04-11 16:20:40 +00:00
#include "SGP4.h"
2011-03-27 21:47:50 +00:00
#include "Globals.h"
#include "Observer.h"
#include "Coord.h"
2011-03-24 15:55:10 +00:00
2011-03-24 16:19:34 +00:00
#include <list>
2011-03-28 10:43:11 +00:00
#include <string>
2011-03-27 21:47:50 +00:00
#include <iomanip>
2011-03-24 15:55:10 +00:00
2011-04-07 14:15:47 +00:00
void FindSatellite(const Julian& time_start, const Julian& time_end) {
/*
* half a second
*/
static const double delta = 1.0 / (60.0 * 60.0 * 24.0 * 2.0);
//while (fabs(time_end - time_start) > delta) {
//}
}
2011-03-27 23:29:11 +00:00
2011-04-11 16:20:40 +00:00
void GeneratePassList(const CoordGeodetic& geo, const SGP4& model, const Julian& date) {
2011-04-05 23:56:17 +00:00
Observer obs(geo);
Eci eci;
model.FindPosition(eci, date);
2011-04-05 23:56:17 +00:00
CoordTopographic topo = obs.GetLookAngle(eci);
2011-03-27 23:29:11 +00:00
2011-04-07 14:15:47 +00:00
/*
* set start and end date
*/
Julian time0 = date;
Julian time1 = date;
time1.AddDay(10.0);
2011-04-07 14:15:47 +00:00
/*
* step throw period with 1 minute increments
*/
for (Julian jd = date; jd <= time1; jd.AddMin(1.0)) {
2011-03-29 20:15:18 +00:00
2011-03-27 23:29:11 +00:00
}
}
2011-04-05 23:56:17 +00:00
int main() {
2011-03-28 00:24:03 +00:00
2011-04-05 23:56:17 +00:00
Tle tle = Tle("UK-DMC 2 ",
"1 35683U 09041C 11089.11558659 .00000272 00000-0 54146-4 0 8712",
"2 35683 98.0762 348.1067 0001434 99.8921 260.2456 14.69414094 89293");
2011-03-28 00:24:03 +00:00
2011-04-05 23:56:17 +00:00
CoordGeodetic geo(Globals::Deg2Rad(51.360242), Globals::Deg2Rad(0.101473), 0.07);
2011-04-11 16:20:40 +00:00
SGP4 sgp4_model;
2011-04-05 23:56:17 +00:00
sgp4_model.SetTle(tle);
Julian date;
2011-04-05 23:56:17 +00:00
GeneratePassList(geo, sgp4_model, date);
2011-04-05 23:56:17 +00:00
return 0;
2011-03-27 23:29:11 +00:00
}
2011-04-05 23:56:17 +00:00
2011-04-07 14:15:47 +00:00
#if 0
http://olifantasia.com/projects/gnuradio/mdvh/weather_sat/weather_sat_scripts_without_capture_files_2010061701/decoding/poes-weather-hrpt-decoder/hrpt-decoder-1.0.0.2/satellite/predict/
xmnpda = 1440.0
/* same formulas, but the one from predict is nicer */
//sat->footprint = 2.0 * xkmper * acos (xkmper/sat->pos.w);
sat->footprint = 12756.33 * acos (xkmper / (xkmper+sat->alt));
age = sat->jul_utc - sat->jul_epoch;
sat->orbit = (long) floor((sat->tle.xno * xmnpda/twopi +
age * sat->tle.bstar * ae) * age +
sat->tle.xmo/twopi) + sat->tle.revnum - 1;
bool TSat::IsGeostationary(void)
{
/* This function returns a 1 if the satellite
appears to be in a geostationary orbit
Circular orbit at an altitude of 35 800 km over the equator.
A satellite moving with the Earth's rotation in a geostationary
orbit has a period of 23 hours, 56 minutes and 4 seconds.
*/
double sma, aalt;
if(meanmo == 0.0)
return true;
sma = 331.25*exp(log(1440.0/meanmo)*(2.0/3.0));
aalt = sma*(1.0+eccn)-xkmper;
if(fabs(meanmo-omega_E) < 0.0005 || // allmost same speed as earth
aalt > 35000) // altitude is over 35000 km
return true;
else
return false;
}
// latitude in radians
bool TSat::DoesRise(double lat)
{
/* This function returns a true if the satellite can ever rise
above the horizon of the ground station.
*/
double lin, sma, apogee;
bool rc = false;
if(meanmo == 0.0)
return rc;
else {
lin = incl;
if(lin >= 90.0)
lin=180.0-lin;
sma = 331.25*exp(log(1440.0/meanmo)*(2.0/3.0));
apogee = sma*(1.0+eccn)-xkmper;
if((acos2(xkmper/(apogee+xkmper))+lin*deg2rad) > fabs(lat))
rc = true;
else
rc = false;
}
return rc;
}
#endif