1 |
mocchiut |
1.1 |
// |
2 |
|
|
// stdafx.h |
3 |
|
|
// |
4 |
|
|
#ifndef sgp4_h |
5 |
|
|
#define sgp4_h |
6 |
|
|
|
7 |
|
|
#if !defined(__CINT__) || defined(__MAKECINT__) |
8 |
|
|
|
9 |
|
|
//#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers |
10 |
|
|
#include <stdio.h> |
11 |
|
|
//#include <tchar.h> |
12 |
|
|
#include <ctype.h> |
13 |
|
|
#include <string> |
14 |
|
|
#include <map> |
15 |
|
|
#include <vector> |
16 |
|
|
#include <algorithm> |
17 |
|
|
#include <assert.h> |
18 |
|
|
#include <time.h> |
19 |
|
|
#include <math.h> |
20 |
|
|
|
21 |
|
|
using namespace std; |
22 |
|
|
// |
23 |
|
|
// globals.h |
24 |
|
|
// |
25 |
|
|
|
26 |
|
|
const double PI = 3.141592653589793; |
27 |
|
|
const double TWOPI = 2.0 * PI; |
28 |
|
|
const double RADS_PER_DEG = PI / 180.0; |
29 |
|
|
|
30 |
|
|
const double GM = 398601.2; // Earth gravitational constant, km^3/sec^2 |
31 |
|
|
const double GEOSYNC_ALT = 42241.892; // km |
32 |
|
|
const double EARTH_DIA = 12800.0; // km |
33 |
|
|
const double DAY_SIDERAL = (23 * 3600) + (56 * 60) + 4.09; // sec |
34 |
|
|
const double DAY_24HR = (24 * 3600); // sec |
35 |
|
|
|
36 |
|
|
const double AE = 1.0; |
37 |
|
|
const double AU = 149597870.0; // Astronomical unit (km) (IAU 76) |
38 |
|
|
const double SR = 696000.0; // Solar radius (km) (IAU 76) |
39 |
|
|
const double TWOTHRD = 2.0 / 3.0; |
40 |
|
|
const double XKMPER_WGS72 = 6378.135; // Earth equatorial radius - km (WGS '72) |
41 |
|
|
const double F = 1.0 / 298.26; // Earth flattening (WGS '72) |
42 |
|
|
const double GE = 398600.8; // Earth gravitational constant (WGS '72) |
43 |
|
|
const double J2 = 1.0826158E-3; // J2 harmonic (WGS '72) |
44 |
|
|
const double J3 = -2.53881E-6; // J3 harmonic (WGS '72) |
45 |
|
|
const double J4 = -1.65597E-6; // J4 harmonic (WGS '72) |
46 |
|
|
const double CK2 = J2 / 2.0; |
47 |
|
|
const double CK4 = -3.0 * J4 / 8.0; |
48 |
|
|
const double XJ3 = J3; |
49 |
|
|
const double E6A = 1.0e-06; |
50 |
|
|
const double QO = AE + 120.0 / XKMPER_WGS72; |
51 |
|
|
const double S = AE + 78.0 / XKMPER_WGS72; |
52 |
|
|
const double HR_PER_DAY = 24.0; // Hours per day (solar) |
53 |
|
|
const double MIN_PER_DAY = 1440.0; // Minutes per day (solar) |
54 |
|
|
const double SEC_PER_DAY = 86400.0; // Seconds per day (solar) |
55 |
|
|
const double OMEGA_E = 1.00273790934; // earth rotation per sideral day |
56 |
|
|
const double XKE = sqrt(3600.0 * GE / //sqrt(ge) ER^3/min^2 |
57 |
|
|
(XKMPER_WGS72 * XKMPER_WGS72 * XKMPER_WGS72)); |
58 |
|
|
const double QOMS2T = pow((QO - S), 4); //(QO - S)^4 ER^4 |
59 |
|
|
|
60 |
|
|
// Utility functions |
61 |
|
|
double sqr (const double x); |
62 |
|
|
double Fmod2p(const double arg); |
63 |
|
|
double AcTan (const double sinx, double cosx); |
64 |
|
|
|
65 |
|
|
double rad2deg(const double); |
66 |
|
|
double deg2rad(const double); |
67 |
|
|
// |
68 |
|
|
// coord.h |
69 |
|
|
// |
70 |
|
|
// Copyright 2002-2003 Michael F. Henry |
71 |
|
|
// |
72 |
|
|
////////////////////////////////////////////////////////////////////// |
73 |
|
|
// Geocentric coordinates. |
74 |
|
|
class cCoordGeo |
75 |
|
|
{ |
76 |
|
|
public: |
77 |
|
|
cCoordGeo(); |
78 |
|
|
cCoordGeo(double lat, double lon, double alt) : |
79 |
|
|
m_Lat(lat), m_Lon(lon), m_Alt(alt) {} |
80 |
|
|
virtual ~cCoordGeo() {}; |
81 |
|
|
|
82 |
|
|
double m_Lat; // Latitude, radians (negative south) |
83 |
|
|
double m_Lon; // Longitude, radians (negative west) |
84 |
|
|
double m_Alt; // Altitude, km (above mean sea level) |
85 |
|
|
}; |
86 |
|
|
|
87 |
|
|
////////////////////////////////////////////////////////////////////// |
88 |
|
|
// Topocentric-Horizon coordinates. |
89 |
|
|
class cCoordTopo |
90 |
|
|
{ |
91 |
|
|
public: |
92 |
|
|
cCoordTopo(); |
93 |
|
|
cCoordTopo(double az, double el, double rng, double rate) : |
94 |
|
|
m_Az(az), m_El(el), m_Range(rng), m_RangeRate(rate) {} |
95 |
|
|
virtual ~cCoordTopo() {}; |
96 |
|
|
|
97 |
|
|
double m_Az; // Azimuth, radians |
98 |
|
|
double m_El; // Elevation, radians |
99 |
|
|
double m_Range; // Range, kilometers |
100 |
|
|
double m_RangeRate; // Range rate of change, km/sec |
101 |
|
|
// Negative value means "towards observer" |
102 |
|
|
}; |
103 |
|
|
|
104 |
|
|
// cVector.h: interface for the cVector class. |
105 |
|
|
// |
106 |
|
|
// Copyright 2003 (c) Michael F. Henry |
107 |
|
|
// |
108 |
|
|
////////////////////////////////////////////////////////////////////// |
109 |
|
|
|
110 |
|
|
class cVector |
111 |
|
|
{ |
112 |
|
|
public: |
113 |
|
|
cVector(double x = 0.0, double y = 0.0, double z = 0.0, double w = 0.0) : |
114 |
|
|
m_x(x), m_y(y), m_z(z), m_w(w) {} |
115 |
|
|
virtual ~cVector() {}; |
116 |
|
|
|
117 |
|
|
void Sub(const cVector&); // subtraction |
118 |
|
|
void Mul(double factor); // multiply each component by 'factor' |
119 |
|
|
|
120 |
|
|
double Angle(const cVector&) const; // angle between two vectors |
121 |
|
|
double Magnitude() const; // vector magnitude |
122 |
|
|
double Dot(const cVector& vec) const; // dot product |
123 |
|
|
|
124 |
|
|
// protected: |
125 |
|
|
double m_x; |
126 |
|
|
double m_y; |
127 |
|
|
double m_z; |
128 |
|
|
double m_w; |
129 |
|
|
}; |
130 |
|
|
// |
131 |
|
|
// cTle.h |
132 |
|
|
// |
133 |
|
|
// This class will accept a single set of two-line elements and then allow |
134 |
|
|
// a client to request specific fields, such as epoch, mean motion, |
135 |
|
|
// etc., from the set. |
136 |
|
|
// |
137 |
|
|
// Copyright 1996-2003 Michael F. Henry |
138 |
|
|
// |
139 |
|
|
///////////////////////////////////////////////////////////////////////////// |
140 |
|
|
class cTle |
141 |
|
|
{ |
142 |
|
|
public: |
143 |
|
|
cTle(string&, string&, string&); |
144 |
|
|
cTle(const cTle &tle); |
145 |
|
|
~cTle(); |
146 |
|
|
|
147 |
|
|
enum eTleLine |
148 |
|
|
{ |
149 |
|
|
LINE_ZERO, |
150 |
|
|
LINE_ONE, |
151 |
|
|
LINE_TWO |
152 |
|
|
}; |
153 |
|
|
|
154 |
|
|
enum eField |
155 |
|
|
{ |
156 |
|
|
FLD_FIRST, |
157 |
|
|
FLD_NORADNUM = FLD_FIRST, |
158 |
|
|
FLD_INTLDESC, |
159 |
|
|
FLD_SET, // TLE set number |
160 |
|
|
FLD_EPOCHYEAR, // Epoch: Last two digits of year |
161 |
|
|
FLD_EPOCHDAY, // Epoch: Fractional Julian Day of year |
162 |
|
|
FLD_ORBITNUM, // Orbit at epoch |
163 |
|
|
FLD_I, // Inclination |
164 |
|
|
FLD_RAAN, // R.A. ascending node |
165 |
|
|
FLD_E, // Eccentricity |
166 |
|
|
FLD_ARGPER, // Argument of perigee |
167 |
|
|
FLD_M, // Mean anomaly |
168 |
|
|
FLD_MMOTION, // Mean motion |
169 |
|
|
FLD_MMOTIONDT, // First time derivative of mean motion |
170 |
|
|
FLD_MMOTIONDT2,// Second time derivative of mean motion |
171 |
|
|
FLD_BSTAR, // BSTAR Drag |
172 |
|
|
FLD_LAST // MUST be last |
173 |
|
|
}; |
174 |
|
|
|
175 |
|
|
enum eUnits |
176 |
|
|
{ |
177 |
|
|
U_FIRST, |
178 |
|
|
U_RAD = U_FIRST, // radians |
179 |
|
|
U_DEG, // degrees |
180 |
|
|
U_NATIVE, // TLE format native units (no conversion) |
181 |
|
|
U_LAST // MUST be last |
182 |
|
|
}; |
183 |
|
|
|
184 |
|
|
void Initialize(); |
185 |
|
|
|
186 |
|
|
static int CheckSum(const string&); |
187 |
|
|
static bool IsValidLine(string&, eTleLine); |
188 |
|
|
static string ExpToDecimal(const string&); |
189 |
|
|
|
190 |
|
|
static void TrimLeft(string&); |
191 |
|
|
static void TrimRight(string&); |
192 |
|
|
|
193 |
|
|
double getField(eField fld, // which field to retrieve |
194 |
|
|
eUnits unit = U_NATIVE, // return units in rad, deg etc. |
195 |
|
|
string *pstr = NULL, // return ptr for str value |
196 |
|
|
bool bStrUnits = false) // 'true': append units to str val |
197 |
|
|
const; |
198 |
|
|
string getName() const { return m_strName; } |
199 |
|
|
string getLine1() const { return m_strLine1;} |
200 |
|
|
string getLine2() const { return m_strLine2;} |
201 |
|
|
|
202 |
|
|
protected: |
203 |
|
|
static double ConvertUnits(double val, eField fld, eUnits units); |
204 |
|
|
|
205 |
|
|
private: |
206 |
|
|
string getUnits(eField) const; |
207 |
|
|
double getFieldNumeric(eField) const; |
208 |
|
|
|
209 |
|
|
// Satellite name and two data lines |
210 |
|
|
string m_strName; |
211 |
|
|
string m_strLine1; |
212 |
|
|
string m_strLine2; |
213 |
|
|
|
214 |
|
|
// Converted fields, in atof()-readable form |
215 |
|
|
string m_Field[FLD_LAST]; |
216 |
|
|
|
217 |
|
|
// Cache of field values in "double" format |
218 |
|
|
typedef int FldKey; |
219 |
|
|
FldKey Key(eUnits u, eField f) const { return (u * 100) + f; } |
220 |
|
|
mutable map<FldKey, double> m_mapCache; |
221 |
|
|
}; |
222 |
|
|
|
223 |
|
|
/////////////////////////////////////////////////////////////////////////// |
224 |
|
|
// |
225 |
|
|
// TLE data format |
226 |
|
|
// |
227 |
|
|
// [Reference: T.S. Kelso] |
228 |
|
|
// |
229 |
|
|
// Two line element data consists of three lines in the following format: |
230 |
|
|
// |
231 |
|
|
// AAAAAAAAAAAAAAAAAAAAAA |
232 |
|
|
// 1 NNNNNU NNNNNAAA NNNNN.NNNNNNNN +.NNNNNNNN +NNNNN-N +NNNNN-N N NNNNN |
233 |
|
|
// 2 NNNNN NNN.NNNN NNN.NNNN NNNNNNN NNN.NNNN NNN.NNNN NN.NNNNNNNNNNNNNN |
234 |
|
|
// |
235 |
|
|
// Line 0 is a twenty-two-character name. |
236 |
|
|
// |
237 |
|
|
// Lines 1 and 2 are the standard Two-Line Orbital Element Set Format identical |
238 |
|
|
// to that used by NORAD and NASA. The format description is: |
239 |
|
|
// |
240 |
|
|
// Line 1 |
241 |
|
|
// Column Description |
242 |
|
|
// 01-01 Line Number of Element Data |
243 |
|
|
// 03-07 Satellite Number |
244 |
|
|
// 10-11 International Designator (Last two digits of launch year) |
245 |
|
|
// 12-14 International Designator (Launch number of the year) |
246 |
|
|
// 15-17 International Designator (Piece of launch) |
247 |
|
|
// 19-20 Epoch Year (Last two digits of year) |
248 |
|
|
// 21-32 Epoch (Julian Day and fractional portion of the day) |
249 |
|
|
// 34-43 First Time Derivative of the Mean Motion |
250 |
|
|
// or Ballistic Coefficient (Depending on ephemeris type) |
251 |
|
|
// 45-52 Second Time Derivative of Mean Motion (decimal point assumed; |
252 |
|
|
// blank if N/A) |
253 |
|
|
// 54-61 BSTAR drag term if GP4 general perturbation theory was used. |
254 |
|
|
// Otherwise, radiation pressure coefficient. (Decimal point assumed) |
255 |
|
|
// 63-63 Ephemeris type |
256 |
|
|
// 65-68 Element number |
257 |
|
|
// 69-69 Check Sum (Modulo 10) |
258 |
|
|
// (Letters, blanks, periods, plus signs = 0; minus signs = 1) |
259 |
|
|
// |
260 |
|
|
// Line 2 |
261 |
|
|
// Column Description |
262 |
|
|
// 01-01 Line Number of Element Data |
263 |
|
|
// 03-07 Satellite Number |
264 |
|
|
// 09-16 Inclination [Degrees] |
265 |
|
|
// 18-25 Right Ascension of the Ascending Node [Degrees] |
266 |
|
|
// 27-33 Eccentricity (decimal point assumed) |
267 |
|
|
// 35-42 Argument of Perigee [Degrees] |
268 |
|
|
// 44-51 Mean Anomaly [Degrees] |
269 |
|
|
// 53-63 Mean Motion [Revs per day] |
270 |
|
|
// 64-68 Revolution number at epoch [Revs] |
271 |
|
|
// 69-69 Check Sum (Modulo 10) |
272 |
|
|
// |
273 |
|
|
// All other columns are blank or fixed. |
274 |
|
|
// |
275 |
|
|
// Example: |
276 |
|
|
// |
277 |
|
|
// NOAA 6 |
278 |
|
|
// 1 11416U 86 50.28438588 0.00000140 67960-4 0 5293 |
279 |
|
|
// 2 11416 98.5105 69.3305 0012788 63.2828 296.9658 14.24899292346978 |
280 |
|
|
|
281 |
|
|
// |
282 |
|
|
// cJulian.h |
283 |
|
|
// |
284 |
|
|
// Copyright (c) 2003 Michael F. Henry |
285 |
|
|
// |
286 |
|
|
// |
287 |
|
|
// See note in cJulian.cpp for information on this class and the epoch dates |
288 |
|
|
// |
289 |
|
|
const double EPOCH_JAN1_00H_1900 = 2415019.5; // Jan 1.0 1900 = Jan 1 1900 00h UTC |
290 |
|
|
const double EPOCH_JAN1_12H_1900 = 2415020.0; // Jan 1.5 1900 = Jan 1 1900 12h UTC |
291 |
|
|
const double EPOCH_JAN1_12H_2000 = 2451545.0; // Jan 1.5 2000 = Jan 1 2000 12h UTC |
292 |
|
|
|
293 |
|
|
////////////////////////////////////////////////////////////////////////////// |
294 |
|
|
class cJulian |
295 |
|
|
{ |
296 |
|
|
public: |
297 |
|
|
cJulian() { Initialize(2000, 1); } |
298 |
|
|
explicit cJulian(time_t t); // Create from time_t |
299 |
|
|
explicit cJulian(int year, double day); // Create from year, day of year |
300 |
|
|
explicit cJulian(int year, // i.e., 2004 |
301 |
|
|
int mon, // 1..12 |
302 |
|
|
int day, // 1..31 |
303 |
|
|
int hour, // 0..23 |
304 |
|
|
int min, // 0..59 |
305 |
|
|
double sec = 0.0); // 0..(59.999999...) |
306 |
|
|
~cJulian() {}; |
307 |
|
|
|
308 |
|
|
double toGMST() const; // Greenwich Mean Sidereal Time |
309 |
|
|
double toLMST(double lon) const; // Local Mean Sideral Time |
310 |
|
|
time_t toTime() const; // To time_t type - avoid using |
311 |
|
|
|
312 |
|
|
double FromJan1_00h_1900() const { return m_Date - EPOCH_JAN1_00H_1900; } |
313 |
|
|
double FromJan1_12h_1900() const { return m_Date - EPOCH_JAN1_12H_1900; } |
314 |
|
|
double FromJan1_12h_2000() const { return m_Date - EPOCH_JAN1_12H_2000; } |
315 |
|
|
|
316 |
|
|
void getComponent(int *pYear, int *pMon = NULL, double *pDOM = NULL) const; |
317 |
|
|
double getDate() const { return m_Date; } |
318 |
|
|
|
319 |
|
|
void addDay (double day) { m_Date += day; } |
320 |
|
|
void addHour(double hr ) { m_Date += (hr / HR_PER_DAY ); } |
321 |
|
|
void addMin (double min) { m_Date += (min / MIN_PER_DAY); } |
322 |
|
|
void addSec (double sec) { m_Date += (sec / SEC_PER_DAY); } |
323 |
|
|
|
324 |
|
|
double spanDay (const cJulian& b) const { return m_Date - b.m_Date; } |
325 |
|
|
double spanHour(const cJulian& b) const { return spanDay(b) * HR_PER_DAY; } |
326 |
|
|
double spanMin (const cJulian& b) const { return spanDay(b) * MIN_PER_DAY; } |
327 |
|
|
double spanSec (const cJulian& b) const { return spanDay(b) * SEC_PER_DAY; } |
328 |
|
|
|
329 |
|
|
static bool IsLeapYear(int y) |
330 |
|
|
{ return (y % 4 == 0 && y % 100 != 0) || (y % 400 == 0); } |
331 |
|
|
|
332 |
|
|
protected: |
333 |
|
|
void Initialize(int year, double day); |
334 |
|
|
|
335 |
|
|
double m_Date; // Julian date |
336 |
|
|
}; |
337 |
|
|
// |
338 |
|
|
// cEci.h |
339 |
|
|
// |
340 |
|
|
// Copyright (c) 2003 Michael F. Henry |
341 |
|
|
// |
342 |
|
|
////////////////////////////////////////////////////////////////////// |
343 |
|
|
// class cEci |
344 |
|
|
// Encapsulates an Earth-Centered Inertial position, velocity, and time. |
345 |
|
|
class cEci |
346 |
|
|
{ |
347 |
|
|
public: |
348 |
|
|
cEci() { m_VecUnits = UNITS_NONE; } |
349 |
|
|
cEci(const cCoordGeo &geo, const cJulian &cJulian); |
350 |
|
|
cEci(const cVector &pos, const cVector &vel, |
351 |
|
|
const cJulian &date, bool IsAeUnits = true); |
352 |
|
|
virtual ~cEci() {}; |
353 |
|
|
|
354 |
|
|
cCoordGeo toGeo(); |
355 |
|
|
|
356 |
|
|
cVector getPos() const { return m_pos; } |
357 |
|
|
cVector getVel() const { return m_vel; } |
358 |
|
|
cJulian getDate() const { return m_date; } |
359 |
|
|
|
360 |
|
|
void setUnitsAe() { m_VecUnits = UNITS_AE; } |
361 |
|
|
void setUnitsKm() { m_VecUnits = UNITS_KM; } |
362 |
|
|
bool UnitsAreAe() const { return m_VecUnits == UNITS_AE; } |
363 |
|
|
bool UnitsAreKm() const { return m_VecUnits == UNITS_KM; } |
364 |
|
|
void ae2km(); // Convert position, velocity vector units from AE to km |
365 |
|
|
|
366 |
|
|
protected: |
367 |
|
|
void MulPos(double factor) { m_pos.Mul(factor); } |
368 |
|
|
void MulVel(double factor) { m_vel.Mul(factor); } |
369 |
|
|
|
370 |
|
|
enum VecUnits |
371 |
|
|
{ |
372 |
|
|
UNITS_NONE, // not initialized |
373 |
|
|
UNITS_AE, |
374 |
|
|
UNITS_KM |
375 |
|
|
}; |
376 |
|
|
|
377 |
|
|
cVector m_pos; |
378 |
|
|
cVector m_vel; |
379 |
|
|
cJulian m_date; |
380 |
|
|
VecUnits m_VecUnits; |
381 |
|
|
}; |
382 |
|
|
// |
383 |
|
|
// cNoradBase.h |
384 |
|
|
// |
385 |
|
|
// This class provides a base class for the NORAD SGP4/SDP4 |
386 |
|
|
// orbit models. |
387 |
|
|
// |
388 |
|
|
// Copyright (c) 2003 Michael F. Henry |
389 |
|
|
// |
390 |
|
|
#pragma once |
391 |
|
|
|
392 |
|
|
////////////////////////////////////////////////////////////////////////////// |
393 |
|
|
|
394 |
|
|
class cEci; |
395 |
|
|
class cOrbit; |
396 |
|
|
|
397 |
|
|
////////////////////////////////////////////////////////////////////////////// |
398 |
|
|
|
399 |
|
|
class cNoradBase |
400 |
|
|
{ |
401 |
|
|
public: |
402 |
|
|
cNoradBase(const cOrbit&); |
403 |
|
|
virtual ~cNoradBase() {}; |
404 |
|
|
|
405 |
|
|
virtual bool getPosition(double tsince, cEci &eci) = 0; |
406 |
|
|
|
407 |
|
|
protected: |
408 |
|
|
cNoradBase& operator=(const cNoradBase&); |
409 |
|
|
|
410 |
|
|
void Initialize(); |
411 |
|
|
bool FinalPosition(double incl, double omega, double e, |
412 |
|
|
double a, double xl, double xnode, |
413 |
|
|
double xn, double tsince, cEci &eci); |
414 |
|
|
|
415 |
|
|
const cOrbit &m_Orbit; |
416 |
|
|
|
417 |
|
|
// Orbital parameter variables which need only be calculated one |
418 |
|
|
// time for a given orbit (ECI position time-independent). |
419 |
|
|
double m_satInc; // inclination |
420 |
|
|
double m_satEcc; // eccentricity |
421 |
|
|
|
422 |
|
|
double m_cosio; double m_theta2; double m_x3thm1; double m_eosq; |
423 |
|
|
double m_betao2; double m_betao; double m_aodp; double m_xnodp; |
424 |
|
|
double m_s4; double m_qoms24; double m_perigee; double m_tsi; |
425 |
|
|
double m_eta; double m_etasq; double m_eeta; double m_coef; |
426 |
|
|
double m_coef1; double m_c1; double m_c2; double m_c3; |
427 |
|
|
double m_c4; double m_sinio; double m_a3ovk2; double m_x1mth2; |
428 |
|
|
double m_xmdot; double m_omgdot; double m_xhdot1; double m_xnodot; |
429 |
|
|
double m_xnodcf; double m_t2cof; double m_xlcof; double m_aycof; |
430 |
|
|
double m_x7thm1; |
431 |
|
|
}; |
432 |
|
|
// |
433 |
|
|
// cOrbit.h |
434 |
|
|
// |
435 |
|
|
// This is the header file for the class cOrbit. This class accepts a |
436 |
|
|
// single satellite's NORAD two-line element set and provides information |
437 |
|
|
// regarding the satellite's orbit such as period, axis length, |
438 |
|
|
// ECI coordinates/velocity, etc., using the SGP4/SDP4 orbital models. |
439 |
|
|
// |
440 |
|
|
// Copyright (c) 2002-2003 Michael F. Henry |
441 |
|
|
// |
442 |
|
|
#pragma once |
443 |
|
|
|
444 |
|
|
#include "math.h" |
445 |
|
|
|
446 |
|
|
using namespace std; |
447 |
|
|
////////////////////////////////////////////////////////////////////////////// |
448 |
|
|
|
449 |
|
|
class cVector; |
450 |
|
|
class cGeoCoord; |
451 |
|
|
class cEci; |
452 |
|
|
|
453 |
|
|
////////////////////////////////////////////////////////////////////////////// |
454 |
|
|
class cOrbit |
455 |
|
|
{ |
456 |
|
|
public: |
457 |
|
|
cOrbit(const cTle &tle); |
458 |
|
|
virtual ~cOrbit(); |
459 |
|
|
|
460 |
|
|
// Return satellite ECI data at given minutes since element's epoch. |
461 |
|
|
bool getPosition(double tsince, cEci *pEci) const; |
462 |
|
|
|
463 |
|
|
double Inclination() const { return radGet(cTle::FLD_I); } |
464 |
|
|
double Eccentricity() const { return m_tle.getField(cTle::FLD_E); } |
465 |
|
|
double RAAN() const { return radGet(cTle::FLD_RAAN); } |
466 |
|
|
double ArgPerigee() const { return radGet(cTle::FLD_ARGPER); } |
467 |
|
|
double BStar() const { return m_tle.getField(cTle::FLD_BSTAR) / AE;} |
468 |
|
|
double Drag() const { return m_tle.getField(cTle::FLD_MMOTIONDT); } |
469 |
|
|
double mnMotion() const { return m_tle.getField(cTle::FLD_MMOTION); } |
470 |
|
|
double mnAnomaly() const { return radGet(cTle::FLD_M); } |
471 |
|
|
double mnAnomaly(cJulian t) const; // mean anomaly (in radians) at time t |
472 |
|
|
|
473 |
|
|
cJulian Epoch() const { return m_jdEpoch; } |
474 |
|
|
|
475 |
|
|
double TPlusEpoch(const cJulian &t) const; // time span [t - epoch] in secs |
476 |
|
|
|
477 |
|
|
string SatName(bool fAppendId = false) const; |
478 |
|
|
|
479 |
|
|
// "Recovered" from the input elements |
480 |
|
|
double SemiMajor() const { return m_aeAxisSemiMajorRec; } |
481 |
|
|
double SemiMinor() const { return m_aeAxisSemiMinorRec; } |
482 |
|
|
double mnMotionRec() const { return m_mnMotionRec; } // mn motion, rads/min |
483 |
|
|
double Major() const { return 2.0 * SemiMajor(); } // major axis in AE |
484 |
|
|
double Minor() const { return 2.0 * SemiMinor(); } // minor axis in AE |
485 |
|
|
double Perigee() const { return m_kmPerigeeRec; } // perigee in km |
486 |
|
|
double Apogee() const { return m_kmApogeeRec; } // apogee in km |
487 |
|
|
double Period() const; // period in seconds |
488 |
|
|
|
489 |
|
|
protected: |
490 |
|
|
double radGet(cTle::eField fld) const |
491 |
|
|
{ return m_tle.getField(fld, cTle::U_RAD); } |
492 |
|
|
|
493 |
|
|
double degGet(cTle::eField fld) const |
494 |
|
|
{ return m_tle.getField(fld, cTle::U_DEG); } |
495 |
|
|
|
496 |
|
|
private: |
497 |
|
|
cTle m_tle; |
498 |
|
|
cJulian m_jdEpoch; |
499 |
|
|
cNoradBase *m_pNoradModel; |
500 |
|
|
|
501 |
|
|
// Caching variables; note units are not necessarily the same as tle units |
502 |
|
|
mutable double m_secPeriod; |
503 |
|
|
|
504 |
|
|
// Caching variables recovered from the input TLE elements |
505 |
|
|
double m_aeAxisSemiMinorRec; // semi-minor axis, in AE units |
506 |
|
|
double m_aeAxisSemiMajorRec; // semi-major axis, in AE units |
507 |
|
|
double m_mnMotionRec; // radians per minute |
508 |
|
|
double m_kmPerigeeRec; // perigee, in km |
509 |
|
|
double m_kmApogeeRec; // apogee, in km |
510 |
|
|
}; |
511 |
|
|
|
512 |
|
|
// |
513 |
|
|
// cNoradSGP4.h |
514 |
|
|
// |
515 |
|
|
// This class implements the NORAD Simple General Perturbation 4 orbit |
516 |
|
|
// model. This model provides the ECI coordiantes/velocity of satellites |
517 |
|
|
// with orbit periods less than 225 minutes. |
518 |
|
|
// |
519 |
|
|
// Copyright (c) 2003 Michael F. Henry |
520 |
|
|
// |
521 |
|
|
#pragma once |
522 |
|
|
|
523 |
|
|
class cOrbit; |
524 |
|
|
|
525 |
|
|
////////////////////////////////////////////////////////////////////////////// |
526 |
|
|
class cNoradSGP4 : public cNoradBase |
527 |
|
|
{ |
528 |
|
|
public: |
529 |
|
|
cNoradSGP4(const cOrbit &orbit); |
530 |
|
|
virtual ~cNoradSGP4() {}; |
531 |
|
|
|
532 |
|
|
virtual bool getPosition(double tsince, cEci &eci); |
533 |
|
|
|
534 |
|
|
protected: |
535 |
|
|
double m_c5; |
536 |
|
|
double m_omgcof; |
537 |
|
|
double m_xmcof; |
538 |
|
|
double m_delmo; |
539 |
|
|
double m_sinmo; |
540 |
|
|
}; |
541 |
|
|
|
542 |
|
|
// |
543 |
|
|
// cNoradSDP4.h |
544 |
|
|
// |
545 |
|
|
// This class implements the NORAD Simple Deep Perturbation 4 orbit |
546 |
|
|
// model. This model provides the ECI coordinates/velocity of satellites |
547 |
|
|
// with periods >= 225 minutes. |
548 |
|
|
// |
549 |
|
|
// Copyright (c) 2003 Michael F. Henry |
550 |
|
|
// |
551 |
|
|
#pragma once |
552 |
|
|
|
553 |
|
|
class cOrbit; |
554 |
|
|
|
555 |
|
|
////////////////////////////////////////////////////////////////////////////// |
556 |
|
|
class cNoradSDP4 : public cNoradBase |
557 |
|
|
{ |
558 |
|
|
public: |
559 |
|
|
cNoradSDP4(const cOrbit &orbit); |
560 |
|
|
virtual ~cNoradSDP4() {}; |
561 |
|
|
|
562 |
|
|
virtual bool getPosition(double tsince, cEci &eci); |
563 |
|
|
|
564 |
|
|
protected: |
565 |
|
|
bool DeepInit(double *eosq, double *sinio, double *cosio, double *m_betao, |
566 |
|
|
double *m_aodp, double *m_theta2, double *m_sing, double *m_cosg, |
567 |
|
|
double *m_betao2,double *xmdot, double *omgdot, double *xnodott); |
568 |
|
|
|
569 |
|
|
bool DeepSecular(double *xmdf, double *omgadf,double *xnode, double *emm, |
570 |
|
|
double *xincc, double *xnn, double *tsince); |
571 |
|
|
bool DeepCalcDotTerms (double *pxndot, double *pxnddt, double *pxldot); |
572 |
|
|
void DeepCalcIntegrator(double *pxndot, double *pxnddt, double *pxldot, |
573 |
|
|
const double &delt); |
574 |
|
|
bool DeepPeriodics(double *e, double *xincc, double *omgadf, |
575 |
|
|
double *xnode, double *xmam); |
576 |
|
|
double m_sing; |
577 |
|
|
double m_cosg; |
578 |
|
|
|
579 |
|
|
// Deep Initialization |
580 |
|
|
double eqsq; double siniq; double cosiq; double rteqsq; double ao; |
581 |
|
|
double cosq2; double sinomo; double cosomo; double bsq; double xlldot; |
582 |
|
|
double omgdt; double xnodot; |
583 |
|
|
|
584 |
|
|
// Deep Secular, Periodic |
585 |
|
|
double xll; double omgasm; double xnodes; double _em; |
586 |
|
|
double xinc; double xn; double t; |
587 |
|
|
|
588 |
|
|
// Variables shared by "Deep" routines |
589 |
|
|
double dp_e3; double dp_ee2; double dp_savtsn; double dp_se2; |
590 |
|
|
double dp_se3; double dp_sgh2; double dp_sgh3; double dp_sgh4; |
591 |
|
|
double dp_sghs; double dp_sh2; double dp_sh3; double dp_si2; |
592 |
|
|
double dp_si3; double dp_sl2; double dp_sl3; double dp_sl4; |
593 |
|
|
double dp_xgh2; double dp_xgh3; double dp_xgh4; double dp_xh2; |
594 |
|
|
double dp_xh3; double dp_xi2; double dp_xi3; double dp_xl2; |
595 |
|
|
double dp_xl3; double dp_xl4; double dp_xqncl; double dp_zmol; |
596 |
|
|
double dp_zmos; |
597 |
|
|
|
598 |
|
|
double dp_atime; double dp_d2201; double dp_d2211; double dp_d3210; |
599 |
|
|
double dp_d3222; double dp_d4410; double dp_d4422; double dp_d5220; |
600 |
|
|
double dp_d5232; double dp_d5421; double dp_d5433; double dp_del1; |
601 |
|
|
double dp_del2; double dp_del3; double dp_fasx2; double dp_fasx4; |
602 |
|
|
double dp_fasx6; double dp_omegaq; double dp_sse; double dp_ssg; |
603 |
|
|
double dp_ssh; double dp_ssi; double dp_ssl; double dp_step2; |
604 |
|
|
double dp_stepn; double dp_stepp; double dp_thgr; double dp_xfact; |
605 |
|
|
double dp_xlamo; double dp_xli; double dp_xni; |
606 |
|
|
|
607 |
|
|
bool dp_iresfl; |
608 |
|
|
bool dp_isynfl; |
609 |
|
|
|
610 |
|
|
// DeepInit vars that change with epoch |
611 |
|
|
double dpi_c; double dpi_ctem; double dpi_day; double dpi_gam; |
612 |
|
|
double dpi_stem; double dpi_xnodce; double dpi_zcosgl; double dpi_zcoshl; |
613 |
|
|
double dpi_zcosil; double dpi_zsingl; double dpi_zsinhl; double dpi_zsinil; |
614 |
|
|
double dpi_zx; double dpi_zy; |
615 |
|
|
|
616 |
|
|
}; |
617 |
|
|
|
618 |
|
|
#endif |
619 |
|
|
#endif |
620 |
|
|
|