perturb 1.0.0
A modern C++11 wrapper for the SGP4 orbit propagator
Loading...
Searching...
No Matches
sgp4.hpp
Go to the documentation of this file.
1#ifndef PERTURB_SGP4_HPP
2#define PERTURB_SGP4_HPP
3// clang-format off
4/* ----------------------------------------------------------------
5*
6* SGP4.h
7*
8* this file contains the sgp4 procedures for analytical propagation
9* of a satellite. the code was originally released in the 1980 and 1986
10* spacetrack papers. a detailed discussion of the theory and history
11* may be found in the 2006 aiaa paper by vallado, crawford, hujsak,
12* and kelso.
13*
14* current :
15* 12 mar 20 david vallado
16* chg satnum to string for alpha 5 or 9-digit
17* changes :
18* 7 dec 15 david vallado
19* fix jd, jdfrac
20* 3 nov 14 david vallado
21* update to msvs2013 c++
22* 30 Dec 11 david vallado
23* consolidate updated code version
24* 30 Aug 10 david vallado
25* delete unused variables in initl
26* replace pow inetger 2, 3 with multiplies for speed
27* 3 Nov 08 david vallado
28* put returns in for error codes
29* 29 sep 08 david vallado
30* fix atime for faster operation in dspace
31* add operationmode for afspc (a) or improved (i)
32* performance mode
33* 20 apr 07 david vallado
34* misc fixes for constants
35* 11 aug 06 david vallado
36* chg lyddane choice back to strn3, constants, misc doc
37* 15 dec 05 david vallado
38* misc fixes
39* 26 jul 05 david vallado
40* fixes for paper
41* note that each fix is preceded by a
42* comment with "sgp4fix" and an explanation of
43* what was changed
44* 10 aug 04 david vallado
45* 2nd printing baseline working
46* 14 may 01 david vallado
47* 2nd edition baseline
48* 80 norad
49* original baseline
50* ---------------------------------------------------------------- */
51
58
59// Define `PERTURB_SGP4_ENABLE_DEBUG` to enable Vallado's verification mode.
60// Generally, this is unwanted. Only enabled for tests.
61#if (defined(PERTURB_SGP4_ENABLE_DEBUG) && defined(PERTURB_DISABLE_IO))
62#error "Cannot enable SGP4 debug without I/O functionality"
63#endif
64
65// NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers, readability-magic-numbers
66// NOLINTBEGIN(readability-avoid-const-params-in-decls)
67
68// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
69#define PERTURB_SGP4_SGP4Version "SGP4 Version 2020-07-13"
70
71namespace perturb {
72
79namespace sgp4 {
80
81// -------------------------- structure declarations ----------------------------
82typedef enum // NOLINT(modernize-use-using)
83{
84 wgs72old,
85 wgs72,
86 wgs84
87} gravconsttype;
88
89typedef struct elsetrec // NOLINT(modernize-use-using,altera-struct-pack-align)
90{
91 char satnum[6];
92 int epochyr, epochtynumrev;
93 int error;
94 char operationmode;
95 char init, method;
96
97 /* Near Earth */
98 int isimp;
99 double aycof , con41 , cc1 , cc4 , cc5 , d2 , d3 , d4 ,
100 delmo , eta , argpdot, omgcof , sinmao , t , t2cof, t3cof ,
101 t4cof , t5cof , x1mth2 , x7thm1 , mdot , nodedot, xlcof , xmcof ,
102 nodecf;
103
104 /* Deep Space */
105 int irez;
106 double d2201 , d2211 , d3210 , d3222 , d4410 , d4422 , d5220 , d5232 ,
107 d5421 , d5433 , dedt , del1 , del2 , del3 , didt , dmdt ,
108 dnodt , domdt , e3 , ee2 , peo , pgho , pho , pinco ,
109 plo , se2 , se3 , sgh2 , sgh3 , sgh4 , sh2 , sh3 ,
110 si2 , si3 , sl2 , sl3 , sl4 , gsto , xfact , xgh2 ,
111 xgh3 , xgh4 , xh2 , xh3 , xi2 , xi3 , xl2 , xl3 ,
112 xl4 , xlamo , zmol , zmos , atime , xli , xni;
113
114 double a, altp, alta, epochdays, jdsatepoch, jdsatepochF, nddot, ndot,
115 bstar, rcse, inclo, nodeo, ecco, argpo, mo, no_kozai;
116 // sgp4fix add new variables from tle
117 char classification, intldesg[11];
118 int ephtype;
119 long elnum , revnum;
120 // sgp4fix add unkozai'd variable
121 double no_unkozai;
122 // sgp4fix add singly averaged variables
123 double am , em , im , Om , om , mm , nm;
124 // sgp4fix add constant parameters to eliminate mutliple calls during execution
125 double tumin, mus, radiusearthkm, xke, j2, j3, j4, j3oj2;
126
127 // Additional elements to capture relevant TLE and object information:
128 long dia_mm; // RSO dia in mm
129 double period_sec; // Period in seconds
130 unsigned char active; // "Active S/C" flag (0=n, 1=y)
131 unsigned char not_orbital; // "Orbiting S/C" flag (0=n, 1=y)
132 double rcs_m2; // "RCS (m^2)" storage
133
134} elsetrec;
135
136
137// namespace SGP4Funcs
138// {
139
140 // public class SGP4Class
141 // {
142
143 bool sgp4init
144 (
145 gravconsttype whichconst, char opsmode, const char satn[5], const double epoch,
146 const double xbstar, const double xndot, const double xnddot, const double xecco, const double xargpo,
147 const double xinclo, const double xmo, const double xno,
148 const double xnodeo, elsetrec& satrec
149 );
150
151 bool sgp4
152 (
153 // no longer need gravconsttype whichconst, all data contained in satrec
154 elsetrec& satrec, double tsince,
155 double r[3], double v[3]
156 );
157
158 void getgravconst
159 (
160 gravconsttype whichconst,
161 double& tumin,
162 double& mus,
163 double& radiusearthkm,
164 double& xke,
165 double& j2,
166 double& j3,
167 double& j4,
168 double& j3oj2
169 );
170
171#ifndef PERTURB_DISABLE_IO
172 // older sgp4io methods
173 void twoline2rv
174 (
175 char longstr1[130], char longstr2[130],
176 char typerun, char typeinput, char opsmode,
177 gravconsttype whichconst,
178 double& startmfe, double& stopmfe, double& deltamin,
179 elsetrec& satrec
180 );
181#endif // PERTURB_DISABLE_IO
182
183 // older sgp4ext methods
184 double gstime_SGP4
185 (
186 double jdut1
187 );
188
189 double sgn_SGP4
190 (
191 double x
192 );
193
194 double mag_SGP4
195 (
196 double x[3]
197 );
198
199 void cross_SGP4
200 (
201 double vec1[3], double vec2[3], double outvec[3]
202 );
203
204 double dot_SGP4
205 (
206 double x[3], double y[3]
207 );
208
209 double angle_SGP4
210 (
211 double vec1[3],
212 double vec2[3]
213 );
214
215 void newtonnu_SGP4
216 (
217 double ecc, double nu,
218 double& e0, double& m
219 );
220
221 double asinh_SGP4
222 (
223 double xval
224 );
225
226 void rv2coe_SGP4
227 (
228 double r[3], double v[3], double mus,
229 double& p, double& a, double& ecc, double& incl, double& omega, double& argp,
230 double& nu, double& m, double& arglat, double& truelon, double& lonper
231 );
232
233 void jday_SGP4
234 (
235 int year, int mon, int day, int hr, int minute, double sec,
236 double& jd, double& jdFrac
237 );
238
239 void days2mdhms_SGP4
240 (
241 int year, double days,
242 int& mon, int& day, int& hr, int& minute, double& sec
243 );
244
245 void invjday_SGP4
246 (
247 double jd, double jdFrac,
248 int& year, int& mon, int& day,
249 int& hr, int& minute, double& sec
250 );
251
252
253// } // namespace
254
255} // namespace sgp4
256} // namespace perturb
257
258// NOLINTEND(cppcoreguidelines-avoid-magic-numbers, readability-magic-numbers
259// NOLINTEND(readability-avoid-const-params-in-decls)
260// clang-format on
261
262#endif // PERTURB_SGP4_HPP
double mag_SGP4(double x[3])
Definition: sgp4.cpp:2565
void newtonnu_SGP4(double ecc, double nu, double &e0, double &m)
Definition: sgp4.cpp:2750
void getgravconst(gravconsttype whichconst, double &tumin, double &mus, double &radiusearthkm, double &xke, double &j2, double &j3, double &j4, double &j3oj2)
Definition: sgp4.cpp:2102
bool sgp4(elsetrec &satrec, double tsince, double r[3], double v[3])
Definition: sgp4.cpp:1770
void rv2coe_SGP4(double r[3], double v[3], double mus, double &p, double &a, double &ecc, double &incl, double &omega, double &argp, double &nu, double &m, double &arglat, double &truelon, double &lonper)
Definition: sgp4.cpp:2864
void twoline2rv(char longstr1[130], char longstr2[130], char typerun, char typeinput, char opsmode, gravconsttype whichconst, double &startmfe, double &stopmfe, double &deltamin, elsetrec &satrec)
Definition: sgp4.cpp:2202
double gstime_SGP4(double jdut1)
Definition: sgp4.cpp:2507
bool sgp4init(gravconsttype whichconst, char opsmode, const char satn[5], const double epoch, const double xbstar, const double xndot, const double xnddot, const double xecco, const double xargpo, const double xinclo, const double xmo, const double xno, const double xnodeo, elsetrec &satrec)
Definition: sgp4.cpp:1384
void invjday_SGP4(double jd, double jdFrac, int &year, int &mon, int &day, int &hr, int &minute, double &sec)
Definition: sgp4.cpp:3236
double asinh_SGP4(double xval)
Definition: sgp4.cpp:2706
double angle_SGP4(double vec1[3], double vec2[3])
Definition: sgp4.cpp:2660
void cross_SGP4(double vec1[3], double vec2[3], double outvec[3])
Definition: sgp4.cpp:2595
void jday_SGP4(int year, int mon, int day, int hr, int minute, double sec, double &jd, double &jdFrac)
Definition: sgp4.cpp:3101
void days2mdhms_SGP4(int year, double days, int &mon, int &day, int &hr, int &minute, double &sec)
Definition: sgp4.cpp:3162
double dot_SGP4(double x[3], double y[3])
Definition: sgp4.cpp:2628
Primary namespace for the perturb library, everything is in here.
Definition: perturb.hpp:32
Definition: sgp4.hpp:90