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