ootk 1.0.6 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/sgp4.js CHANGED
@@ -30,8 +30,21 @@
30
30
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31
31
  * SOFTWARE.
32
32
  */
33
+ // NOTE: This file is meant to maintain as much of the original format as possible.
34
+ /* eslint-disable no-lonely-if */
35
+ /* eslint-disable prefer-destructuring */
36
+ /* eslint-disable complexity */
37
+ /* eslint-disable max-len */
38
+ /* eslint-disable no-param-reassign */
39
+ /* eslint-disable max-params */
40
+ /* eslint-disable no-shadow */
41
+ /* eslint-disable init-declarations */
42
+ /* eslint-disable max-statements */
43
+ /* eslint-disable max-lines-per-function */
44
+ /* eslint-disable max-lines */
33
45
  import { DEG2RAD, PI, TAU, temp4, x2o3 } from './utils/constants';
34
- /* ----------------------------------------------------------------
46
+ /*
47
+ * ----------------------------------------------------------------
35
48
  *
36
49
  * sgp4unit.cpp
37
50
  *
@@ -86,76 +99,79 @@ import { DEG2RAD, PI, TAU, temp4, x2o3 } from './utils/constants';
86
99
  * 2nd edition baseline
87
100
  * 80 norad
88
101
  * original baseline
89
- * ---------------------------------------------------------------- */
102
+ * ----------------------------------------------------------------
103
+ */
90
104
  var Sgp4 = /** @class */ (function () {
91
105
  function Sgp4() {
92
106
  }
93
- /* -----------------------------------------------------------------------------
94
- *
95
- * procedure dpper
96
- *
97
- * this procedure provides deep space long period periodic contributions
98
- * to the mean elements. by design, these periodics are zero at epoch.
99
- * this used to be dscom which included initialization, but it's really a
100
- * recurring function.
101
- *
102
- * author : david vallado 719-573-2600 28 jun 2005
103
- *
104
- * inputs :
105
- * e3 -
106
- * ee2 -
107
- * peo -
108
- * pgho -
109
- * pho -
110
- * PInco -
111
- * plo -
112
- * se2 , se3 , sgh2, sgh3, sgh4, sh2, sh3, si2, si3, sl2, sl3, sl4 -
113
- * t -
114
- * xh2, xh3, xi2, xi3, xl2, xl3, xl4 -
115
- * zmol -
116
- * zmos -
117
- * ep - eccentricity 0.0 - 1.0
118
- * inclo - inclination - needed for lyddane modification
119
- * nodep - right ascension of ascending node
120
- * argpp - argument of perigee
121
- * mp - mean anomaly
122
- *
123
- * outputs :
124
- * ep - eccentricity 0.0 - 1.0
125
- * inclp - inclination
126
- * nodep - right ascension of ascending node
127
- * argpp - argument of perigee
128
- * mp - mean anomaly
129
- *
130
- * locals :
131
- * alfdp -
132
- * betdp -
133
- * cosip , sinip , cosop , sinop ,
134
- * dalf -
135
- * dbet -
136
- * dls -
137
- * f2, f3 -
138
- * pe -
139
- * pgh -
140
- * ph -
141
- * PInc -
142
- * pl -
143
- * sel , ses , sghl , sghs , shl , shs , sil , sinzf , sis ,
144
- * sll , sls
145
- * xls -
146
- * xnoh -
147
- * zf -
148
- * zm -
149
- *
150
- * coupling :
151
- * none.
152
- *
153
- * references :
154
- * hoots, roehrich, norad spacetrack report #3 1980
155
- * hoots, norad spacetrack report #6 1986
156
- * hoots, schumacher and glover 2004
157
- * vallado, crawford, hujsak, kelso 2006
158
- ----------------------------------------------------------------------------*/
107
+ /*
108
+ * -----------------------------------------------------------------------------
109
+ *
110
+ * procedure dpper
111
+ *
112
+ * this procedure provides deep space long period periodic contributions
113
+ * to the mean elements. by design, these periodics are zero at epoch.
114
+ * this used to be dscom which included initialization, but it's really a
115
+ * recurring function.
116
+ *
117
+ * author : david vallado 719-573-2600 28 jun 2005
118
+ *
119
+ * inputs :
120
+ * e3 -
121
+ * ee2 -
122
+ * peo -
123
+ * pgho -
124
+ * pho -
125
+ * PInco -
126
+ * plo -
127
+ * se2 , se3 , sgh2, sgh3, sgh4, sh2, sh3, si2, si3, sl2, sl3, sl4 -
128
+ * t -
129
+ * xh2, xh3, xi2, xi3, xl2, xl3, xl4 -
130
+ * zmol -
131
+ * zmos -
132
+ * ep - eccentricity 0.0 - 1.0
133
+ * inclo - inclination - needed for lyddane modification
134
+ * nodep - right ascension of ascending node
135
+ * argpp - argument of perigee
136
+ * mp - mean anomaly
137
+ *
138
+ * outputs :
139
+ * ep - eccentricity 0.0 - 1.0
140
+ * inclp - inclination
141
+ * nodep - right ascension of ascending node
142
+ * argpp - argument of perigee
143
+ * mp - mean anomaly
144
+ *
145
+ * locals :
146
+ * alfdp -
147
+ * betdp -
148
+ * cosip , sinip , cosop , sinop ,
149
+ * dalf -
150
+ * dbet -
151
+ * dls -
152
+ * f2, f3 -
153
+ * pe -
154
+ * pgh -
155
+ * ph -
156
+ * PInc -
157
+ * pl -
158
+ * sel , ses , sghl , sghs , shl , shs , sil , sinzf , sis ,
159
+ * sll , sls
160
+ * xls -
161
+ * xnoh -
162
+ * zf -
163
+ * zm -
164
+ *
165
+ * coupling :
166
+ * none.
167
+ *
168
+ * references :
169
+ * hoots, roehrich, norad spacetrack report #3 1980
170
+ * hoots, norad spacetrack report #6 1986
171
+ * hoots, schumacher and glover 2004
172
+ * vallado, crawford, hujsak, kelso 2006
173
+ * ----------------------------------------------------------------------------
174
+ */
159
175
  Sgp4.dpper = function (satrec, options) {
160
176
  var e3 = satrec.e3, ee2 = satrec.ee2, peo = satrec.peo, pgho = satrec.pgho, pho = satrec.pho, PInco = satrec.PInco, plo = satrec.plo, se2 = satrec.se2, se3 = satrec.se3, sgh2 = satrec.sgh2, sgh3 = satrec.sgh3, sgh4 = satrec.sgh4, sh2 = satrec.sh2, sh3 = satrec.sh3, si2 = satrec.si2, si3 = satrec.si3, sl2 = satrec.sl2, sl3 = satrec.sl3, sl4 = satrec.sl4, t = satrec.t, xgh2 = satrec.xgh2, xgh3 = satrec.xgh3, xgh4 = satrec.xgh4, xh2 = satrec.xh2, xh3 = satrec.xh3, xi2 = satrec.xi2, xi3 = satrec.xi3, xl2 = satrec.xl2, xl3 = satrec.xl3, xl4 = satrec.xl4, zmol = satrec.zmol, zmos = satrec.zmos;
161
177
  var ep = options.ep, inclp = options.inclp, nodep = options.nodep, argpp = options.argpp, mp = options.mp;
@@ -168,7 +184,7 @@ var Sgp4 = /** @class */ (function () {
168
184
  var zel = 0.0549;
169
185
  // --------------- calculate time varying periodics -----------
170
186
  var zm = zmos + zns * t;
171
- // be sure that the initial call has time set to zero
187
+ // Be sure that the initial call has time set to zero
172
188
  if (init === 'y') {
173
189
  zm = zmos;
174
190
  }
@@ -210,14 +226,16 @@ var Sgp4 = /** @class */ (function () {
210
226
  var sinip = Math.sin(inclp);
211
227
  var cosip = Math.cos(inclp);
212
228
  /* ----------------- apply periodics directly ------------ */
213
- // sgp4fix for lyddane choice
214
- // strn3 used original inclination - this is technically feasible
215
- // gsfc used perturbed inclination - also technically feasible
216
- // probably best to readjust the 0.2 limit value and limit discontinuity
217
- // 0.2 rad = 11.45916 deg
218
- // use next line for original strn3 approach and original inclination
219
- // if (inclo >= 0.2)
220
- // use next line for gsfc version and perturbed inclination
229
+ /*
230
+ * Sgp4fix for lyddane choice
231
+ * strn3 used original inclination - this is technically feasible
232
+ * gsfc used perturbed inclination - also technically feasible
233
+ * probably best to readjust the 0.2 limit value and limit discontinuity
234
+ * 0.2 rad = 11.45916 deg
235
+ * use next line for original strn3 approach and original inclination
236
+ * if (inclo >= 0.2)
237
+ * use next line for gsfc version and perturbed inclination
238
+ */
221
239
  if (inclp >= 0.2) {
222
240
  ph /= sinip;
223
241
  pgh -= cosip * ph;
@@ -236,8 +254,10 @@ var Sgp4 = /** @class */ (function () {
236
254
  alfdp += dalf;
237
255
  betdp += dbet;
238
256
  nodep %= TAU;
239
- // sgp4fix for afspc written intrinsic functions
240
- // nodep used without a trigonometric function ahead
257
+ /*
258
+ * Sgp4fix for afspc written intrinsic functions
259
+ * nodep used without a trigonometric function ahead
260
+ */
241
261
  /* istanbul ignore next */
242
262
  if (nodep < 0.0 && opsmode === 'a') {
243
263
  nodep += TAU;
@@ -247,8 +267,10 @@ var Sgp4 = /** @class */ (function () {
247
267
  xls += dls;
248
268
  var xnoh = nodep;
249
269
  nodep = Math.atan2(alfdp, betdp);
250
- // sgp4fix for afspc written intrinsic functions
251
- // nodep used without a trigonometric function ahead
270
+ /*
271
+ * Sgp4fix for afspc written intrinsic functions
272
+ * nodep used without a trigonometric function ahead
273
+ */
252
274
  /* istanbul ignore next */
253
275
  if (nodep < 0.0 && opsmode === 'a') {
254
276
  nodep += TAU;
@@ -265,7 +287,7 @@ var Sgp4 = /** @class */ (function () {
265
287
  mp += pl;
266
288
  argpp = xls - mp - cosip * nodep;
267
289
  }
268
- } // if init == 'n'
290
+ } // If init == 'n'
269
291
  return {
270
292
  ep: ep,
271
293
  inclp: inclp,
@@ -273,74 +295,76 @@ var Sgp4 = /** @class */ (function () {
273
295
  argpp: argpp,
274
296
  mp: mp,
275
297
  };
276
- }; // dpper
277
- /*-----------------------------------------------------------------------------
278
- *
279
- * procedure dscom
280
- *
281
- * this procedure provides deep space common items used by both the secular
282
- * and periodics subroutines. input is provided as shown. this routine
283
- * used to be called dpper, but the functions inside weren't well organized.
284
- *
285
- * author : david vallado 719-573-2600 28 jun 2005
286
- *
287
- * inputs :
288
- * epoch -
289
- * ep - eccentricity
290
- * argpp - argument of perigee
291
- * tc -
292
- * inclp - inclination
293
- * nodep - right ascension of ascending node
294
- * np - mean motion
295
- *
296
- * outputs :
297
- * sinim , cosim , sinomm , cosomm , snodm , cnodm
298
- * day -
299
- * e3 -
300
- * ee2 -
301
- * em - eccentricity
302
- * emsq - eccentricity squared
303
- * gam -
304
- * peo -
305
- * pgho -
306
- * pho -
307
- * PInco -
308
- * plo -
309
- * rtemsq -
310
- * se2, se3 -
311
- * sgh2, sgh3, sgh4 -
312
- * sh2, sh3, si2, si3, sl2, sl3, sl4 -
313
- * s1, s2, s3, s4, s5, s6, s7 -
314
- * ss1, ss2, ss3, ss4, ss5, ss6, ss7, sz1, sz2, sz3 -
315
- * sz11, sz12, sz13, sz21, sz22, sz23, sz31, sz32, sz33 -
316
- * xgh2, xgh3, xgh4, xh2, xh3, xi2, xi3, xl2, xl3, xl4 -
317
- * nm - mean motion
318
- * z1, z2, z3, z11, z12, z13, z21, z22, z23, z31, z32, z33 -
319
- * zmol -
320
- * zmos -
321
- *
322
- * locals :
323
- * a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 -
324
- * betasq -
325
- * cc -
326
- * ctem, stem -
327
- * x1, x2, x3, x4, x5, x6, x7, x8 -
328
- * xnodce -
329
- * xnoi -
330
- * zcosg , zsing , zcosgl , zsingl , zcosh , zsinh , zcoshl , zsinhl ,
331
- * zcosi , zsini , zcosil , zsinil ,
332
- * zx -
333
- * zy -
334
- *
335
- * coupling :
336
- * none.
337
- *
338
- * references :
339
- * hoots, roehrich, norad spacetrack report #3 1980
340
- * hoots, norad spacetrack report #6 1986
341
- * hoots, schumacher and glover 2004
342
- * vallado, crawford, hujsak, kelso 2006
343
- ----------------------------------------------------------------------------*/
298
+ }; // Dpper
299
+ /*
300
+ *-----------------------------------------------------------------------------
301
+ *
302
+ * procedure dscom
303
+ *
304
+ * this procedure provides deep space common items used by both the secular
305
+ * and periodics subroutines. input is provided as shown. this routine
306
+ * used to be called dpper, but the functions inside weren't well organized.
307
+ *
308
+ * author : david vallado 719-573-2600 28 jun 2005
309
+ *
310
+ * inputs :
311
+ * epoch -
312
+ * ep - eccentricity
313
+ * argpp - argument of perigee
314
+ * tc -
315
+ * inclp - inclination
316
+ * nodep - right ascension of ascending node
317
+ * np - mean motion
318
+ *
319
+ * outputs :
320
+ * sinim , cosim , sinomm , cosomm , snodm , cnodm
321
+ * day -
322
+ * e3 -
323
+ * ee2 -
324
+ * em - eccentricity
325
+ * emsq - eccentricity squared
326
+ * gam -
327
+ * peo -
328
+ * pgho -
329
+ * pho -
330
+ * PInco -
331
+ * plo -
332
+ * rtemsq -
333
+ * se2, se3 -
334
+ * sgh2, sgh3, sgh4 -
335
+ * sh2, sh3, si2, si3, sl2, sl3, sl4 -
336
+ * s1, s2, s3, s4, s5, s6, s7 -
337
+ * ss1, ss2, ss3, ss4, ss5, ss6, ss7, sz1, sz2, sz3 -
338
+ * sz11, sz12, sz13, sz21, sz22, sz23, sz31, sz32, sz33 -
339
+ * xgh2, xgh3, xgh4, xh2, xh3, xi2, xi3, xl2, xl3, xl4 -
340
+ * nm - mean motion
341
+ * z1, z2, z3, z11, z12, z13, z21, z22, z23, z31, z32, z33 -
342
+ * zmol -
343
+ * zmos -
344
+ *
345
+ * locals :
346
+ * a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 -
347
+ * betasq -
348
+ * cc -
349
+ * ctem, stem -
350
+ * x1, x2, x3, x4, x5, x6, x7, x8 -
351
+ * xnodce -
352
+ * xnoi -
353
+ * zcosg , zsing , zcosgl , zsingl , zcosh , zsinh , zcoshl , zsinhl ,
354
+ * zcosi , zsini , zcosil , zsinil ,
355
+ * zx -
356
+ * zy -
357
+ *
358
+ * coupling :
359
+ * none.
360
+ *
361
+ * references :
362
+ * hoots, roehrich, norad spacetrack report #3 1980
363
+ * hoots, norad spacetrack report #6 1986
364
+ * hoots, schumacher and glover 2004
365
+ * vallado, crawford, hujsak, kelso 2006
366
+ *----------------------------------------------------------------------------
367
+ */
344
368
  Sgp4.dscom = function (options) {
345
369
  var epoch = options.epoch, ep = options.ep, argpp = options.argpp, tc = options.tc, inclp = options.inclp, nodep = options.nodep, np = options.np;
346
370
  // -------------------------- constants -------------------------
@@ -355,7 +379,7 @@ var Sgp4 = /** @class */ (function () {
355
379
  var zsings = -0.98088458;
356
380
  var TAU = 2.0 * Math.PI;
357
381
  // --------------------- local variables ------------------------
358
- var s1, s2, s3, s4, s5, s6, s7, ss1, ss2, ss3, ss4, ss5, ss6, ss7, sz1, sz2, sz3, sz11, sz12, sz13, sz21, sz22, sz23, sz31, sz32, sz33, z31, z32, z33, z1, z2, z3, z11, z12, z13, z21, z22, z23;
382
+ var s1, s2, s3, s4, s5, s6, s7, ss1, ss2, ss3, ss4, ss5, ss6, ss7, sz1, sz11, sz12, sz13, sz2, sz21, sz22, sz23, sz3, sz31, sz32, sz33, z1, z11, z12, z13, z2, z21, z22, z23, z3, z31, z32, z33;
359
383
  var nm = np;
360
384
  var em = ep;
361
385
  var snodm = Math.sin(nodep);
@@ -579,91 +603,94 @@ var Sgp4 = /** @class */ (function () {
579
603
  zmol: zmol,
580
604
  zmos: zmos,
581
605
  };
582
- }; // dscom
583
- /*-----------------------------------------------------------------------------
584
- *
585
- * procedure dsinit
586
- *
587
- * this procedure provides deep space contributions to mean motion dot due
588
- * to geopotential resonance with half day and one day orbits.
589
- *
590
- * author : david vallado 719-573-2600 28 jun 2005
591
- *
592
- * inputs :
593
- * cosim, sinim-
594
- * emsq - eccentricity squared
595
- * argpo - argument of perigee
596
- * s1, s2, s3, s4, s5 -
597
- * ss1, ss2, ss3, ss4, ss5 -
598
- * sz1, sz3, sz11, sz13, sz21, sz23, sz31, sz33 -
599
- * t - time
600
- * tc -
601
- * gsto - greenwich sidereal time rad
602
- * mo - mean anomaly
603
- * mdot - mean anomaly dot (rate)
604
- * no - mean motion
605
- * nodeo - right ascension of ascending node
606
- * nodedot - right ascension of ascending node dot (rate)
607
- * xPIdot -
608
- * z1, z3, z11, z13, z21, z23, z31, z33 -
609
- * eccm - eccentricity
610
- * argpm - argument of perigee
611
- * inclm - inclination
612
- * mm - mean anomaly
613
- * xn - mean motion
614
- * nodem - right ascension of ascending node
615
- *
616
- * outputs :
617
- * em - eccentricity
618
- * argpm - argument of perigee
619
- * inclm - inclination
620
- * mm - mean anomaly
621
- * nm - mean motion
622
- * nodem - right ascension of ascending node
623
- * irez - flag for resonance 0-none, 1-one day, 2-half day
624
- * atime -
625
- * d2201, d2211, d3210, d3222, d4410, d4422, d5220, d5232, d5421, d5433 -
626
- * dedt -
627
- * didt -
628
- * dmdt -
629
- * dndt -
630
- * dnodt -
631
- * domdt -
632
- * del1, del2, del3 -
633
- * ses , sghl , sghs , sgs , shl , shs , sis , sls
634
- * theta -
635
- * xfact -
636
- * xlamo -
637
- * xli -
638
- * xni
639
- *
640
- * locals :
641
- * ainv2 -
642
- * aonv -
643
- * cosisq -
644
- * eoc -
645
- * f220, f221, f311, f321, f322, f330, f441, f442, f522, f523, f542, f543 -
646
- * g200, g201, g211, g300, g310, g322, g410, g422, g520, g521, g532, g533 -
647
- * sini2 -
648
- * temp -
649
- * temp1 -
650
- * theta -
651
- * xno2 -
652
- *
653
- * coupling :
654
- * getgravconst
655
- *
656
- * references :
657
- * hoots, roehrich, norad spacetrack report #3 1980
658
- * hoots, norad spacetrack report #6 1986
659
- * hoots, schumacher and glover 2004
660
- * vallado, crawford, hujsak, kelso 2006
661
- ----------------------------------------------------------------------------*/
606
+ }; // Dscom
607
+ /*
608
+ *-----------------------------------------------------------------------------
609
+ *
610
+ * procedure dsinit
611
+ *
612
+ * this procedure provides deep space contributions to mean motion dot due
613
+ * to geopotential resonance with half day and one day orbits.
614
+ *
615
+ * author : david vallado 719-573-2600 28 jun 2005
616
+ *
617
+ * inputs :
618
+ * cosim, sinim-
619
+ * emsq - eccentricity squared
620
+ * argpo - argument of perigee
621
+ * s1, s2, s3, s4, s5 -
622
+ * ss1, ss2, ss3, ss4, ss5 -
623
+ * sz1, sz3, sz11, sz13, sz21, sz23, sz31, sz33 -
624
+ * t - time
625
+ * tc -
626
+ * gsto - greenwich sidereal time rad
627
+ * mo - mean anomaly
628
+ * mdot - mean anomaly dot (rate)
629
+ * no - mean motion
630
+ * nodeo - right ascension of ascending node
631
+ * nodedot - right ascension of ascending node dot (rate)
632
+ * xPIdot -
633
+ * z1, z3, z11, z13, z21, z23, z31, z33 -
634
+ * eccm - eccentricity
635
+ * argpm - argument of perigee
636
+ * inclm - inclination
637
+ * mm - mean anomaly
638
+ * xn - mean motion
639
+ * nodem - right ascension of ascending node
640
+ *
641
+ * outputs :
642
+ * em - eccentricity
643
+ * argpm - argument of perigee
644
+ * inclm - inclination
645
+ * mm - mean anomaly
646
+ * nm - mean motion
647
+ * nodem - right ascension of ascending node
648
+ * irez - flag for resonance 0-none, 1-one day, 2-half day
649
+ * atime -
650
+ * d2201, d2211, d3210, d3222, d4410, d4422, d5220, d5232, d5421, d5433 -
651
+ * dedt -
652
+ * didt -
653
+ * dmdt -
654
+ * dndt -
655
+ * dnodt -
656
+ * domdt -
657
+ * del1, del2, del3 -
658
+ * ses , sghl , sghs , sgs , shl , shs , sis , sls
659
+ * theta -
660
+ * xfact -
661
+ * xlamo -
662
+ * xli -
663
+ * xni
664
+ *
665
+ * locals :
666
+ * ainv2 -
667
+ * aonv -
668
+ * cosisq -
669
+ * eoc -
670
+ * f220, f221, f311, f321, f322, f330, f441, f442, f522, f523, f542, f543 -
671
+ * g200, g201, g211, g300, g310, g322, g410, g422, g520, g521, g532, g533 -
672
+ * sini2 -
673
+ * temp -
674
+ * temp1 -
675
+ * theta -
676
+ * xno2 -
677
+ *
678
+ * coupling :
679
+ * getgravconst
680
+ *
681
+ * references :
682
+ * hoots, roehrich, norad spacetrack report #3 1980
683
+ * hoots, norad spacetrack report #6 1986
684
+ * hoots, schumacher and glover 2004
685
+ * vallado, crawford, hujsak, kelso 2006
686
+ *----------------------------------------------------------------------------
687
+ */
662
688
  Sgp4.dsinit = function (options) {
663
- var
664
- // sgp4fix just send in xke as a constant and eliminate getgravconst call
665
- // gravconsttype whichconst,
666
- xke = options.xke, cosim = options.cosim, argpo = options.argpo, s1 = options.s1, s2 = options.s2, s3 = options.s3, s4 = options.s4, s5 = options.s5, sinim = options.sinim, ss1 = options.ss1, ss2 = options.ss2, ss3 = options.ss3, ss4 = options.ss4, ss5 = options.ss5, sz1 = options.sz1, sz3 = options.sz3, sz11 = options.sz11, sz13 = options.sz13, sz21 = options.sz21, sz23 = options.sz23, sz31 = options.sz31, sz33 = options.sz33, t = options.t, tc = options.tc, gsto = options.gsto, mo = options.mo, mdot = options.mdot, no = options.no, nodeo = options.nodeo, nodedot = options.nodedot, xPIdot = options.xPIdot, z1 = options.z1, z3 = options.z3, z11 = options.z11, z13 = options.z13, z21 = options.z21, z23 = options.z23, z31 = options.z31, z33 = options.z33, ecco = options.ecco, eccsq = options.eccsq;
689
+ /*
690
+ * Sgp4fix just send in xke as a constant and eliminate getgravconst call
691
+ * gravconsttype whichconst,
692
+ */
693
+ var xke = options.xke, cosim = options.cosim, argpo = options.argpo, s1 = options.s1, s2 = options.s2, s3 = options.s3, s4 = options.s4, s5 = options.s5, sinim = options.sinim, ss1 = options.ss1, ss2 = options.ss2, ss3 = options.ss3, ss4 = options.ss4, ss5 = options.ss5, sz1 = options.sz1, sz3 = options.sz3, sz11 = options.sz11, sz13 = options.sz13, sz21 = options.sz21, sz23 = options.sz23, sz31 = options.sz31, sz33 = options.sz33, t = options.t, tc = options.tc, gsto = options.gsto, mo = options.mo, mdot = options.mdot, no = options.no, nodeo = options.nodeo, nodedot = options.nodedot, xPIdot = options.xPIdot, z1 = options.z1, z3 = options.z3, z11 = options.z11, z13 = options.z13, z21 = options.z21, z23 = options.z23, z31 = options.z31, z33 = options.z33, ecco = options.ecco, eccsq = options.eccsq;
667
694
  var emsq = options.emsq, em = options.em, argpm = options.argpm, inclm = options.inclm, mm = options.mm, nm = options.nm, nodem = options.nodem, irez = options.irez, atime = options.atime, d2201 = options.d2201, d2211 = options.d2211, d3210 = options.d3210, d3222 = options.d3222, d4410 = options.d4410, d4422 = options.d4422, d5220 = options.d5220, d5232 = options.d5232, d5421 = options.d5421, d5433 = options.d5433, dedt = options.dedt, didt = options.didt, dmdt = options.dmdt, dnodt = options.dnodt, domdt = options.domdt, del1 = options.del1, del2 = options.del2, del3 = options.del3, xfact = options.xfact, xlamo = options.xlamo, xli = options.xli, xni = options.xni;
668
695
  /* --------------------- local variables ------------------------ */
669
696
  /** Ootk -- Some variables imported from outside the class at the top */
@@ -673,15 +700,19 @@ var Sgp4 = /** @class */ (function () {
673
700
  var root22 = 1.7891679e-6;
674
701
  var root44 = 7.3636953e-9;
675
702
  var root54 = 2.1765803e-9;
676
- var rptim = 4.37526908801129966e-3; // equates to 7.29211514668855e-5 rad/sec
703
+ // IDEA: Any way to fix this?
704
+ // eslint-disable-next-line @typescript-eslint/no-loss-of-precision
705
+ var rptim = 4.37526908801129966e-3; // Equates to 7.29211514668855e-5 rad/sec
677
706
  var root32 = 3.7393792e-7;
678
707
  var root52 = 1.1428639e-7;
679
708
  var x2o3 = 2.0 / 3.0;
680
709
  var znl = 1.5835218e-4;
681
710
  var zns = 1.19459e-5;
682
- // sgp4fix identify constants and allow alternate values
683
- // just xke is used here so pass it in rather than have multiple calls
684
- // getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 );
711
+ /*
712
+ * Sgp4fix identify constants and allow alternate values
713
+ * just xke is used here so pass it in rather than have multiple calls
714
+ * getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 );
715
+ */
685
716
  // -------------------- deep space initialization ------------
686
717
  irez = 0;
687
718
  if (nm < 0.0052359877 && nm > 0.0034906585) {
@@ -696,7 +727,7 @@ var Sgp4 = /** @class */ (function () {
696
727
  var sls = -zns * ss3 * (sz1 + sz3 - 14.0 - 6.0 * emsq);
697
728
  var sghs = ss4 * zns * (sz31 + sz33 - 6.0);
698
729
  var shs = -zns * ss2 * (sz21 + sz23);
699
- // sgp4fix for 180 deg incl
730
+ // Sgp4fix for 180 deg incl
700
731
  if (inclm < 5.2359877e-2 || inclm > PI - 5.2359877e-2) {
701
732
  shs = 0.0;
702
733
  }
@@ -710,7 +741,7 @@ var Sgp4 = /** @class */ (function () {
710
741
  dmdt = sls - znl * s3 * (z1 + z3 - 14.0 - 6.0 * emsq);
711
742
  var sghl = s4 * znl * (z31 + z33 - 6.0);
712
743
  var shll = -znl * s2 * (z21 + z23);
713
- // sgp4fix for 180 deg incl
744
+ // Sgp4fix for 180 deg incl
714
745
  if (inclm < 5.2359877e-2 || inclm > PI - 5.2359877e-2) {
715
746
  shll = 0.0;
716
747
  }
@@ -728,14 +759,16 @@ var Sgp4 = /** @class */ (function () {
728
759
  argpm += domdt * t;
729
760
  nodem += dnodt * t;
730
761
  mm += dmdt * t;
731
- // sgp4fix for negative inclinations
732
- // the following if statement should be commented out
733
- // if (inclm < 0.0)
734
- // {
735
- // inclm = -inclm;
736
- // argpm = argpm - PI;
737
- // nodem = nodem + PI;
738
- // }
762
+ /*
763
+ * Sgp4fix for negative inclinations
764
+ * the following if statement should be commented out
765
+ * if (inclm < 0.0)
766
+ * {
767
+ * inclm = -inclm;
768
+ * argpm = argpm - PI;
769
+ * nodem = nodem + PI;
770
+ * }
771
+ */
739
772
  // -------------- initialize the resonance terms -------------
740
773
  if (irez !== 0) {
741
774
  var aonv = Math.pow((nm / xke), x2o3);
@@ -748,7 +781,7 @@ var Sgp4 = /** @class */ (function () {
748
781
  emsq = eccsq;
749
782
  var eoc = em * emsq;
750
783
  var g201 = -0.306 - (em - 0.64) * 0.44;
751
- var g211 = void 0, g310 = void 0, g322 = void 0, g410 = void 0, g422 = void 0, g520 = void 0, g533 = void 0, g521 = void 0, g532 = void 0;
784
+ var g211 = void 0, g310 = void 0, g322 = void 0, g410 = void 0, g422 = void 0, g520 = void 0, g521 = void 0, g532 = void 0, g533 = void 0;
752
785
  if (em <= 0.65) {
753
786
  g211 = 3.616 - 13.247 * em + 16.29 * emsq;
754
787
  g310 = -19.302 + 117.39 * em - 228.419 * emsq + 156.591 * eoc;
@@ -787,8 +820,11 @@ var Sgp4 = /** @class */ (function () {
787
820
  var f322 = -1.875 * sinim * (1.0 + 2.0 * cosim - 3.0 * cosisq);
788
821
  var f441 = 35.0 * sini2 * f220;
789
822
  var f442 = 39.375 * sini2 * sini2;
790
- var f522 = 9.84375 * sinim * (sini2 * (1.0 - 2.0 * cosim - 5.0 * cosisq) + 0.33333333 * (-2.0 + 4.0 * cosim + 6.0 * cosisq));
791
- var f523 = sinim * (4.92187512 * sini2 * (-2.0 - 4.0 * cosim + 10.0 * cosisq) + 6.56250012 * (1.0 + 2.0 * cosim - 3.0 * cosisq));
823
+ var f522 = 9.84375 *
824
+ sinim *
825
+ (sini2 * (1.0 - 2.0 * cosim - 5.0 * cosisq) + 0.33333333 * (-2.0 + 4.0 * cosim + 6.0 * cosisq));
826
+ var f523 = sinim *
827
+ (4.92187512 * sini2 * (-2.0 - 4.0 * cosim + 10.0 * cosisq) + 6.56250012 * (1.0 + 2.0 * cosim - 3.0 * cosisq));
792
828
  var f542 = 29.53125 * sinim * (2.0 - 8.0 * cosim + cosisq * (-12.0 + 8.0 * cosim + 10.0 * cosisq));
793
829
  var f543 = 29.53125 * sinim * (-2.0 - 8.0 * cosim + cosisq * (12.0 + 8.0 * cosim - 10.0 * cosisq));
794
830
  var xno2 = nm * nm;
@@ -872,79 +908,81 @@ var Sgp4 = /** @class */ (function () {
872
908
  xli: xli,
873
909
  xni: xni,
874
910
  };
875
- }; // dsinit
876
- /*-----------------------------------------------------------------------------
877
- *
878
- * procedure dspace
879
- *
880
- * this procedure provides deep space contributions to mean elements for
881
- * perturbing third body. these effects have been averaged over one
882
- * revolution of the sun and moon. for earth resonance effects, the
883
- * effects have been averaged over no revolutions of the satellite.
884
- * (mean motion)
885
- *
886
- * author : david vallado 719-573-2600 28 jun 2005
887
- *
888
- * inputs :
889
- * d2201, d2211, d3210, d3222, d4410, d4422, d5220, d5232, d5421, d5433 -
890
- * dedt -
891
- * del1, del2, del3 -
892
- * didt -
893
- * dmdt -
894
- * dnodt -
895
- * domdt -
896
- * irez - flag for resonance 0-none, 1-one day, 2-half day
897
- * argpo - argument of perigee
898
- * argpdot - argument of perigee dot (rate)
899
- * t - time
900
- * tc -
901
- * gsto - gst
902
- * xfact -
903
- * xlamo -
904
- * no - mean motion
905
- * atime -
906
- * em - eccentricity
907
- * ft -
908
- * argpm - argument of perigee
909
- * inclm - inclination
910
- * xli -
911
- * mm - mean anomaly
912
- * xni - mean motion
913
- * nodem - right ascension of ascending node
914
- *
915
- * outputs :
916
- * atime -
917
- * em - eccentricity
918
- * argpm - argument of perigee
919
- * inclm - inclination
920
- * xli -
921
- * mm - mean anomaly
922
- * xni -
923
- * nodem - right ascension of ascending node
924
- * dndt -
925
- * nm - mean motion
926
- *
927
- * locals :
928
- * delt -
929
- * ft -
930
- * theta -
931
- * x2li -
932
- * x2omi -
933
- * xl -
934
- * xldot -
935
- * xnddt -
936
- * xndt -
937
- * xomi -
938
- *
939
- * coupling :
940
- * none -
941
- *
942
- * references :
943
- * hoots, roehrich, norad spacetrack report #3 1980
944
- * hoots, norad spacetrack report #6 1986
945
- * hoots, schumacher and glover 2004
946
- * vallado, crawford, hujsak, kelso 2006
947
- ----------------------------------------------------------------------------*/
911
+ }; // Dsinit
912
+ /*
913
+ *-----------------------------------------------------------------------------
914
+ *
915
+ * procedure dspace
916
+ *
917
+ * this procedure provides deep space contributions to mean elements for
918
+ * perturbing third body. these effects have been averaged over one
919
+ * revolution of the sun and moon. for earth resonance effects, the
920
+ * effects have been averaged over no revolutions of the satellite.
921
+ * (mean motion)
922
+ *
923
+ * author : david vallado 719-573-2600 28 jun 2005
924
+ *
925
+ * inputs :
926
+ * d2201, d2211, d3210, d3222, d4410, d4422, d5220, d5232, d5421, d5433 -
927
+ * dedt -
928
+ * del1, del2, del3 -
929
+ * didt -
930
+ * dmdt -
931
+ * dnodt -
932
+ * domdt -
933
+ * irez - flag for resonance 0-none, 1-one day, 2-half day
934
+ * argpo - argument of perigee
935
+ * argpdot - argument of perigee dot (rate)
936
+ * t - time
937
+ * tc -
938
+ * gsto - gst
939
+ * xfact -
940
+ * xlamo -
941
+ * no - mean motion
942
+ * atime -
943
+ * em - eccentricity
944
+ * ft -
945
+ * argpm - argument of perigee
946
+ * inclm - inclination
947
+ * xli -
948
+ * mm - mean anomaly
949
+ * xni - mean motion
950
+ * nodem - right ascension of ascending node
951
+ *
952
+ * outputs :
953
+ * atime -
954
+ * em - eccentricity
955
+ * argpm - argument of perigee
956
+ * inclm - inclination
957
+ * xli -
958
+ * mm - mean anomaly
959
+ * xni -
960
+ * nodem - right ascension of ascending node
961
+ * dndt -
962
+ * nm - mean motion
963
+ *
964
+ * locals :
965
+ * delt -
966
+ * ft -
967
+ * theta -
968
+ * x2li -
969
+ * x2omi -
970
+ * xl -
971
+ * xldot -
972
+ * xnddt -
973
+ * xndt -
974
+ * xomi -
975
+ *
976
+ * coupling :
977
+ * none -
978
+ *
979
+ * references :
980
+ * hoots, roehrich, norad spacetrack report #3 1980
981
+ * hoots, norad spacetrack report #6 1986
982
+ * hoots, schumacher and glover 2004
983
+ * vallado, crawford, hujsak, kelso 2006
984
+ *----------------------------------------------------------------------------
985
+ */
948
986
  Sgp4.dspace = function (irez, d2201, d2211, d3210, d3222, d4410, d4422, d5220, d5232, d5421, d5433, dedt, del1, del2, del3, didt, dmdt, dnodt, domdt, argpo, argpdot, t, tc, gsto, xfact, xlamo, no, atime, em, argpm, inclm, xli, mm, xni, nodem, nm) {
949
987
  /** Ootk -- Some variables imported from outside the class at the top */
950
988
  var fasx2 = 0.13130908;
@@ -955,7 +993,9 @@ var Sgp4 = /** @class */ (function () {
955
993
  var g44 = 1.8014998;
956
994
  var g52 = 1.050833;
957
995
  var g54 = 4.4108898;
958
- var rptim = 4.37526908801129966e-3; // equates to 7.29211514668855e-5 rad/sec
996
+ // IDEA: Any way to fix this?
997
+ // eslint-disable-next-line @typescript-eslint/no-loss-of-precision
998
+ var rptim = 4.37526908801129966e-3; // Equates to 7.29211514668855e-5 rad/sec
959
999
  var stepp = 720.0;
960
1000
  var stepn = -720.0;
961
1001
  var step2 = 259200.0;
@@ -967,29 +1007,33 @@ var Sgp4 = /** @class */ (function () {
967
1007
  argpm += domdt * t;
968
1008
  nodem += dnodt * t;
969
1009
  mm += dmdt * t;
970
- // sgp4fix for negative inclinations
971
- // the following if statement should be commented out
972
- // if (inclm < 0.0)
973
- // {
974
- // inclm = -inclm;
975
- // argpm = argpm - PI;
976
- // nodem = nodem + PI;
977
- // }
1010
+ /*
1011
+ * Sgp4fix for negative inclinations
1012
+ * the following if statement should be commented out
1013
+ * if (inclm < 0.0)
1014
+ * {
1015
+ * inclm = -inclm;
1016
+ * argpm = argpm - PI;
1017
+ * nodem = nodem + PI;
1018
+ * }
1019
+ */
978
1020
  /* - update resonances : numerical (euler-maclaurin) integration - */
979
1021
  /* ------------------------- epoch restart ---------------------- */
980
- // sgp4fix for propagator problems
981
- // the following integration works for negative time steps and periods
982
- // the specific changes are unknown because the original code was so convoluted
983
- // sgp4fix take out atime = 0.0 and fix for faster operation
984
- // ft = 0.0; /** Ootk -- This has no value */
1022
+ /*
1023
+ * Sgp4fix for propagator problems
1024
+ * the following integration works for negative time steps and periods
1025
+ * the specific changes are unknown because the original code was so convoluted
1026
+ */
1027
+ // Sgp4fix take out atime = 0.0 and fix for faster operation
1028
+ // Ft = 0.0; /** Ootk -- This has no value */
985
1029
  if (irez !== 0) {
986
- // sgp4fix streamline check
1030
+ // Sgp4fix streamline check
987
1031
  if (atime === 0.0 || t * atime <= 0.0 || Math.abs(t) < Math.abs(atime)) {
988
1032
  atime = 0.0;
989
1033
  xni = no;
990
1034
  xli = xlamo;
991
1035
  }
992
- // sgp4fix move check outside loop
1036
+ // Sgp4fix move check outside loop
993
1037
  var delt = void 0;
994
1038
  if (t > 0.0) {
995
1039
  delt = stepp;
@@ -997,15 +1041,21 @@ var Sgp4 = /** @class */ (function () {
997
1041
  else {
998
1042
  delt = stepn;
999
1043
  }
1000
- var xndt = void 0, xldot = void 0, xnddt = void 0, xomi = void 0, x2omi = void 0, x2li = void 0, ft = void 0;
1001
- var iretn = 381; // added for do loop
1044
+ var ft = void 0, x2li = void 0, x2omi = void 0, xldot = void 0, xnddt = void 0, xndt = void 0, xomi = void 0;
1045
+ var iretn = 381; // Added for do loop
1002
1046
  while (iretn === 381) {
1003
- // ------------------- dot terms calculated -------------
1004
- // ----------- near - synchronous resonance terms -------
1047
+ /*
1048
+ * ------------------- dot terms calculated -------------
1049
+ * ----------- near - synchronous resonance terms -------
1050
+ */
1005
1051
  if (irez !== 2) {
1006
- xndt = del1 * Math.sin(xli - fasx2) + del2 * Math.sin(2.0 * (xli - fasx4)) + del3 * Math.sin(3.0 * (xli - fasx6));
1052
+ xndt =
1053
+ del1 * Math.sin(xli - fasx2) + del2 * Math.sin(2.0 * (xli - fasx4)) + del3 * Math.sin(3.0 * (xli - fasx6));
1007
1054
  xldot = xni + xfact;
1008
- xnddt = del1 * Math.cos(xli - fasx2) + 2.0 * del2 * Math.cos(2.0 * (xli - fasx4)) + 3.0 * del3 * Math.cos(3.0 * (xli - fasx6));
1055
+ xnddt =
1056
+ del1 * Math.cos(xli - fasx2) +
1057
+ 2.0 * del2 * Math.cos(2.0 * (xli - fasx4)) +
1058
+ 3.0 * del3 * Math.cos(3.0 * (xli - fasx6));
1009
1059
  xnddt *= xldot;
1010
1060
  }
1011
1061
  else {
@@ -1038,10 +1088,12 @@ var Sgp4 = /** @class */ (function () {
1038
1088
  d5433 * Math.cos(-xomi + x2li - g54);
1039
1089
  xnddt *= xldot;
1040
1090
  }
1041
- // ----------------------- integrator -------------------
1042
- // sgp4fix move end checks to end of routine
1091
+ /*
1092
+ * ----------------------- integrator -------------------
1093
+ * sgp4fix move end checks to end of routine
1094
+ */
1043
1095
  if (Math.abs(t - atime) >= stepp) {
1044
- // iret = 0; /** Ootk -- This has no value */
1096
+ // Iret = 0; /** Ootk -- This has no value */
1045
1097
  iretn = 381;
1046
1098
  }
1047
1099
  else {
@@ -1053,7 +1105,7 @@ var Sgp4 = /** @class */ (function () {
1053
1105
  xni += xndt * delt + xnddt * step2;
1054
1106
  atime += delt;
1055
1107
  }
1056
- } // while iretn = 381
1108
+ } // While iretn = 381
1057
1109
  nm = xni + xndt * ft + xnddt * ft * ft * 0.5;
1058
1110
  var xl = xli + xldot * ft + xndt * ft * ft * 0.5;
1059
1111
  if (irez !== 1) {
@@ -1067,76 +1119,82 @@ var Sgp4 = /** @class */ (function () {
1067
1119
  nm = no + dndt;
1068
1120
  }
1069
1121
  return [em, argpm, inclm, mm, nodem, nm];
1070
- }; // dspace
1071
- /*-----------------------------------------------------------------------------
1072
- *
1073
- * procedure initl
1074
- *
1075
- * this procedure initializes the sgp4 propagator. all the initialization is
1076
- * consolidated here instead of having multiple loops inside other routines.
1077
- *
1078
- * author : david vallado 719-573-2600 28 jun 2005
1079
- *
1080
- * inputs :
1081
- * satn - satellite number - not needed, placed in satrec
1082
- * xke - reciprocal of tumin
1083
- * j2 - j2 zonal harmonic
1084
- * ecco - eccentricity 0.0 - 1.0
1085
- * epoch - epoch time in days from jan 0, 1950. 0 hr
1086
- * inclo - inclination of satellite
1087
- * no - mean motion of satellite
1088
- *
1089
- * outputs :
1090
- * ainv - 1.0 / a
1091
- * ao - semi major axis
1092
- * con41 -
1093
- * con42 - 1.0 - 5.0 cos(i)
1094
- * cosio - cosine of inclination
1095
- * cosio2 - cosio squared
1096
- * eccsq - eccentricity squared
1097
- * method - flag for deep space 'd', 'n'
1098
- * omeosq - 1.0 - ecco * ecco
1099
- * posq - semi-parameter squared
1100
- * rp - radius of perigee
1101
- * rteosq - square root of (1.0 - ecco*ecco)
1102
- * sinio - sine of inclination
1103
- * gsto - gst at time of observation rad
1104
- * no - mean motion of satellite
1105
- *
1106
- * locals :
1107
- * ak -
1108
- * d1 -
1109
- * del -
1110
- * adel -
1111
- * po -
1112
- *
1113
- * coupling :
1114
- * getgravconst- no longer used
1115
- * gstime - find greenwich sidereal time from the julian date
1116
- *
1117
- * references :
1118
- * hoots, roehrich, norad spacetrack report #3 1980
1119
- * hoots, norad spacetrack report #6 1986
1120
- * hoots, schumacher and glover 2004
1121
- * vallado, crawford, hujsak, kelso 2006
1122
- ----------------------------------------------------------------------------*/
1122
+ }; // Dspace
1123
+ /*
1124
+ *-----------------------------------------------------------------------------
1125
+ *
1126
+ * procedure initl
1127
+ *
1128
+ * this procedure initializes the sgp4 propagator. all the initialization is
1129
+ * consolidated here instead of having multiple loops inside other routines.
1130
+ *
1131
+ * author : david vallado 719-573-2600 28 jun 2005
1132
+ *
1133
+ * inputs :
1134
+ * satn - satellite number - not needed, placed in satrec
1135
+ * xke - reciprocal of tumin
1136
+ * j2 - j2 zonal harmonic
1137
+ * ecco - eccentricity 0.0 - 1.0
1138
+ * epoch - epoch time in days from jan 0, 1950. 0 hr
1139
+ * inclo - inclination of satellite
1140
+ * no - mean motion of satellite
1141
+ *
1142
+ * outputs :
1143
+ * ainv - 1.0 / a
1144
+ * ao - semi major axis
1145
+ * con41 -
1146
+ * con42 - 1.0 - 5.0 cos(i)
1147
+ * cosio - cosine of inclination
1148
+ * cosio2 - cosio squared
1149
+ * eccsq - eccentricity squared
1150
+ * method - flag for deep space 'd', 'n'
1151
+ * omeosq - 1.0 - ecco * ecco
1152
+ * posq - semi-parameter squared
1153
+ * rp - radius of perigee
1154
+ * rteosq - square root of (1.0 - ecco*ecco)
1155
+ * sinio - sine of inclination
1156
+ * gsto - gst at time of observation rad
1157
+ * no - mean motion of satellite
1158
+ *
1159
+ * locals :
1160
+ * ak -
1161
+ * d1 -
1162
+ * del -
1163
+ * adel -
1164
+ * po -
1165
+ *
1166
+ * coupling :
1167
+ * getgravconst- no longer used
1168
+ * gstime - find greenwich sidereal time from the julian date
1169
+ *
1170
+ * references :
1171
+ * hoots, roehrich, norad spacetrack report #3 1980
1172
+ * hoots, norad spacetrack report #6 1986
1173
+ * hoots, schumacher and glover 2004
1174
+ * vallado, crawford, hujsak, kelso 2006
1175
+ *----------------------------------------------------------------------------
1176
+ */
1123
1177
  Sgp4.initl = function (options) {
1124
- // sgp4fix satn not needed. include in satrec in case needed later
1125
- // int satn,
1126
- // sgp4fix just pass in xke and j2
1127
- // gravconsttype whichconst,
1178
+ /*
1179
+ * Sgp4fix satn not needed. include in satrec in case needed later
1180
+ * int satn,
1181
+ * sgp4fix just pass in xke and j2
1182
+ * gravconsttype whichconst,
1183
+ */
1128
1184
  var opsmode = options.opsmode, ecco = options.ecco, epoch = options.epoch, inclo = options.inclo, xke = options.xke, j2 = options.j2;
1129
1185
  var no = options.no;
1130
1186
  /* --------------------- local variables ------------------------ */
1131
1187
  var PI = Math.PI;
1132
1188
  var TAU = PI * 2;
1133
1189
  var x2o3 = 2.0 / 3.0;
1134
- // sgp4fix use old way of finding gst
1190
+ // Sgp4fix use old way of finding gst
1135
1191
  /** Ootk -- Some variables imported from outside the class at the top */
1136
- // ----------------------- earth constants ---------------------
1137
- // sgp4fix identify constants and allow alternate values
1138
- // only xke and j2 are used here so pass them in directly
1139
- // getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 )
1192
+ /*
1193
+ * ----------------------- earth constants ---------------------
1194
+ * sgp4fix identify constants and allow alternate values
1195
+ * only xke and j2 are used here so pass them in directly
1196
+ * getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 )
1197
+ */
1140
1198
  // ------------- calculate auxillary epoch quantities ----------
1141
1199
  var eccsq = ecco * ecco;
1142
1200
  var omeosq = 1.0 - eccsq;
@@ -1149,7 +1207,7 @@ var Sgp4 = /** @class */ (function () {
1149
1207
  var delPrime = d1 / (ak * ak);
1150
1208
  var adel = ak * (1.0 - delPrime * delPrime - delPrime * (1.0 / 3.0 + (134.0 * delPrime * delPrime) / 81.0));
1151
1209
  delPrime = d1 / (adel * adel);
1152
- no = no / (1.0 + delPrime);
1210
+ no /= 1.0 + delPrime;
1153
1211
  var ao = Math.pow((xke / no), x2o3);
1154
1212
  var sinio = Math.sin(inclo);
1155
1213
  var po = ao * omeosq;
@@ -1159,18 +1217,24 @@ var Sgp4 = /** @class */ (function () {
1159
1217
  var posq = po * po;
1160
1218
  var rp = ao * (1.0 - ecco);
1161
1219
  var method = 'n';
1162
- // sgp4fix modern approach to finding sidereal time
1220
+ // Sgp4fix modern approach to finding sidereal time
1163
1221
  /** Ootk -- Continue allowing AFSPC mode for SGP4 Validation */
1164
1222
  var gsto;
1165
- if (opsmode == 'a') {
1166
- // sgp4fix use old way of finding gst
1167
- // count integer number of days from 0 jan 1970
1223
+ if (opsmode === 'a') {
1224
+ /*
1225
+ * Sgp4fix use old way of finding gst
1226
+ * count integer number of days from 0 jan 1970
1227
+ */
1168
1228
  var ts70 = epoch - 7305.0;
1169
1229
  var ds70 = Math.floor(ts70 + 1.0e-8);
1170
1230
  var tfrac = ts70 - ds70;
1171
- // find greenwich location at epoch
1231
+ // Find greenwich location at epoch
1232
+ // IDEA: Precision issues in JavaScript...
1233
+ // eslint-disable-next-line @typescript-eslint/no-loss-of-precision
1172
1234
  var c1 = 1.72027916940703639e-2;
1235
+ // eslint-disable-next-line @typescript-eslint/no-loss-of-precision
1173
1236
  var thgr70 = 1.7321343856509374;
1237
+ // eslint-disable-next-line @typescript-eslint/no-loss-of-precision
1174
1238
  var fk5r = 5.07551419432269442e-15;
1175
1239
  var c1p2p = c1 + TAU;
1176
1240
  gsto = (thgr70 + c1 * ds70 + c1p2p * tfrac + ts70 * ts70 * fk5r) % TAU;
@@ -1199,95 +1263,99 @@ var Sgp4 = /** @class */ (function () {
1199
1263
  sinio: sinio,
1200
1264
  gsto: gsto,
1201
1265
  };
1202
- }; // initl
1203
- /*-----------------------------------------------------------------------------
1204
- *
1205
- * procedure sgp4init
1206
- *
1207
- * this procedure initializes variables for sgp4.
1208
- *
1209
- * author : david vallado 719-573-2600 28 jun 2005
1210
- *
1211
- * inputs :
1212
- * opsmode - mode of operation afspc or improved 'a', 'i'
1213
- * whichconst - which set of constants to use 72, 84
1214
- * satn - satellite number
1215
- * bstar - sgp4 type drag coefficient kg/m2er
1216
- * ecco - eccentricity
1217
- * epoch - epoch time in days from jan 0, 1950. 0 hr
1218
- * argpo - argument of perigee (output if ds)
1219
- * inclo - inclination
1220
- * mo - mean anomaly (output if ds)
1221
- * no - mean motion
1222
- * nodeo - right ascension of ascending node
1223
- *
1224
- * outputs :
1225
- * rec - common values for subsequent calls
1226
- * return code - non-zero on error.
1227
- * 1 - mean elements, ecc >= 1.0 or ecc < -0.001 or a < 0.95 er
1228
- * 2 - mean motion less than 0.0
1229
- * 3 - pert elements, ecc < 0.0 or ecc > 1.0
1230
- * 4 - semi-latus rectum < 0.0
1231
- * 5 - epoch elements are sub-orbital
1232
- * 6 - satellite has decayed
1233
- *
1234
- * locals :
1235
- * cnodm , snodm , cosim , sinim , cosomm , sinomm
1236
- * cc1sq , cc2 , cc3
1237
- * coef , coef1
1238
- * cosio4 -
1239
- * day -
1240
- * dndt -
1241
- * em - eccentricity
1242
- * emsq - eccentricity squared
1243
- * eeta -
1244
- * etasq -
1245
- * gam -
1246
- * argpm - argument of perigee
1247
- * nodem -
1248
- * inclm - inclination
1249
- * mm - mean anomaly
1250
- * nm - mean motion
1251
- * perige - perigee
1252
- * PInvsq -
1253
- * psisq -
1254
- * qzms24 -
1255
- * rtemsq -
1256
- * s1, s2, s3, s4, s5, s6, s7 -
1257
- * sfour -
1258
- * ss1, ss2, ss3, ss4, ss5, ss6, ss7 -
1259
- * sz1, sz2, sz3
1260
- * sz11, sz12, sz13, sz21, sz22, sz23, sz31, sz32, sz33 -
1261
- * tc -
1262
- * temp -
1263
- * temp1, temp2, temp3 -
1264
- * tsi -
1265
- * xPIdot -
1266
- * xhdot1 -
1267
- * z1, z2, z3 -
1268
- * z11, z12, z13, z21, z22, z23, z31, z32, z33 -
1269
- *
1270
- * coupling :
1271
- * getgravconst-
1272
- * initl -
1273
- * dscom -
1274
- * dpper -
1275
- * dsinit -
1276
- * sgp4 -
1277
- *
1278
- * references :
1279
- * hoots, roehrich, norad spacetrack report #3 1980
1280
- * hoots, norad spacetrack report #6 1986
1281
- * hoots, schumacher and glover 2004
1282
- * vallado, crawford, hujsak, kelso 2006
1283
- ----------------------------------------------------------------------------*/
1266
+ }; // Initl
1267
+ /*
1268
+ *-----------------------------------------------------------------------------
1269
+ *
1270
+ * procedure sgp4init
1271
+ *
1272
+ * this procedure initializes variables for sgp4.
1273
+ *
1274
+ * author : david vallado 719-573-2600 28 jun 2005
1275
+ *
1276
+ * inputs :
1277
+ * opsmode - mode of operation afspc or improved 'a', 'i'
1278
+ * whichconst - which set of constants to use 72, 84
1279
+ * satn - satellite number
1280
+ * bstar - sgp4 type drag coefficient kg/m2er
1281
+ * ecco - eccentricity
1282
+ * epoch - epoch time in days from jan 0, 1950. 0 hr
1283
+ * argpo - argument of perigee (output if ds)
1284
+ * inclo - inclination
1285
+ * mo - mean anomaly (output if ds)
1286
+ * no - mean motion
1287
+ * nodeo - right ascension of ascending node
1288
+ *
1289
+ * outputs :
1290
+ * rec - common values for subsequent calls
1291
+ * return code - non-zero on error.
1292
+ * 1 - mean elements, ecc >= 1.0 or ecc < -0.001 or a < 0.95 er
1293
+ * 2 - mean motion less than 0.0
1294
+ * 3 - pert elements, ecc < 0.0 or ecc > 1.0
1295
+ * 4 - semi-latus rectum < 0.0
1296
+ * 5 - epoch elements are sub-orbital
1297
+ * 6 - satellite has decayed
1298
+ *
1299
+ * locals :
1300
+ * cnodm , snodm , cosim , sinim , cosomm , sinomm
1301
+ * cc1sq , cc2 , cc3
1302
+ * coef , coef1
1303
+ * cosio4 -
1304
+ * day -
1305
+ * dndt -
1306
+ * em - eccentricity
1307
+ * emsq - eccentricity squared
1308
+ * eeta -
1309
+ * etasq -
1310
+ * gam -
1311
+ * argpm - argument of perigee
1312
+ * nodem -
1313
+ * inclm - inclination
1314
+ * mm - mean anomaly
1315
+ * nm - mean motion
1316
+ * perige - perigee
1317
+ * PInvsq -
1318
+ * psisq -
1319
+ * qzms24 -
1320
+ * rtemsq -
1321
+ * s1, s2, s3, s4, s5, s6, s7 -
1322
+ * sfour -
1323
+ * ss1, ss2, ss3, ss4, ss5, ss6, ss7 -
1324
+ * sz1, sz2, sz3
1325
+ * sz11, sz12, sz13, sz21, sz22, sz23, sz31, sz32, sz33 -
1326
+ * tc -
1327
+ * temp -
1328
+ * temp1, temp2, temp3 -
1329
+ * tsi -
1330
+ * xPIdot -
1331
+ * xhdot1 -
1332
+ * z1, z2, z3 -
1333
+ * z11, z12, z13, z21, z22, z23, z31, z32, z33 -
1334
+ *
1335
+ * coupling :
1336
+ * getgravconst-
1337
+ * initl -
1338
+ * dscom -
1339
+ * dpper -
1340
+ * dsinit -
1341
+ * sgp4 -
1342
+ *
1343
+ * references :
1344
+ * hoots, roehrich, norad spacetrack report #3 1980
1345
+ * hoots, norad spacetrack report #6 1986
1346
+ * hoots, schumacher and glover 2004
1347
+ * vallado, crawford, hujsak, kelso 2006
1348
+ *----------------------------------------------------------------------------
1349
+ */
1284
1350
  Sgp4.sgp4init = function (satrec, options) {
1285
1351
  /* eslint-disable no-param-reassign */
1286
1352
  var _a = options.whichconst, whichconst = _a === void 0 ? 'wgs72' : _a, _b = options.opsmode, opsmode = _b === void 0 ? 'i' : _b, _c = options.satn, satn = _c === void 0 ? satrec.satnum : _c, epoch = options.epoch, xbstar = options.xbstar, xecco = options.xecco, xargpo = options.xargpo, xinclo = options.xinclo, xndot = options.xndot, xnddot = options.xnddot, xmo = options.xmo, xno = options.xno, xnodeo = options.xnodeo;
1287
1353
  /* ------------------------ initialization --------------------- */
1288
- // sgp4fix divisor for divide by zero check on inclination
1289
- // the old check used 1.0 + Math.cos(PI-1.0e-9), but then compared it to
1290
- // 1.5 e-12, so the threshold was changed to 1.5e-12 for consistency
1354
+ /*
1355
+ * Sgp4fix divisor for divide by zero check on inclination
1356
+ * the old check used 1.0 + Math.cos(PI-1.0e-9), but then compared it to
1357
+ * 1.5 e-12, so the threshold was changed to 1.5e-12 for consistency
1358
+ */
1291
1359
  // ----------- set all near earth variables to zero ------------
1292
1360
  satrec.isimp = 0;
1293
1361
  satrec.method = 'n';
@@ -1374,8 +1442,10 @@ var Sgp4 = /** @class */ (function () {
1374
1442
  satrec.xli = 0.0;
1375
1443
  satrec.xni = 0.0;
1376
1444
  /* ------------------------ earth constants ----------------------- */
1377
- // sgp4fix identify constants and allow alternate values
1378
- // this is now the only call for the constants
1445
+ /*
1446
+ * Sgp4fix identify constants and allow alternate values
1447
+ * this is now the only call for the constants
1448
+ */
1379
1449
  var gravResults = Sgp4.getgravconst(whichconst);
1380
1450
  satrec.tumin = gravResults.tumin;
1381
1451
  satrec.mus = gravResults.mus;
@@ -1389,11 +1459,12 @@ var Sgp4 = /** @class */ (function () {
1389
1459
  var j4 = gravResults.j4;
1390
1460
  var xke = gravResults.xke;
1391
1461
  var j3oj2 = gravResults.j3oj2;
1392
- //-------------------------------------------------------------------------
1462
+ // -------------------------------------------------------------------------
1393
1463
  satrec.error = 0;
1394
1464
  satrec.operationmode = opsmode;
1395
- // new alpha5 or 9-digit number
1396
- /** Ootk -- Using JS code for string manipulation but same effect
1465
+ // New alpha5 or 9-digit number
1466
+ /**
1467
+ * Ootk -- Using JS code for string manipulation but same effect
1397
1468
  * Ex. A2525 = 102525
1398
1469
  * Ex. Z1234 = 351234
1399
1470
  */
@@ -1404,33 +1475,39 @@ var Sgp4 = /** @class */ (function () {
1404
1475
  else {
1405
1476
  satrec.satnum = satn;
1406
1477
  }
1407
- // sgp4fix - note the following variables are also passed directly via satrec.
1408
- // it is possible to streamline the sgp4init call by deleting the "x"
1409
- // variables, but the user would need to set the satrec.* values first. we
1410
- // include the additional assignments in case twoline2rv is not used.
1478
+ /*
1479
+ * Sgp4fix - note the following variables are also passed directly via satrec.
1480
+ * it is possible to streamline the sgp4init call by deleting the "x"
1481
+ * variables, but the user would need to set the satrec.* values first. we
1482
+ * include the additional assignments in case twoline2rv is not used.
1483
+ */
1411
1484
  satrec.bstar = xbstar;
1412
- // sgp4fix allow additional parameters in the struct
1485
+ // Sgp4fix allow additional parameters in the struct
1413
1486
  satrec.ndot = xndot;
1414
1487
  satrec.nddot = xnddot;
1415
1488
  satrec.ecco = xecco;
1416
1489
  satrec.argpo = xargpo;
1417
1490
  satrec.inclo = xinclo;
1418
1491
  satrec.mo = xmo;
1419
- // sgp4fix rename variables to clarify which mean motion is intended
1492
+ // Sgp4fix rename variables to clarify which mean motion is intended
1420
1493
  satrec.no = xno;
1421
1494
  satrec.nodeo = xnodeo;
1422
- // single averaged mean elements
1423
- // satrec.am = satrec.em = satrec.im = satrec.Om = satrec.mm = satrec.nm = 0.0;
1424
- // ------------------------ earth constants -----------------------
1425
- // sgp4fix identify constants and allow alternate values
1426
- // getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 );
1495
+ /*
1496
+ * Single averaged mean elements
1497
+ * satrec.am = satrec.em = satrec.im = satrec.Om = satrec.mm = satrec.nm = 0.0;
1498
+ */
1499
+ /*
1500
+ * ------------------------ earth constants -----------------------
1501
+ * sgp4fix identify constants and allow alternate values
1502
+ * getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 );
1503
+ */
1427
1504
  var ss = 78.0 / satrec.radiusearthkm + 1.0;
1428
- // sgp4fix use multiply for speed instead of pow
1505
+ // Sgp4fix use multiply for speed instead of pow
1429
1506
  var qzms2ttemp = (120.0 - 78.0) / satrec.radiusearthkm;
1430
1507
  var qzms2t = qzms2ttemp * qzms2ttemp * qzms2ttemp * qzms2ttemp;
1431
1508
  satrec.init = 'y';
1432
1509
  satrec.t = 0.0;
1433
- // sgp4fix remove satn as it is not needed in initl
1510
+ // Sgp4fix remove satn as it is not needed in initl
1434
1511
  var initlOptions = {
1435
1512
  ecco: satrec.ecco,
1436
1513
  epoch: epoch,
@@ -1446,18 +1523,20 @@ var Sgp4 = /** @class */ (function () {
1446
1523
  satrec.no = initlResult.no;
1447
1524
  satrec.con41 = initlResult.con41;
1448
1525
  satrec.gsto = initlResult.gsto;
1449
- satrec.a = Math.pow(satrec.no * satrec.tumin, -2.0 / 3.0);
1526
+ satrec.a = Math.pow((satrec.no * satrec.tumin), (-2.0 / 3.0));
1450
1527
  satrec.alta = satrec.a * (1.0 + satrec.ecco) - 1.0;
1451
1528
  satrec.altp = satrec.a * (1.0 - satrec.ecco) - 1.0;
1452
1529
  satrec.error = 0;
1453
- // sgp4fix remove this check as it is unnecessary
1454
- // the mrt check in sgp4 handles decaying satellite cases even if the starting
1455
- // condition is below the surface of te earth
1456
- // if (rp < 1.0)
1457
- // {
1458
- // printf("// *** satn%d epoch elts sub-orbital ***\n", satn);
1459
- // satrec.error = 5;
1460
- // }
1530
+ /*
1531
+ * Sgp4fix remove this check as it is unnecessary
1532
+ * the mrt check in sgp4 handles decaying satellite cases even if the starting
1533
+ * condition is below the surface of te earth
1534
+ * if (rp < 1.0)
1535
+ * {
1536
+ * printf("// *** satn%d epoch elts sub-orbital ***\n", satn);
1537
+ * satrec.error = 5;
1538
+ * }
1539
+ */
1461
1540
  if (omeosq >= 0.0 || satrec.no >= 0.0) {
1462
1541
  satrec.isimp = 0;
1463
1542
  if (rp < 220.0 / satrec.radiusearthkm + 1.0) {
@@ -1472,7 +1551,7 @@ var Sgp4 = /** @class */ (function () {
1472
1551
  if (perige < 98.0) {
1473
1552
  sfour = 20.0;
1474
1553
  }
1475
- // sgp4fix use multiply for speed instead of pow
1554
+ // Sgp4fix use multiply for speed instead of pow
1476
1555
  var qzms24temp = (120.0 - sfour) / satrec.radiusearthkm;
1477
1556
  qzms24 = qzms24temp * qzms24temp * qzms24temp * qzms24temp;
1478
1557
  sfour = sfour / satrec.radiusearthkm + 1.0;
@@ -1485,7 +1564,10 @@ var Sgp4 = /** @class */ (function () {
1485
1564
  var psisq = Math.abs(1.0 - etasq);
1486
1565
  var coef = qzms24 * Math.pow(tsi, 4.0);
1487
1566
  var coef1 = coef / Math.pow(psisq, 3.5);
1488
- var cc2 = coef1 * satrec.no * (ao * (1.0 + 1.5 * etasq + eeta * (4.0 + etasq)) + ((0.375 * j2 * tsi) / psisq) * satrec.con41 * (8.0 + 3.0 * etasq * (8.0 + etasq)));
1567
+ var cc2 = coef1 *
1568
+ satrec.no *
1569
+ (ao * (1.0 + 1.5 * etasq + eeta * (4.0 + etasq)) +
1570
+ ((0.375 * j2 * tsi) / psisq) * satrec.con41 * (8.0 + 3.0 * etasq * (8.0 + etasq)));
1489
1571
  satrec.cc1 = satrec.bstar * cc2;
1490
1572
  var cc3 = 0.0;
1491
1573
  if (satrec.ecco > 1.0e-4) {
@@ -1501,14 +1583,21 @@ var Sgp4 = /** @class */ (function () {
1501
1583
  (satrec.eta * (2.0 + 0.5 * etasq) +
1502
1584
  satrec.ecco * (0.5 + 2.0 * etasq) -
1503
1585
  ((j2 * tsi) / (ao * psisq)) *
1504
- (-3.0 * satrec.con41 * (1.0 - 2.0 * eeta + etasq * (1.5 - 0.5 * eeta)) + 0.75 * satrec.x1mth2 * (2.0 * etasq - eeta * (1.0 + etasq)) * Math.cos(2.0 * satrec.argpo)));
1586
+ (-3.0 * satrec.con41 * (1.0 - 2.0 * eeta + etasq * (1.5 - 0.5 * eeta)) +
1587
+ 0.75 * satrec.x1mth2 * (2.0 * etasq - eeta * (1.0 + etasq)) * Math.cos(2.0 * satrec.argpo)));
1505
1588
  satrec.cc5 = 2.0 * coef1 * ao * omeosq * (1.0 + 2.75 * (etasq + eeta) + eeta * etasq);
1506
1589
  var cosio4 = cosio2 * cosio2;
1507
1590
  var temp1 = 1.5 * j2 * PInvsq * satrec.no;
1508
1591
  var temp2 = 0.5 * temp1 * j2 * PInvsq;
1509
1592
  var temp3 = -0.46875 * j4 * PInvsq * PInvsq * satrec.no;
1510
- satrec.mdot = satrec.no + 0.5 * temp1 * rteosq * satrec.con41 + 0.0625 * temp2 * rteosq * (13.0 - 78.0 * cosio2 + 137.0 * cosio4);
1511
- satrec.argpdot = -0.5 * temp1 * con42 + 0.0625 * temp2 * (7.0 - 114.0 * cosio2 + 395.0 * cosio4) + temp3 * (3.0 - 36.0 * cosio2 + 49.0 * cosio4);
1593
+ satrec.mdot =
1594
+ satrec.no +
1595
+ 0.5 * temp1 * rteosq * satrec.con41 +
1596
+ 0.0625 * temp2 * rteosq * (13.0 - 78.0 * cosio2 + 137.0 * cosio4);
1597
+ satrec.argpdot =
1598
+ -0.5 * temp1 * con42 +
1599
+ 0.0625 * temp2 * (7.0 - 114.0 * cosio2 + 395.0 * cosio4) +
1600
+ temp3 * (3.0 - 36.0 * cosio2 + 49.0 * cosio4);
1512
1601
  var xhdot1 = -temp1 * cosio;
1513
1602
  satrec.nodedot = xhdot1 + (0.5 * temp2 * (4.0 - 19.0 * cosio2) + 2.0 * temp3 * (3.0 - 7.0 * cosio2)) * cosio;
1514
1603
  var xPIdot = satrec.argpdot + satrec.nodedot;
@@ -1519,7 +1608,7 @@ var Sgp4 = /** @class */ (function () {
1519
1608
  }
1520
1609
  satrec.nodecf = 3.5 * omeosq * xhdot1 * satrec.cc1;
1521
1610
  satrec.t2cof = 1.5 * satrec.cc1;
1522
- // sgp4fix for divide by zero with xinco = 180 deg
1611
+ // Sgp4fix for divide by zero with xinco = 180 deg
1523
1612
  if (Math.abs(cosio + 1.0) > 1.5e-12) {
1524
1613
  satrec.xlcof = (-0.25 * j3oj2 * sinio * (3.0 + 5.0 * cosio)) / (1.0 + cosio);
1525
1614
  }
@@ -1527,7 +1616,7 @@ var Sgp4 = /** @class */ (function () {
1527
1616
  satrec.xlcof = (-0.25 * j3oj2 * sinio * (3.0 + 5.0 * cosio)) / temp4;
1528
1617
  }
1529
1618
  satrec.aycof = -0.5 * j3oj2 * sinio;
1530
- // sgp4fix use multiply for speed instead of pow
1619
+ // Sgp4fix use multiply for speed instead of pow
1531
1620
  var delmotemp = 1.0 + satrec.eta * Math.cos(satrec.mo);
1532
1621
  satrec.delmo = delmotemp * delmotemp * delmotemp;
1533
1622
  satrec.sinmao = Math.sin(satrec.mo);
@@ -1740,110 +1829,125 @@ var Sgp4 = /** @class */ (function () {
1740
1829
  satrec.d4 = 0.5 * temp * ao * tsi * (221.0 * ao + 31.0 * sfour) * satrec.cc1;
1741
1830
  satrec.t3cof = satrec.d2 + 2.0 * cc1sq;
1742
1831
  satrec.t4cof = 0.25 * (3.0 * satrec.d3 + satrec.cc1 * (12.0 * satrec.d2 + 10.0 * cc1sq));
1743
- satrec.t5cof = 0.2 * (3.0 * satrec.d4 + 12.0 * satrec.cc1 * satrec.d3 + 6.0 * satrec.d2 * satrec.d2 + 15.0 * cc1sq * (2.0 * satrec.d2 + cc1sq));
1744
- } // if omeosq = 0 ...
1745
- /* finally propogate to zero epoch to initialize all others. */
1746
- // sgp4fix take out check to let satellites process until they are actually below earth surface
1747
- // if(satrec.error == 0)
1832
+ satrec.t5cof =
1833
+ 0.2 *
1834
+ (3.0 * satrec.d4 +
1835
+ 12.0 * satrec.cc1 * satrec.d3 +
1836
+ 6.0 * satrec.d2 * satrec.d2 +
1837
+ 15.0 * cc1sq * (2.0 * satrec.d2 + cc1sq));
1838
+ } // If omeosq = 0 ...
1839
+ /* Finally propogate to zero epoch to initialize all others. */
1840
+ /*
1841
+ * Sgp4fix take out check to let satellites process until they are actually below earth surface
1842
+ * if(satrec.error == 0)
1843
+ */
1748
1844
  }
1749
1845
  Sgp4.propagate(satrec, 0);
1750
1846
  satrec.init = 'n';
1751
- //sgp4fix return boolean. satrec.error contains any error codes
1752
- // return satrec; -- no reason to return anything in JS
1753
- }; // sgp4init
1754
- /*----------------------------------------------------------------------------
1755
- *
1756
- * procedure sgp4
1757
- *
1758
- * this procedure is the sgp4 prediction model from space command. this is an
1759
- * updated and combined version of sgp4 and sdp4, which were originally
1760
- * published separately in spacetrack report //3. this version follows the
1761
- * methodology from the aiaa paper (2006) describing the history and
1762
- * development of the code.
1763
- *
1764
- * author : david vallado 719-573-2600 28 jun 2005
1765
- *
1766
- * inputs :
1767
- * satrec - initialised structure from sgp4init() call.
1768
- * tsince - time since epoch (minutes)
1769
- *
1770
- * outputs :
1771
- * r - position vector km
1772
- * v - velocity km/sec
1773
- * return code - non-zero on error.
1774
- * 1 - mean elements, ecc >= 1.0 or ecc < -0.001 or a < 0.95 er
1775
- * 2 - mean motion less than 0.0
1776
- * 3 - pert elements, ecc < 0.0 or ecc > 1.0
1777
- * 4 - semi-latus rectum < 0.0
1778
- * 5 - epoch elements are sub-orbital
1779
- * 6 - satellite has decayed
1780
- *
1781
- * locals :
1782
- * am -
1783
- * axnl, aynl -
1784
- * betal -
1785
- * cosim , sinim , cosomm , sinomm , cnod , snod , cos2u ,
1786
- * sin2u , coseo1 , sineo1 , cosi , sini , cosip , sinip ,
1787
- * cosisq , cossu , sinsu , cosu , sinu
1788
- * delm -
1789
- * delomg -
1790
- * dndt -
1791
- * eccm -
1792
- * emsq -
1793
- * ecose -
1794
- * el2 -
1795
- * eo1 -
1796
- * eccp -
1797
- * esine -
1798
- * argpm -
1799
- * argpp -
1800
- * omgadf -
1801
- * pl -
1802
- * r -
1803
- * rtemsq -
1804
- * rdotl -
1805
- * rl -
1806
- * rvdot -
1807
- * rvdotl -
1808
- * su -
1809
- * t2 , t3 , t4 , tc
1810
- * tem5, temp , temp1 , temp2 , tempa , tempe , templ
1811
- * u , ux , uy , uz , vx , vy , vz
1812
- * inclm - inclination
1813
- * mm - mean anomaly
1814
- * nm - mean motion
1815
- * nodem - right asc of ascending node
1816
- * xinc -
1817
- * xincp -
1818
- * xl -
1819
- * xlm -
1820
- * mp -
1821
- * xmdf -
1822
- * xmx -
1823
- * xmy -
1824
- * nodedf -
1825
- * xnode -
1826
- * nodep -
1827
- * np -
1828
- *
1829
- * coupling :
1830
- * getgravconst-
1831
- * dpper
1832
- * dspace
1833
- *
1834
- * references :
1835
- * hoots, roehrich, norad spacetrack report //3 1980
1836
- * hoots, norad spacetrack report //6 1986
1837
- * hoots, schumacher and glover 2004
1838
- * vallado, crawford, hujsak, kelso 2006
1839
- ----------------------------------------------------------------------------*/
1847
+ /*
1848
+ * Sgp4fix return boolean. satrec.error contains any error codes
1849
+ * return satrec; -- no reason to return anything in JS
1850
+ */
1851
+ }; // Sgp4init
1852
+ /*
1853
+ *----------------------------------------------------------------------------
1854
+ *
1855
+ * procedure sgp4
1856
+ *
1857
+ * this procedure is the sgp4 prediction model from space command. this is an
1858
+ * updated and combined version of sgp4 and sdp4, which were originally
1859
+ * published separately in spacetrack report //3. this version follows the
1860
+ * methodology from the aiaa paper (2006) describing the history and
1861
+ * development of the code.
1862
+ *
1863
+ * author : david vallado 719-573-2600 28 jun 2005
1864
+ *
1865
+ * inputs :
1866
+ * satrec - initialised structure from sgp4init() call.
1867
+ * tsince - time since epoch (minutes)
1868
+ *
1869
+ * outputs :
1870
+ * r - position vector km
1871
+ * v - velocity km/sec
1872
+ * return code - non-zero on error.
1873
+ * 1 - mean elements, ecc >= 1.0 or ecc < -0.001 or a < 0.95 er
1874
+ * 2 - mean motion less than 0.0
1875
+ * 3 - pert elements, ecc < 0.0 or ecc > 1.0
1876
+ * 4 - semi-latus rectum < 0.0
1877
+ * 5 - epoch elements are sub-orbital
1878
+ * 6 - satellite has decayed
1879
+ *
1880
+ * locals :
1881
+ * am -
1882
+ * axnl, aynl -
1883
+ * betal -
1884
+ * cosim , sinim , cosomm , sinomm , cnod , snod , cos2u ,
1885
+ * sin2u , coseo1 , sineo1 , cosi , sini , cosip , sinip ,
1886
+ * cosisq , cossu , sinsu , cosu , sinu
1887
+ * delm -
1888
+ * delomg -
1889
+ * dndt -
1890
+ * eccm -
1891
+ * emsq -
1892
+ * ecose -
1893
+ * el2 -
1894
+ * eo1 -
1895
+ * eccp -
1896
+ * esine -
1897
+ * argpm -
1898
+ * argpp -
1899
+ * omgadf -
1900
+ * pl -
1901
+ * r -
1902
+ * rtemsq -
1903
+ * rdotl -
1904
+ * rl -
1905
+ * rvdot -
1906
+ * rvdotl -
1907
+ * su -
1908
+ * t2 , t3 , t4 , tc
1909
+ * tem5, temp , temp1 , temp2 , tempa , tempe , templ
1910
+ * u , ux , uy , uz , vx , vy , vz
1911
+ * inclm - inclination
1912
+ * mm - mean anomaly
1913
+ * nm - mean motion
1914
+ * nodem - right asc of ascending node
1915
+ * xinc -
1916
+ * xincp -
1917
+ * xl -
1918
+ * xlm -
1919
+ * mp -
1920
+ * xmdf -
1921
+ * xmx -
1922
+ * xmy -
1923
+ * nodedf -
1924
+ * xnode -
1925
+ * nodep -
1926
+ * np -
1927
+ *
1928
+ * coupling :
1929
+ * getgravconst-
1930
+ * dpper
1931
+ * dspace
1932
+ *
1933
+ * references :
1934
+ * hoots, roehrich, norad spacetrack report //3 1980
1935
+ * hoots, norad spacetrack report //6 1986
1936
+ * hoots, schumacher and glover 2004
1937
+ * vallado, crawford, hujsak, kelso 2006
1938
+ *----------------------------------------------------------------------------
1939
+ */
1840
1940
  Sgp4.propagate = function (satrec, tsince) {
1841
1941
  /* ------------------ set mathematical constants --------------- */
1842
- // sgp4fix divisor for divide by zero check on inclination
1843
- // the old check used 1.0 + cos(PI-1.0e-9), but then compared it to
1844
- // 1.5 e-12, so the threshold was changed to 1.5e-12 for consistency
1845
- // sgp4fix identify constants and allow alternate values
1846
- // getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 );
1942
+ /*
1943
+ * Sgp4fix divisor for divide by zero check on inclination
1944
+ * the old check used 1.0 + cos(PI-1.0e-9), but then compared it to
1945
+ * 1.5 e-12, so the threshold was changed to 1.5e-12 for consistency
1946
+ */
1947
+ /*
1948
+ * Sgp4fix identify constants and allow alternate values
1949
+ * getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 );
1950
+ */
1847
1951
  var xke = satrec.xke, j2 = satrec.j2, j3oj2 = satrec.j3oj2;
1848
1952
  var vkmpersec = (satrec.radiusearthkm * satrec.xke) / 60.0;
1849
1953
  // --------------------- clear sgp4 error flag -----------------
@@ -1862,7 +1966,7 @@ var Sgp4 = /** @class */ (function () {
1862
1966
  var templ = satrec.t2cof * t2;
1863
1967
  if (satrec.isimp !== 1) {
1864
1968
  var delomg = satrec.omgcof * satrec.t;
1865
- // sgp4fix use mutliply for speed instead of pow
1969
+ // Sgp4fix use mutliply for speed instead of pow
1866
1970
  var delmtemp = 1.0 + satrec.eta * Math.cos(xmdf);
1867
1971
  var delm = satrec.xmcof * (delmtemp * delmtemp * delmtemp - satrec.delmo);
1868
1972
  var temp_1 = delomg + delm;
@@ -1881,27 +1985,31 @@ var Sgp4 = /** @class */ (function () {
1881
1985
  var tc = satrec.t;
1882
1986
  var dspaceResult = Sgp4.dspace(satrec.irez, satrec.d2201, satrec.d2211, satrec.d3210, satrec.d3222, satrec.d4410, satrec.d4422, satrec.d5220, satrec.d5232, satrec.d5421, satrec.d5433, satrec.dedt, satrec.del1, satrec.del2, satrec.del3, satrec.didt, satrec.dmdt, satrec.dnodt, satrec.domdt, satrec.argpo, satrec.argpdot, satrec.t, tc, satrec.gsto, satrec.xfact, satrec.xlamo, satrec.no, satrec.atime, em, argpm, inclm, satrec.xli, mm, satrec.xni, nodem, nm);
1883
1987
  em = dspaceResult[0], argpm = dspaceResult[1], inclm = dspaceResult[2], mm = dspaceResult[3], nodem = dspaceResult[4], nm = dspaceResult[5];
1884
- } // if methjod = d
1988
+ } // If methjod = d
1885
1989
  if (nm <= 0.0) {
1886
- // printf("// error nm %f\n", nm);
1990
+ // Printf("// error nm %f\n", nm);
1887
1991
  satrec.error = 2;
1888
- // sgp4fix add return
1992
+ // Sgp4fix add return
1889
1993
  return { position: false, velocity: false };
1890
1994
  }
1891
1995
  var am = Math.pow((xke / nm), x2o3) * tempa * tempa;
1892
1996
  nm = xke / Math.pow(am, 1.5);
1893
1997
  em -= tempe;
1894
- // fix tolerance for error recognition
1895
- // sgp4fix am is fixed from the previous nm check
1998
+ /*
1999
+ * Fix tolerance for error recognition
2000
+ * sgp4fix am is fixed from the previous nm check
2001
+ */
1896
2002
  /* istanbul ignore next | This is no longer possible*/
1897
2003
  if (em >= 1.0 || em < -0.001) {
1898
- // || (am < 0.95)
1899
- // printf("// error em %f\n", em);
2004
+ /*
2005
+ * || (am < 0.95)
2006
+ * printf("// error em %f\n", em);
2007
+ */
1900
2008
  satrec.error = 1;
1901
- // sgp4fix to return if there is an error in eccentricity
2009
+ // Sgp4fix to return if there is an error in eccentricity
1902
2010
  return { position: false, velocity: false };
1903
2011
  }
1904
- // sgp4fix fix tolerance to avoid a divide by zero
2012
+ // Sgp4fix fix tolerance to avoid a divide by zero
1905
2013
  if (em < 1.0e-6) {
1906
2014
  em = 1.0e-6;
1907
2015
  }
@@ -1911,15 +2019,17 @@ var Sgp4 = /** @class */ (function () {
1911
2019
  argpm %= TAU;
1912
2020
  xlm %= TAU;
1913
2021
  mm = (xlm - argpm - nodem) % TAU;
1914
- // sgp4fix recover singly averaged mean elements
1915
- // TODO: Skip these?
1916
- // satrec.am = am;
1917
- // satrec.em = em;
1918
- // satrec.im = inclm;
1919
- // satrec.Om = nodem;
1920
- // satrec.om = argpm;
1921
- // satrec.mm = mm;
1922
- // satrec.nm = nm;
2022
+ /*
2023
+ * Sgp4fix recover singly averaged mean elements
2024
+ * TODO: Skip these?
2025
+ * satrec.am = am;
2026
+ * satrec.em = em;
2027
+ * satrec.im = inclm;
2028
+ * satrec.Om = nodem;
2029
+ * satrec.om = argpm;
2030
+ * satrec.mm = mm;
2031
+ * satrec.nm = nm;
2032
+ */
1923
2033
  // ----------------- compute extra mean quantities -------------
1924
2034
  var sinim = Math.sin(inclm);
1925
2035
  var cosim = Math.cos(inclm);
@@ -1951,9 +2061,9 @@ var Sgp4 = /** @class */ (function () {
1951
2061
  argpp -= PI;
1952
2062
  }
1953
2063
  if (ep < 0.0 || ep > 1.0) {
1954
- // printf("// error ep %f\n", ep);
2064
+ // Printf("// error ep %f\n", ep);
1955
2065
  satrec.error = 3;
1956
- // sgp4fix add return
2066
+ // Sgp4fix add return
1957
2067
  return { position: false, velocity: false };
1958
2068
  }
1959
2069
  }
@@ -1962,7 +2072,7 @@ var Sgp4 = /** @class */ (function () {
1962
2072
  sinip = Math.sin(xincp);
1963
2073
  cosip = Math.cos(xincp);
1964
2074
  satrec.aycof = -0.5 * j3oj2 * sinip;
1965
- // sgp4fix for divide by zero for xincp = 180 deg
2075
+ // Sgp4fix for divide by zero for xincp = 180 deg
1966
2076
  /* istanbul ignore next | This is no longer possible*/
1967
2077
  if (Math.abs(cosip + 1.0) > 1.5e-12) {
1968
2078
  satrec.xlcof = (-0.25 * j3oj2 * sinip * (3.0 + 5.0 * cosip)) / (1.0 + cosip);
@@ -1980,9 +2090,11 @@ var Sgp4 = /** @class */ (function () {
1980
2090
  var eo1 = u;
1981
2091
  var tem5 = 9999.9;
1982
2092
  var ktr = 1;
1983
- // sgp4fix for kepler iteration
1984
- // the following iteration needs better limits on corrections
1985
- var sineo1, coseo1;
2093
+ /*
2094
+ * Sgp4fix for kepler iteration
2095
+ * the following iteration needs better limits on corrections
2096
+ */
2097
+ var coseo1, sineo1;
1986
2098
  while (Math.abs(tem5) >= 1.0e-12 && ktr <= 10) {
1987
2099
  sineo1 = Math.sin(eo1);
1988
2100
  coseo1 = Math.cos(eo1);
@@ -2005,9 +2117,9 @@ var Sgp4 = /** @class */ (function () {
2005
2117
  var el2 = axnl * axnl + aynl * aynl;
2006
2118
  var pl = am * (1.0 - el2);
2007
2119
  if (pl < 0.0) {
2008
- // printf("// error pl %f\n", pl);
2120
+ // Printf("// error pl %f\n", pl);
2009
2121
  satrec.error = 4;
2010
- // sgp4fix add return
2122
+ // Sgp4fix add return
2011
2123
  return { position: false, velocity: false };
2012
2124
  }
2013
2125
  var rl = am * (1.0 - ecose);
@@ -2032,9 +2144,9 @@ var Sgp4 = /** @class */ (function () {
2032
2144
  }
2033
2145
  var mrt = rl * (1.0 - 1.5 * temp2 * betal * satrec.con41) + 0.5 * temp1 * satrec.x1mth2 * cos2u;
2034
2146
  /** Moved this up to reduce unnecessary computation if you are going to return false anyway */
2035
- // sgp4fix for decaying satellites
2147
+ // Sgp4fix for decaying satellites
2036
2148
  if (mrt < 1.0) {
2037
- // printf("// decay condition %11.6f \n",mrt);
2149
+ // Printf("// decay condition %11.6f \n",mrt);
2038
2150
  satrec.error = 6;
2039
2151
  return {
2040
2152
  position: false,
@@ -2077,43 +2189,45 @@ var Sgp4 = /** @class */ (function () {
2077
2189
  velocity: v,
2078
2190
  };
2079
2191
  };
2080
- /* -----------------------------------------------------------------------------
2081
- *
2082
- * function getgravconst
2083
- *
2084
- * this function gets constants for the propagator. note that mu is identified to
2085
- * facilitiate comparisons with newer models. the common useage is wgs72.
2086
- *
2087
- * author : david vallado 719-573-2600 21 jul 2006
2088
- *
2089
- * inputs :
2090
- * whichconst - which set of constants to use wgs72old, wgs72, wgs84
2091
- *
2092
- * outputs :
2093
- * tumin - minutes in one time unit
2094
- * mu - earth gravitational parameter
2095
- * radiusearthkm - radius of the earth in km
2096
- * xke - reciprocal of tumin
2097
- * j2, j3, j4 - un-normalized zonal harmonic values
2098
- * j3oj2 - j3 divided by j2
2099
- *
2100
- * locals :
2101
- *
2102
- * coupling :
2103
- * none
2104
- *
2105
- * references :
2106
- * norad spacetrack report #3
2107
- * vallado, crawford, hujsak, kelso 2006
2108
- --------------------------------------------------------------------------- */
2192
+ /*
2193
+ * -----------------------------------------------------------------------------
2194
+ *
2195
+ * function getgravconst
2196
+ *
2197
+ * this function gets constants for the propagator. note that mu is identified to
2198
+ * facilitiate comparisons with newer models. the common useage is wgs72.
2199
+ *
2200
+ * author : david vallado 719-573-2600 21 jul 2006
2201
+ *
2202
+ * inputs :
2203
+ * whichconst - which set of constants to use wgs72old, wgs72, wgs84
2204
+ *
2205
+ * outputs :
2206
+ * tumin - minutes in one time unit
2207
+ * mu - earth gravitational parameter
2208
+ * radiusearthkm - radius of the earth in km
2209
+ * xke - reciprocal of tumin
2210
+ * j2, j3, j4 - un-normalized zonal harmonic values
2211
+ * j3oj2 - j3 divided by j2
2212
+ *
2213
+ * locals :
2214
+ *
2215
+ * coupling :
2216
+ * none
2217
+ *
2218
+ * references :
2219
+ * norad spacetrack report #3
2220
+ * vallado, crawford, hujsak, kelso 2006
2221
+ * ---------------------------------------------------------------------------
2222
+ */
2109
2223
  Sgp4.getgravconst = function (whichconst) {
2110
- var tumin, mus, radiusearthkm, xke, j2, j3, j4, j3oj2;
2224
+ var j2, j3, j3oj2, j4, mus, radiusearthkm, tumin, xke;
2111
2225
  switch (whichconst) {
2112
2226
  // -- wgs-72 low precision str#3 constants --
2113
2227
  case 'wgs72old':
2114
- mus = 398600.79964; // in km3 / s2
2115
- radiusearthkm = 6378.135; // km
2116
- xke = 0.0743669161; // reciprocal of tumin
2228
+ mus = 398600.79964; // In km3 / s2
2229
+ radiusearthkm = 6378.135; // Km
2230
+ xke = 0.0743669161; // Reciprocal of tumin
2117
2231
  tumin = 1.0 / xke;
2118
2232
  j2 = 0.001082616;
2119
2233
  j3 = -0.00000253881;
@@ -2122,8 +2236,8 @@ var Sgp4 = /** @class */ (function () {
2122
2236
  break;
2123
2237
  // ------------ wgs-72 constants ------------
2124
2238
  case 'wgs72':
2125
- mus = 398600.8; // in km3 / s2
2126
- radiusearthkm = 6378.135; // km
2239
+ mus = 398600.8; // In km3 / s2
2240
+ radiusearthkm = 6378.135; // Km
2127
2241
  xke = 60.0 / Math.sqrt((radiusearthkm * radiusearthkm * radiusearthkm) / mus);
2128
2242
  tumin = 1.0 / xke;
2129
2243
  j2 = 0.001082616;
@@ -2133,8 +2247,8 @@ var Sgp4 = /** @class */ (function () {
2133
2247
  break;
2134
2248
  case 'wgs84':
2135
2249
  // ------------ wgs-84 constants ------------
2136
- mus = 398600.5; // in km3 / s2
2137
- radiusearthkm = 6378.137; // km
2250
+ mus = 398600.5; // In km3 / s2
2251
+ radiusearthkm = 6378.137; // Km
2138
2252
  xke = 60.0 / Math.sqrt((radiusearthkm * radiusearthkm * radiusearthkm) / mus);
2139
2253
  tumin = 1.0 / xke;
2140
2254
  j2 = 0.00108262998905;
@@ -2155,46 +2269,48 @@ var Sgp4 = /** @class */ (function () {
2155
2269
  j4: j4,
2156
2270
  j3oj2: j3oj2,
2157
2271
  };
2158
- }; // getgravconst
2159
- /* -----------------------------------------------------------------------------
2160
- *
2161
- * function twoline2rv
2162
- *
2163
- * this function converts the two line element set character string data to
2164
- * variables and initializes the sgp4 variables. several intermediate varaibles
2165
- * and quantities are determined. note that the result is a structure so multiple
2166
- * satellites can be processed simultaneously without having to reinitialize. the
2167
- * verification mode is an important option that permits quick checks of any
2168
- * changes to the underlying technical theory. this option works using a
2169
- * modified tle file in which the start, stop, and delta time values are
2170
- * included at the end of the second line of data. this only works with the
2171
- * verification mode. the catalog mode simply propagates from -1440 to 1440 min
2172
- * from epoch and is useful when performing entire catalog runs.
2173
- *
2174
- * author : david vallado 719-573-2600 1 mar 2001
2175
- *
2176
- * inputs :
2177
- * longstr1 - first line of the tle
2178
- * longstr2 - second line of the tle
2179
- * typerun - type of run verification 'v', catalog 'c',
2180
- * manual 'm'
2181
- * typeinput - type of manual input mfe 'm', epoch 'e', dayofyr 'd'
2182
- * opsmode - mode of operation afspc or improved 'a', 'i'
2183
- * whichconst - which set of constants to use 72, 84
2184
- *
2185
- * outputs :
2186
- * satrec - structure containing all the sgp4 satellite information
2187
- *
2188
- * coupling :
2189
- * getgravconst-
2190
- * days2mdhms - conversion of days to month, day, hour, minute, second
2191
- * jday - convert day month year hour minute second into julian date
2192
- * sgp4init - initialize the sgp4 variables
2193
- *
2194
- * references :
2195
- * norad spacetrack report #3
2196
- * vallado, crawford, hujsak, kelso 2006
2197
- --------------------------------------------------------------------------- */
2272
+ }; // Getgravconst
2273
+ /*
2274
+ * -----------------------------------------------------------------------------
2275
+ *
2276
+ * function twoline2rv
2277
+ *
2278
+ * this function converts the two line element set character string data to
2279
+ * variables and initializes the sgp4 variables. several intermediate varaibles
2280
+ * and quantities are determined. note that the result is a structure so multiple
2281
+ * satellites can be processed simultaneously without having to reinitialize. the
2282
+ * verification mode is an important option that permits quick checks of any
2283
+ * changes to the underlying technical theory. this option works using a
2284
+ * modified tle file in which the start, stop, and delta time values are
2285
+ * included at the end of the second line of data. this only works with the
2286
+ * verification mode. the catalog mode simply propagates from -1440 to 1440 min
2287
+ * from epoch and is useful when performing entire catalog runs.
2288
+ *
2289
+ * author : david vallado 719-573-2600 1 mar 2001
2290
+ *
2291
+ * inputs :
2292
+ * longstr1 - first line of the tle
2293
+ * longstr2 - second line of the tle
2294
+ * typerun - type of run verification 'v', catalog 'c',
2295
+ * manual 'm'
2296
+ * typeinput - type of manual input mfe 'm', epoch 'e', dayofyr 'd'
2297
+ * opsmode - mode of operation afspc or improved 'a', 'i'
2298
+ * whichconst - which set of constants to use 72, 84
2299
+ *
2300
+ * outputs :
2301
+ * satrec - structure containing all the sgp4 satellite information
2302
+ *
2303
+ * coupling :
2304
+ * getgravconst-
2305
+ * days2mdhms - conversion of days to month, day, hour, minute, second
2306
+ * jday - convert day month year hour minute second into julian date
2307
+ * sgp4init - initialize the sgp4 variables
2308
+ *
2309
+ * references :
2310
+ * norad spacetrack report #3
2311
+ * vallado, crawford, hujsak, kelso 2006
2312
+ * ---------------------------------------------------------------------------
2313
+ */
2198
2314
  Sgp4.createSatrec = function (tleLine1, tleLine2, whichconst, opsmode) {
2199
2315
  if (whichconst === void 0) { whichconst = 'wgs72'; }
2200
2316
  if (opsmode === void 0) { opsmode = 'i'; }
@@ -2318,8 +2434,10 @@ var Sgp4 = /** @class */ (function () {
2318
2434
  d2211: null,
2319
2435
  nm: null,
2320
2436
  };
2321
- // sgp4fix no longer needed
2322
- // getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 );
2437
+ /*
2438
+ * Sgp4fix no longer needed
2439
+ * getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 );
2440
+ */
2323
2441
  var xpdotp = 1440.0 / (2.0 * PI); // 229.1831180523293;
2324
2442
  satrec.error = 0;
2325
2443
  satrec.satnum = tleLine1.substring(2, 7);
@@ -2328,7 +2446,7 @@ var Sgp4 = /** @class */ (function () {
2328
2446
  satrec.ndot = parseFloat(tleLine1.substring(33, 43));
2329
2447
  satrec.nddot = parseFloat("".concat(tleLine1.substring(44, 45), ".").concat(tleLine1.substring(45, 50), "E").concat(tleLine1.substring(50, 52)));
2330
2448
  satrec.bstar = parseFloat("".concat(tleLine1.substring(53, 54), ".").concat(tleLine1.substring(54, 59), "E").concat(tleLine1.substring(59, 61)));
2331
- // satrec.satnum = tleLine2.substring(2, 7);
2449
+ // Satrec.satnum = tleLine2.substring(2, 7);
2332
2450
  satrec.inclo = parseFloat(tleLine2.substring(8, 16));
2333
2451
  satrec.nodeo = parseFloat(tleLine2.substring(17, 25));
2334
2452
  satrec.ecco = parseFloat(".".concat(tleLine2.substring(26, 33)));
@@ -2336,30 +2454,42 @@ var Sgp4 = /** @class */ (function () {
2336
2454
  satrec.mo = parseFloat(tleLine2.substring(43, 51));
2337
2455
  satrec.no = parseFloat(tleLine2.substring(52, 63));
2338
2456
  // ---- find no, ndot, nddot ----
2339
- satrec.no /= xpdotp; // rad/min
2457
+ satrec.no /= xpdotp; // Rad/min
2340
2458
  /** Ootk -- nexp and ibexp are calculated above using template literals */
2341
- // satrec.nddot = satrec.nddot * Math.pow(10.0, nexp);
2342
- // satrec.bstar = satrec.bstar * Math.pow(10.0, ibexp);
2343
- // ---- convert to sgp4 units ----
2344
- // satrec.a = (satrec.no * tumin) ** (-2.0 / 3.0);
2459
+ /*
2460
+ * Satrec.nddot = satrec.nddot * Math.pow(10.0, nexp);
2461
+ * satrec.bstar = satrec.bstar * Math.pow(10.0, ibexp);
2462
+ */
2463
+ /*
2464
+ * ---- convert to sgp4 units ----
2465
+ * satrec.a = (satrec.no * tumin) ** (-2.0 / 3.0);
2466
+ */
2345
2467
  /** Ootk -- Not sure why the following two lines are added. 1st and 2nd derivatives aren't even used anymore */
2346
- // satrec.ndot /= xpdotp * 1440.0; // ? * minperday
2347
- // satrec.nddot /= xpdotp * 1440.0 * 1440;
2468
+ /*
2469
+ * Satrec.ndot /= xpdotp * 1440.0; // ? * minperday
2470
+ * satrec.nddot /= xpdotp * 1440.0 * 1440;
2471
+ */
2348
2472
  // ---- find standard orbital elements ----
2349
2473
  satrec.inclo *= DEG2RAD;
2350
2474
  satrec.nodeo *= DEG2RAD;
2351
2475
  satrec.argpo *= DEG2RAD;
2352
2476
  satrec.mo *= DEG2RAD;
2353
- // sgp4fix not needed here
2354
- // satrec.alta = satrec.a * (1.0 + satrec.ecco) - 1.0;
2355
- // satrec.altp = satrec.a * (1.0 - satrec.ecco) - 1.0;
2356
- // ----------------------------------------------------------------
2357
- // find sgp4epoch time of element set
2358
- // remember that sgp4 uses units of days from 0 jan 1950 (sgp4epoch)
2359
- // and minutes from the epoch (time)
2360
- // ----------------------------------------------------------------
2361
- // ---------------- temp fix for years from 1957-2056 -------------------
2362
- // --------- correct fix will occur when year is 4-digit in tle ---------
2477
+ /*
2478
+ * Sgp4fix not needed here
2479
+ * satrec.alta = satrec.a * (1.0 + satrec.ecco) - 1.0;
2480
+ * satrec.altp = satrec.a * (1.0 - satrec.ecco) - 1.0;
2481
+ */
2482
+ /*
2483
+ * ----------------------------------------------------------------
2484
+ * find sgp4epoch time of element set
2485
+ * remember that sgp4 uses units of days from 0 jan 1950 (sgp4epoch)
2486
+ * and minutes from the epoch (time)
2487
+ * ----------------------------------------------------------------
2488
+ */
2489
+ /*
2490
+ * ---------------- temp fix for years from 1957-2056 -------------------
2491
+ * --------- correct fix will occur when year is 4-digit in tle ---------
2492
+ */
2363
2493
  if (satrec.epochyr < 57) {
2364
2494
  year = satrec.epochyr + 2000;
2365
2495
  }
@@ -2386,8 +2516,9 @@ var Sgp4 = /** @class */ (function () {
2386
2516
  xnodeo: satrec.nodeo,
2387
2517
  });
2388
2518
  return satrec;
2389
- }; // twoline2rv
2390
- /* -----------------------------------------------------------------------------
2519
+ }; // Twoline2rv
2520
+ /*
2521
+ * -----------------------------------------------------------------------------
2391
2522
  *
2392
2523
  * function gstime
2393
2524
  *
@@ -2411,10 +2542,11 @@ var Sgp4 = /** @class */ (function () {
2411
2542
  *
2412
2543
  * references :
2413
2544
  * vallado 2004, 191, eq 3-45
2414
- * --------------------------------------------------------------------------- */
2545
+ * ---------------------------------------------------------------------------
2546
+ */
2415
2547
  Sgp4.gstime = function (jdut1) {
2416
2548
  var tut1 = (jdut1 - 2451545.0) / 36525.0;
2417
- var temp = -6.2e-6 * tut1 * tut1 * tut1 + 0.093104 * tut1 * tut1 + (876600.0 * 3600 + 8640184.812866) * tut1 + 67310.54841; // sec
2549
+ var temp = -6.2e-6 * tut1 * tut1 * tut1 + 0.093104 * tut1 * tut1 + (876600.0 * 3600 + 8640184.812866) * tut1 + 67310.54841; // Sec
2418
2550
  temp = ((temp * DEG2RAD) / 240.0) % TAU; // 360/86400 = 1/240, to deg, to rad
2419
2551
  // ------------------------ check quadrants ---------------------
2420
2552
  if (temp < 0.0) {
@@ -2426,11 +2558,10 @@ var Sgp4 = /** @class */ (function () {
2426
2558
  if (x < 0.0) {
2427
2559
  return -1.0;
2428
2560
  }
2429
- else {
2430
- return 1.0;
2431
- }
2432
- }; // sgn
2433
- /* -----------------------------------------------------------------------------
2561
+ return 1.0;
2562
+ }; // Sgn
2563
+ /*
2564
+ * -----------------------------------------------------------------------------
2434
2565
  *
2435
2566
  * function mag
2436
2567
  *
@@ -2449,39 +2580,43 @@ var Sgp4 = /** @class */ (function () {
2449
2580
  *
2450
2581
  * coupling :
2451
2582
  * none.
2452
- * --------------------------------------------------------------------------- */
2583
+ * ---------------------------------------------------------------------------
2584
+ */
2453
2585
  Sgp4.mag = function (x) {
2454
2586
  return Math.sqrt(x[0] * x[0] + x[1] * x[1] + x[2] * x[2]);
2455
- }; // mag
2456
- /* -----------------------------------------------------------------------------
2457
- *
2458
- * procedure cross_SGP4
2459
- *
2460
- * this procedure crosses two vectors.
2461
- *
2462
- * author : david vallado 719-573-2600 1 mar 2001
2463
- *
2464
- * inputs description range / units
2465
- * vec1 - vector number 1
2466
- * vec2 - vector number 2
2467
- *
2468
- * outputs :
2469
- * outvec - vector result of a x b
2470
- *
2471
- * locals :
2472
- * none.
2473
- *
2474
- * coupling :
2475
- * mag magnitude of a vector
2476
- ---------------------------------------------------------------------------- */
2587
+ }; // Mag
2588
+ /*
2589
+ * -----------------------------------------------------------------------------
2590
+ *
2591
+ * procedure cross_SGP4
2592
+ *
2593
+ * this procedure crosses two vectors.
2594
+ *
2595
+ * author : david vallado 719-573-2600 1 mar 2001
2596
+ *
2597
+ * inputs description range / units
2598
+ * vec1 - vector number 1
2599
+ * vec2 - vector number 2
2600
+ *
2601
+ * outputs :
2602
+ * outvec - vector result of a x b
2603
+ *
2604
+ * locals :
2605
+ * none.
2606
+ *
2607
+ * coupling :
2608
+ * mag magnitude of a vector
2609
+ * ----------------------------------------------------------------------------
2610
+ */
2477
2611
  Sgp4.cross = function (vec1, vec2) {
2478
2612
  var outvec = [0, 0, 0];
2479
2613
  outvec[0] = vec1[1] * vec2[2] - vec1[2] * vec2[1];
2480
2614
  outvec[1] = vec1[2] * vec2[0] - vec1[0] * vec2[2];
2481
2615
  outvec[2] = vec1[0] * vec2[1] - vec1[1] * vec2[0];
2482
2616
  return outvec;
2483
- }; // end cross
2484
- /* -----------------------------------------------------------------------------
2617
+ }; // End cross
2618
+ /*
2619
+ * -----------------------------------------------------------------------------
2485
2620
  *
2486
2621
  * function dot_SGP4
2487
2622
  *
@@ -2501,11 +2636,13 @@ var Sgp4 = /** @class */ (function () {
2501
2636
  *
2502
2637
  * coupling :
2503
2638
  * none.
2504
- * --------------------------------------------------------------------------- */
2639
+ * ---------------------------------------------------------------------------
2640
+ */
2505
2641
  Sgp4.dot = function (x, y) {
2506
2642
  return x[0] * y[0] + x[1] * y[1] + x[2] * y[2];
2507
- }; // dot
2508
- /* -----------------------------------------------------------------------------
2643
+ }; // Dot
2644
+ /*
2645
+ * -----------------------------------------------------------------------------
2509
2646
  *
2510
2647
  * procedure angle_SGP4
2511
2648
  *
@@ -2527,7 +2664,8 @@ var Sgp4 = /** @class */ (function () {
2527
2664
  *
2528
2665
  * coupling :
2529
2666
  * dot dot product of two vectors
2530
- * --------------------------------------------------------------------------- */
2667
+ * ---------------------------------------------------------------------------
2668
+ */
2531
2669
  Sgp4.angle = function (vec1, vec2) {
2532
2670
  var small = 0.00000001;
2533
2671
  var unknown = 999999.1; /** Ootk -- original 'undefined' is protected in JS */
@@ -2535,14 +2673,15 @@ var Sgp4 = /** @class */ (function () {
2535
2673
  var magv2 = Sgp4.mag(vec2);
2536
2674
  if (magv1 * magv2 > small * small) {
2537
2675
  var temp = Sgp4.dot(vec1, vec2) / (magv1 * magv2);
2538
- if (Math.abs(temp) > 1.0)
2539
- temp = Sgp4.sgn(temp) * 1.0;
2676
+ if (Math.abs(temp) > 1.0) {
2677
+ temp = Number(Sgp4.sgn(temp));
2678
+ }
2540
2679
  return Math.acos(temp);
2541
2680
  }
2542
- else
2543
- return unknown;
2544
- }; // angle
2545
- /* -----------------------------------------------------------------------------
2681
+ return unknown;
2682
+ }; // Angle
2683
+ /*
2684
+ * -----------------------------------------------------------------------------
2546
2685
  *
2547
2686
  * function asinh_SGP4
2548
2687
  *
@@ -2561,11 +2700,13 @@ var Sgp4 = /** @class */ (function () {
2561
2700
  *
2562
2701
  * coupling :
2563
2702
  * none.
2564
- * --------------------------------------------------------------------------- */
2703
+ * ---------------------------------------------------------------------------
2704
+ */
2565
2705
  Sgp4.asinh = function (xval) {
2566
2706
  return Math.log(xval + Math.sqrt(xval * xval + 1.0));
2567
- }; // asinh
2568
- /* -----------------------------------------------------------------------------
2707
+ }; // Asinh
2708
+ /*
2709
+ * -----------------------------------------------------------------------------
2569
2710
  *
2570
2711
  * function newtonnu_SGP4
2571
2712
  *
@@ -2598,52 +2739,55 @@ var Sgp4 = /** @class */ (function () {
2598
2739
  *
2599
2740
  * references :
2600
2741
  * vallado 2013, 77, alg 5
2601
- * --------------------------------------------------------------------------- */
2742
+ * ---------------------------------------------------------------------------
2743
+ */
2602
2744
  Sgp4.newtonnu = function (ecc, nu) {
2603
2745
  // --------------------- implementation ---------------------
2604
2746
  var e0 = 999999.9;
2605
2747
  var m = 999999.9;
2606
2748
  var small = 0.00000001;
2607
- // --------------------------- circular ------------------------
2608
2749
  if (Math.abs(ecc) < small) {
2750
+ // --------------------------- circular ------------------------
2609
2751
  m = nu;
2610
2752
  e0 = nu;
2611
2753
  }
2612
- // ---------------------- elliptical -----------------------
2613
2754
  else if (ecc < 1.0 - small) {
2755
+ // ---------------------- elliptical -----------------------
2614
2756
  var sine = (Math.sqrt(1.0 - ecc * ecc) * Math.sin(nu)) / (1.0 + ecc * Math.cos(nu));
2615
2757
  var cose = (ecc + Math.cos(nu)) / (1.0 + ecc * Math.cos(nu));
2616
2758
  e0 = Math.atan2(sine, cose);
2617
2759
  m = e0 - ecc * Math.sin(e0);
2618
2760
  }
2619
- // -------------------- hyperbolic --------------------
2620
2761
  else if (ecc > 1.0 + small) {
2762
+ // -------------------- hyperbolic --------------------
2621
2763
  if (ecc > 1.0 && Math.abs(nu) + 0.00001 < PI - Math.acos(1.0 / ecc)) {
2622
2764
  var sine = (Math.sqrt(ecc * ecc - 1.0) * Math.sin(nu)) / (1.0 + ecc * Math.cos(nu));
2623
2765
  e0 = Sgp4.asinh(sine);
2624
2766
  m = ecc * Sgp4.sinh(e0) - e0;
2625
2767
  }
2626
2768
  }
2627
- // ----------------- parabolic ---------------------
2628
2769
  else if (Math.abs(nu) < (168.0 * PI) / 180.0) {
2770
+ // ----------------- parabolic ---------------------
2629
2771
  e0 = Math.tan(nu * 0.5);
2630
2772
  m = e0 + (e0 * e0 * e0) / 3.0;
2631
2773
  }
2632
2774
  if (ecc < 1.0) {
2633
- m = m % (2.0 * PI);
2634
- if (m < 0.0)
2635
- m = m + 2.0 * PI;
2636
- e0 = e0 % (2.0 * PI);
2775
+ m %= 2.0 * PI;
2776
+ if (m < 0.0) {
2777
+ m += 2.0 * PI;
2778
+ }
2779
+ e0 %= 2.0 * PI;
2637
2780
  }
2638
2781
  return {
2639
2782
  e0: e0,
2640
2783
  m: m,
2641
2784
  };
2642
- }; // newtonnu
2785
+ }; // Newtonnu
2643
2786
  Sgp4.sinh = function (x) {
2644
2787
  return (Math.exp(x) - Math.exp(-x)) / 2;
2645
2788
  };
2646
- /* -----------------------------------------------------------------------------
2789
+ /*
2790
+ * -----------------------------------------------------------------------------
2647
2791
  *
2648
2792
  * function rv2coe_SGP4
2649
2793
  *
@@ -2698,7 +2842,8 @@ var Sgp4 = /** @class */ (function () {
2698
2842
  *
2699
2843
  * references :
2700
2844
  * vallado 2013, 113, alg 9, ex 2-5
2701
- * --------------------------------------------------------------------------- */
2845
+ * ---------------------------------------------------------------------------
2846
+ */
2702
2847
  Sgp4.rv2coe = function (r, v, mus) {
2703
2848
  var nbar = [0, 0, 0];
2704
2849
  var ebar = [0, 0, 0];
@@ -2718,14 +2863,18 @@ var Sgp4 = /** @class */ (function () {
2718
2863
  var hk;
2719
2864
  var sme;
2720
2865
  var i;
2721
- // switch this to an integer msvs seems to have probelms with this and strncpy_s
2722
- //char typeorbit[2];
2866
+ /*
2867
+ * Switch this to an integer msvs seems to have probelms with this and strncpy_s
2868
+ * char typeorbit[2];
2869
+ */
2723
2870
  var typeorbit;
2724
- // here
2725
- // typeorbit = 1 = 'ei'
2726
- // typeorbit = 2 = 'ce'
2727
- // typeorbit = 3 = 'ci'
2728
- // typeorbit = 4 = 'ee'
2871
+ /*
2872
+ * Here
2873
+ * typeorbit = 1 = 'ei'
2874
+ * typeorbit = 2 = 'ce'
2875
+ * typeorbit = 3 = 'ci'
2876
+ * typeorbit = 4 = 'ee'
2877
+ */
2729
2878
  var halfpi = 0.5 * PI;
2730
2879
  var small = 0.00000001;
2731
2880
  var unknown = 999999.1; /** Ootk -- original undefined is illegal in JS */
@@ -2743,21 +2892,26 @@ var Sgp4 = /** @class */ (function () {
2743
2892
  magn = Sgp4.mag(nbar);
2744
2893
  var c1 = magv * magv - mus / magr;
2745
2894
  rdotv = Sgp4.dot(r, v);
2746
- for (i = 0; i <= 2; i++)
2895
+ for (i = 0; i <= 2; i++) {
2747
2896
  ebar[i] = (c1 * r[i] - rdotv * v[i]) / mus;
2897
+ }
2748
2898
  ecc = Sgp4.mag(ebar);
2749
2899
  // ------------ find a e and semi-latus rectum ----------
2750
2900
  sme = magv * magv * 0.5 - mus / magr;
2751
- if (Math.abs(sme) > small)
2901
+ if (Math.abs(sme) > small) {
2752
2902
  a = -mus / (2.0 * sme);
2753
- else
2903
+ }
2904
+ else {
2754
2905
  a = infinite;
2906
+ }
2755
2907
  p = (magh * magh) / mus;
2756
2908
  // ----------------- find inclination -------------------
2757
2909
  hk = hbar[2] / magh;
2758
2910
  incl = Math.acos(hk);
2759
- // -------- determine type of orbit for later use --------
2760
- // ------ elliptical, parabolic, hyperbolic inclined -------
2911
+ /*
2912
+ * -------- determine type of orbit for later use --------
2913
+ * ------ elliptical, parabolic, hyperbolic inclined -------
2914
+ */
2761
2915
  typeorbit = 1;
2762
2916
  if (ecc < small) {
2763
2917
  // ---------------- circular equatorial ---------------
@@ -2778,68 +2932,86 @@ var Sgp4 = /** @class */ (function () {
2778
2932
  // ---------- find right ascension of the ascending node ------------
2779
2933
  if (magn > small) {
2780
2934
  var temp = nbar[0] / magn;
2781
- if (Math.abs(temp) > 1.0)
2935
+ if (Math.abs(temp) > 1.0) {
2782
2936
  temp = Sgp4.sgn(temp);
2937
+ }
2783
2938
  omega = Math.acos(temp);
2784
- if (nbar[1] < 0.0)
2939
+ if (nbar[1] < 0.0) {
2785
2940
  omega = TAU - omega;
2941
+ }
2786
2942
  }
2787
- else
2943
+ else {
2788
2944
  omega = unknown;
2945
+ }
2789
2946
  // ---------------- find argument of perigee ---------------
2790
- if (typeorbit == 1) {
2947
+ if (typeorbit === 1) {
2791
2948
  argp = Sgp4.angle(nbar, ebar);
2792
- if (ebar[2] < 0.0)
2949
+ if (ebar[2] < 0.0) {
2793
2950
  argp = TAU - argp;
2951
+ }
2794
2952
  }
2795
- else
2953
+ else {
2796
2954
  argp = unknown;
2955
+ }
2797
2956
  // ------------ find true anomaly at epoch -------------
2798
- if (typeorbit == 1 || typeorbit == 4) {
2957
+ if (typeorbit === 1 || typeorbit === 4) {
2799
2958
  nu = Sgp4.angle(ebar, r);
2800
- if (rdotv < 0.0)
2959
+ if (rdotv < 0.0) {
2801
2960
  nu = TAU - nu;
2961
+ }
2802
2962
  }
2803
- else
2963
+ else {
2804
2964
  nu = unknown;
2965
+ }
2805
2966
  // ---- find argument of latitude - circular inclined -----
2806
- if (typeorbit == 3) {
2967
+ if (typeorbit === 3) {
2807
2968
  arglat = Sgp4.angle(nbar, r);
2808
- if (r[2] < 0.0)
2969
+ if (r[2] < 0.0) {
2809
2970
  arglat = TAU - arglat;
2971
+ }
2810
2972
  m = arglat;
2811
2973
  }
2812
- else
2974
+ else {
2813
2975
  arglat = unknown;
2814
- if (ecc > small && typeorbit == 4) {
2976
+ }
2977
+ if (ecc > small && typeorbit === 4) {
2815
2978
  var temp = ebar[0] / ecc;
2816
- if (Math.abs(temp) > 1.0)
2979
+ if (Math.abs(temp) > 1.0) {
2817
2980
  temp = Sgp4.sgn(temp);
2981
+ }
2818
2982
  lonper = Math.acos(temp);
2819
- if (ebar[1] < 0.0)
2983
+ if (ebar[1] < 0.0) {
2820
2984
  lonper = TAU - lonper;
2821
- if (incl > halfpi)
2985
+ }
2986
+ if (incl > halfpi) {
2822
2987
  lonper = TAU - lonper;
2988
+ }
2823
2989
  }
2824
- else
2990
+ else {
2825
2991
  lonper = unknown;
2992
+ }
2826
2993
  // -------- find true longitude - circular equatorial ------
2827
- if (magr > small && typeorbit == 2) {
2994
+ if (magr > small && typeorbit === 2) {
2828
2995
  var temp = r[0] / magr;
2829
- if (Math.abs(temp) > 1.0)
2996
+ if (Math.abs(temp) > 1.0) {
2830
2997
  temp = Sgp4.sgn(temp);
2998
+ }
2831
2999
  truelon = Math.acos(temp);
2832
- if (r[1] < 0.0)
3000
+ if (r[1] < 0.0) {
2833
3001
  truelon = TAU - truelon;
2834
- if (incl > halfpi)
3002
+ }
3003
+ if (incl > halfpi) {
2835
3004
  truelon = TAU - truelon;
3005
+ }
2836
3006
  m = truelon;
2837
3007
  }
2838
- else
3008
+ else {
2839
3009
  truelon = unknown;
3010
+ }
2840
3011
  // ------------ find mean anomaly for all orbits -----------
2841
- if (typeorbit == 1 || typeorbit == 4)
3012
+ if (typeorbit === 1 || typeorbit === 4) {
2842
3013
  m = Sgp4.newtonnu(ecc, nu).m;
3014
+ }
2843
3015
  }
2844
3016
  else {
2845
3017
  p = unknown;
@@ -2867,8 +3039,9 @@ var Sgp4 = /** @class */ (function () {
2867
3039
  truelon: truelon,
2868
3040
  lonper: lonper,
2869
3041
  };
2870
- }; // rv2coe
2871
- /* -----------------------------------------------------------------------------
3042
+ }; // Rv2coe
3043
+ /*
3044
+ * -----------------------------------------------------------------------------
2872
3045
  *
2873
3046
  * procedure jday
2874
3047
  *
@@ -2900,20 +3073,26 @@ var Sgp4 = /** @class */ (function () {
2900
3073
  * references :
2901
3074
  * vallado 2013, 183, alg 14, ex 3-4
2902
3075
  *
2903
- * --------------------------------------------------------------------------- */
3076
+ * ---------------------------------------------------------------------------
3077
+ */
2904
3078
  Sgp4.jday = function (year, mon, day, hr, minute, sec) {
2905
- var jd = 367.0 * year - Math.floor(7 * (year + Math.floor((mon + 9) / 12.0)) * 0.25) + Math.floor((275 * mon) / 9.0) + day + 1721013.5; // use - 678987.0 to go to mjd directly
3079
+ var jd = 367.0 * year -
3080
+ Math.floor(7 * (year + Math.floor((mon + 9) / 12.0)) * 0.25) +
3081
+ Math.floor((275 * mon) / 9.0) +
3082
+ day +
3083
+ 1721013.5; // Use - 678987.0 to go to mjd directly
2906
3084
  var jdFrac = (sec + minute * 60.0 + hr * 3600.0) / 86400.0;
2907
- // check that the day and fractional day are correct
3085
+ // Check that the day and fractional day are correct
2908
3086
  if (Math.abs(jdFrac) > 1.0) {
2909
3087
  var dtt = Math.floor(jdFrac);
2910
- jd = jd + dtt;
2911
- jdFrac = jdFrac - dtt;
3088
+ jd += dtt;
3089
+ jdFrac -= dtt;
2912
3090
  }
2913
3091
  // - 0.5*sgn(100.0*year + mon - 190002.5) + 0.5;
2914
3092
  return { jd: jd, jdFrac: jdFrac };
2915
- }; // jday
2916
- /* -----------------------------------------------------------------------------
3093
+ }; // Jday
3094
+ /*
3095
+ * -----------------------------------------------------------------------------
2917
3096
  *
2918
3097
  * procedure days2mdhms
2919
3098
  *
@@ -2948,14 +3127,17 @@ var Sgp4 = /** @class */ (function () {
2948
3127
  *
2949
3128
  * coupling :
2950
3129
  * none.
2951
- * --------------------------------------------------------------------------- */
3130
+ * ---------------------------------------------------------------------------
3131
+ */
2952
3132
  Sgp4.days2mdhms = function (year, days) {
2953
3133
  var lmonth = [31, year % 4 === 0 ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
2954
3134
  var dayofyr = Math.floor(days);
2955
3135
  // ----------------- find month and day of month ----------------
2956
3136
  /** Ootk -- Incorporated in the above declaration */
2957
- // if ((year % 4) == 0)
2958
- // lmonth[2] = 29;
3137
+ /*
3138
+ * If ((year % 4) == 0)
3139
+ * lmonth[2] = 29;
3140
+ */
2959
3141
  var i = 1;
2960
3142
  var inttemp = 0;
2961
3143
  while (dayofyr > inttemp + lmonth[i - 1] && i < 12) {
@@ -2977,8 +3159,9 @@ var Sgp4 = /** @class */ (function () {
2977
3159
  minute: minute,
2978
3160
  sec: sec,
2979
3161
  };
2980
- }; // days2mdhms
2981
- /* -----------------------------------------------------------------------------
3162
+ }; // Days2mdhms
3163
+ /*
3164
+ * -----------------------------------------------------------------------------
2982
3165
  *
2983
3166
  * procedure invjday
2984
3167
  *
@@ -3017,20 +3200,21 @@ var Sgp4 = /** @class */ (function () {
3017
3200
  *
3018
3201
  * references :
3019
3202
  * vallado 2013, 203, alg 22, ex 3-13
3020
- * --------------------------------------------------------------------------- */
3203
+ * ---------------------------------------------------------------------------
3204
+ */
3021
3205
  Sgp4.invjday = function (jd, jdfrac) {
3022
3206
  var leapyrs;
3023
3207
  var days;
3024
- // check jdfrac for multiple days
3208
+ // Check jdfrac for multiple days
3025
3209
  if (Math.abs(jdfrac) >= 1.0) {
3026
- jd = jd + Math.floor(jdfrac);
3027
- jdfrac = jdfrac - Math.floor(jdfrac);
3210
+ jd += Math.floor(jdfrac);
3211
+ jdfrac -= Math.floor(jdfrac);
3028
3212
  }
3029
- // check for fraction of a day included in the jd
3213
+ // Check for fraction of a day included in the jd
3030
3214
  var dt = jd - Math.floor(jd) - 0.5;
3031
3215
  if (Math.abs(dt) > 0.00000001) {
3032
- jd = jd - dt;
3033
- jdfrac = jdfrac + dt;
3216
+ jd -= dt;
3217
+ jdfrac += dt;
3034
3218
  }
3035
3219
  /* --------------- find year and days of the year --------------- */
3036
3220
  var temp = jd - 2415019.5;
@@ -3040,7 +3224,7 @@ var Sgp4 = /** @class */ (function () {
3040
3224
  days = Math.floor(temp - ((year - 1900) * 365.0 + leapyrs));
3041
3225
  /* ------------ check for case of beginning of a year ----------- */
3042
3226
  if (days + jdfrac < 1.0) {
3043
- year = year - 1;
3227
+ year -= 1;
3044
3228
  leapyrs = Math.floor((year - 1901) * 0.25);
3045
3229
  days = Math.floor(temp - ((year - 1900) * 365.0 + leapyrs));
3046
3230
  }
@@ -3054,7 +3238,7 @@ var Sgp4 = /** @class */ (function () {
3054
3238
  minute: minute,
3055
3239
  sec: sec,
3056
3240
  };
3057
- }; // invjday
3241
+ }; // Invjday
3058
3242
  return Sgp4;
3059
3243
  }());
3060
3244
  export { Sgp4 };