1 #ifndef _SDP4_H_
2 #define _SDP4_H_
3 
4 #include <predict/predict.h>
5 
6 struct model_output {
7 	double xinck; //inclination?
8 	double omgadf; //argument of perigee?
9 	double xnodek; //RAAN?
10 
11 	double pos[3];
12 	double vel[3];
13 
14 	double phase;
15 };
16 
17 
18 /**
19  * Parameters for deep space perturbations
20  **/
21 typedef struct	{
22 	/* Used by dpinit part of Deep() */
23 	double  eosq, sinio, cosio, betao, aodp, theta2,
24 	sing, cosg, betao2, xmdot, omgdot, xnodot, xnodp;
25 
26 	/* Used by thetg and Deep() */
27 	double  ds50;
28 }  deep_arg_fixed_t;
29 
30 /**
31  * Output from deep space perturbations.
32  **/
33 typedef struct {
34 	/* Moved from deep_arg_t. */
35 	/* Used by dpsec and dpper parts of Deep() */
36 	double  xll, omgadf, xnode, em, xinc, xn, t;
37 
38 	/* Previously a part of _sdp4, moved here. */
39 	double pl, pinc, pe, sh1, sghl, shs, savtsn, atime, xni, xli, sghs;
40 	///Do loop flag:
41 	int loopFlag;
42 	///Epoch restart flag:
43 	int epochRestartFlag;
44 } deep_arg_dynamic_t;
45 
46 
47 /**
48  * Parameters relevant for SDP4 (simplified deep space perturbations) orbital model.
49  **/
50 struct _sdp4 {
51 
52 	///Lunar terms done?
53 	int lunarTermsDone;
54 	///Resonance flag:
55 	int resonanceFlag;
56 	///Synchronous flag:
57 	int synchronousFlag;
58 
59 
60 	///Static variables from SDP4():
61 	double x3thm1, c1, x1mth2, c4, xnodcf, t2cof, xlcof,
62 	aycof, x7thm1;
63 	deep_arg_fixed_t deep_arg;
64 
65 	///Static variables from Deep():
66 	double thgr, xnq, xqncl, omegaq, zmol, zmos, ee2, e3,
67 	xi2, xl2, xl3, xl4, xgh2, xgh3, xgh4, xh2, xh3, sse, ssi, ssg, xi3,
68 	se2, si2, sl2, sgh2, sh2, se3, si3, sl3, sgh3, sh3, sl4, sgh4, ssl,
69 	ssh, d3210, d3222, d4410, d4422, d5220, d5232, d5421, d5433, del1,
70 	del2, del3, fasx2, fasx4, fasx6, xlamo, xfact, stepp,
71 	stepn, step2, preep, d2201, d2211,
72 	zsingl, zcosgl, zsinhl, zcoshl, zsinil, zcosil;
73 
74 	//converted fields from predict_orbital_elements_t.
75 	double xnodeo;
76 	double omegao;
77 	double xmo;
78 	double xincl;
79 	double eo;
80 	double xno;
81 	double bstar;
82 	double epoch;
83 };
84 
85 /**
86  * Initialize SDP4 model parameters.
87  *
88  * \param orbital_elements Orbital elements
89  * \param m Struct to initialize
90  **/
91 void sdp4_init(const predict_orbital_elements_t *orbital_elements, struct _sdp4 *m);
92 
93 /**
94  * Predict ECI position and velocity of deep-space orbit (period > 225 minutes) according to SDP4 model and the given orbital parameters.
95  *
96  * \param m SDP4 model parameters
97  * \param tsince Time since epoch of TLE in minutes
98  * \param output Modeled output parameters
99  * \copyright GPLv2+
100  **/
101 void sdp4_predict(const struct _sdp4 *m, double tsince, struct model_output *output);
102 
103 /**
104  * Deep space perturbations. Original Deep() function.
105  *
106  * \param m SDP4 model parameters
107  * \param ientry Behavior flag. 1: Deep space secular effects. 2: lunar-solar periodics
108  * \param deep_arg Fixed deep perturbation parameters
109  * \param deep_dyn Output of deep space perturbations
110  * \copyright GPLv2+
111  **/
112 void sdp4_deep(const struct _sdp4 *m, int ientry, const deep_arg_fixed_t * deep_arg, deep_arg_dynamic_t *deep_dyn);
113 
114 
115 #endif // ifndef _SDP4_H_
116