1 /*
2 * - - - - - - - - - - - - - -
3 * g a l _ i n i t s g p 4 p
4 * - - - - - - - - - - - - - -
5 *
6 * This routine is part of the General Astrodynamics Library
7 *
8 * Description:
9 *
10 * This routine initializes the spg4 propagator. All the initialization is
11 * consolidated here instead of having multiple loops inside other routines.
12 *
13 * Status:
14 *
15 * SGP4 support routine.
16 *
17 * Given:
18 *
19 * satn d Satellite NORAD Catalog Number
20 * *gm gal_gm_t Pointer to gravity model structure
21 * ecco d Eccentricity [0.0:1.0]
22 * epoch d Epoch time in days from Jan 0, 1950. 0 hr
23 * inclo d Inclination of satellite
24 * *no d Mean Motion of satellite
25 *
26 * Returned:
27 *
28 * *no d Mean Motion of satellite
29 * *method c Flag for deep space 'd', 'n'
30 * *ainv d 1.0 / a
31 * *ao d Semi Major Axis
32 * *con41 d
33 * *con42 d 1.0 - 5.0 cos(i)
34 * *cosio d Cosine of Inclination
35 * *cosio2 d cosio squared
36 * *eccsq d Eccentricity squared
37 * *omeosq d 1.0 - ecco * ecco
38 * *posq d Semi-parameter squared
39 * *rp d Radius of Perigee
40 * *rteosq d Square root of (1.0 - ecco*ecco)
41 * *sinio d Sine of inclination
42 * *gsto d GST at time of observation (rad)
43 *
44 * Notes:
45 *
46 * 1) This routine is a translation from c++ to c of David Vallado's SGP4UNIT.initl
47 * routine ( 2007 November 16 ).
48 *
49 * References:
50 *
51 * NORAD Spacetrack Report #3 1980
52 * Hoots, Roehrich
53 *
54 * NORAD Spacetrack Report #6 1986
55 * Hoots
56 *
57 * Hoots, Schumacher and Glover 2004
58 *
59 * Revisting Spacetrack Report #3
60 * Vallado, David, Crawford, Paul, Hujsak, Richard, Kelso, T.S.
61 * AIAA 2006-6753
62 *
63 * This revision:
64 *
65 * 2008 April 6
66 *
67 * Copyright (C) 2008 Paul C. L. Willmott. See notes at end.
68 *
69 *-----------------------------------------------------------------------
70 */
71
72 #include <math.h>
73 #include "gal_const.h"
74 #include "gal_initsgp4p.h"
75 #include "gal_gmst82.h"
76
77 void
gal_initsgp4p(int satn,gal_gm_t * gm,double ecco,double epoch,double inclo,double * no,char * method,double * ainv,double * ao,double * con41,double * con42,double * cosio,double * cosio2,double * eccsq,double * omeosq,double * posq,double * rp,double * rteosq,double * sinio,double * gsto)78 gal_initsgp4p
79 (
80 int satn,
81 gal_gm_t *gm,
82 double ecco,
83 double epoch,
84 double inclo,
85 double *no,
86 char *method,
87 double *ainv,
88 double *ao,
89 double *con41,
90 double *con42,
91 double *cosio,
92 double *cosio2,
93 double *eccsq,
94 double *omeosq,
95 double *posq,
96 double *rp,
97 double *rteosq,
98 double *sinio ,
99 double *gsto
100 )
101
102 {
103
104 double ak, d1, del, adel, po, x2o3, j2, xke,
105 tumin, mu, radiusearthkm, j3, j4, j3oj2 ;
106
107
108 double ts70, ds70, tfrac, c1, thgr70, fk5r, c1p2p ;
109 int ids70 ;
110
111 /*
112 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
113 */
114
115 /*
116 * Earth constants
117 */
118
119 gal_sgp4gm ( gm, &tumin, &mu, &radiusearthkm, &xke, &j2, &j3, &j4, &j3oj2 ) ;
120 x2o3 = 2.0 / 3.0 ;
121
122 /*
123 * Calculate auxillary epoch quantities
124 */
125
126 *eccsq = ecco * ecco ;
127 *omeosq = 1.0 - *eccsq ;
128 *rteosq = sqrt ( *omeosq ) ;
129 *cosio = cos ( inclo ) ;
130 *cosio2 = (*cosio) * (*cosio) ;
131
132 /*
133 * Un-Kozai the Mean Motion
134 */
135
136 ak = pow ( xke / *no, x2o3 ) ;
137 d1 = 0.75 * j2 * ( 3.0 * (*cosio2) - 1.0 ) / ( (*rteosq) * (*omeosq) ) ;
138 del = d1 / ( ak * ak ) ;
139 adel = ak * ( 1.0 - del * del - del * ( 1.0 / 3.0 + 134.0 * del * del / 81.0 ) ) ;
140 del = d1 / ( adel * adel ) ;
141 *no /= ( 1.0 + del ) ;
142
143 *ao = pow ( xke / *no, x2o3 ) ;
144 *sinio = sin ( inclo ) ;
145 po = (*ao) * (*omeosq) ;
146 *con42 = 1.0 - 5.0 * (*cosio2) ;
147 *con41 = -(*con42) - (*cosio2) - (*cosio2) ;
148 *ainv = 1.0 / (*ao) ;
149 *posq = (po) * (po) ;
150 *rp = (*ao) * ( 1.0 - ecco ) ;
151 *method = 'n' ;
152
153 /*
154 * Find greenwich location at epoch
155 */
156
157 /*
158 * Old way of finding gst
159 * count integer number of days from 0 jan 1970
160 * This is what AFSPC still uses apparently
161 */
162
163 ts70 = epoch - 7305.0 ;
164 ids70 = floor ( ts70 + 1.0e-8 ) ;
165 ds70 = ids70 ;
166 tfrac = ts70 - ds70 ;
167 c1 = 1.72027916940703639e-2 ;
168 thgr70 = 1.7321343856509374 ;
169 fk5r = 5.07551419432269442e-15 ;
170 c1p2p = c1 + GAL_2PI ;
171 *gsto = fmod ( thgr70 + c1 * ds70 + c1p2p * tfrac + ts70 * ts70 * fk5r, GAL_2PI ) ;
172 if ( *gsto < 0.0 ) {
173 *gsto += GAL_2PI ;
174 }
175
176 /* *gsto = gal_gmst82 ( 2433281.5, epoch ) ; */
177
178 /*
179 * Finished.
180 */
181
182 }
183
184 /*
185 * gal - General Astrodynamics Library
186 * Copyright (C) 2008 Paul C. L. Willmott
187 *
188 * This program is free software; you can redistribute it and/or modify
189 * it under the terms of the GNU General Public License as published by
190 * the Free Software Foundation; either version 2 of the License, or
191 * (at your option) any later version.
192 *
193 * This program is distributed in the hope that it will be useful,
194 * but WITHOUT ANY WARRANTY; without even the implied warranty of
195 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
196 * GNU General Public License for more details.
197 *
198 * You should have received a copy of the GNU General Public License along
199 * with this program; if not, write to the Free Software Foundation, Inc.,
200 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
201 *
202 * Contact:
203 *
204 * Paul Willmott
205 * vp9mu@amsat.org
206 */
207
208