ootk 1.0.8 → 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;
@@ -875,79 +908,81 @@ var Sgp4 = /** @class */ (function () {
875
908
  xli: xli,
876
909
  xni: xni,
877
910
  };
878
- }; // dsinit
879
- /*-----------------------------------------------------------------------------
880
- *
881
- * procedure dspace
882
- *
883
- * this procedure provides deep space contributions to mean elements for
884
- * perturbing third body. these effects have been averaged over one
885
- * revolution of the sun and moon. for earth resonance effects, the
886
- * effects have been averaged over no revolutions of the satellite.
887
- * (mean motion)
888
- *
889
- * author : david vallado 719-573-2600 28 jun 2005
890
- *
891
- * inputs :
892
- * d2201, d2211, d3210, d3222, d4410, d4422, d5220, d5232, d5421, d5433 -
893
- * dedt -
894
- * del1, del2, del3 -
895
- * didt -
896
- * dmdt -
897
- * dnodt -
898
- * domdt -
899
- * irez - flag for resonance 0-none, 1-one day, 2-half day
900
- * argpo - argument of perigee
901
- * argpdot - argument of perigee dot (rate)
902
- * t - time
903
- * tc -
904
- * gsto - gst
905
- * xfact -
906
- * xlamo -
907
- * no - mean motion
908
- * atime -
909
- * em - eccentricity
910
- * ft -
911
- * argpm - argument of perigee
912
- * inclm - inclination
913
- * xli -
914
- * mm - mean anomaly
915
- * xni - mean motion
916
- * nodem - right ascension of ascending node
917
- *
918
- * outputs :
919
- * atime -
920
- * em - eccentricity
921
- * argpm - argument of perigee
922
- * inclm - inclination
923
- * xli -
924
- * mm - mean anomaly
925
- * xni -
926
- * nodem - right ascension of ascending node
927
- * dndt -
928
- * nm - mean motion
929
- *
930
- * locals :
931
- * delt -
932
- * ft -
933
- * theta -
934
- * x2li -
935
- * x2omi -
936
- * xl -
937
- * xldot -
938
- * xnddt -
939
- * xndt -
940
- * xomi -
941
- *
942
- * coupling :
943
- * none -
944
- *
945
- * references :
946
- * hoots, roehrich, norad spacetrack report #3 1980
947
- * hoots, norad spacetrack report #6 1986
948
- * hoots, schumacher and glover 2004
949
- * vallado, crawford, hujsak, kelso 2006
950
- ----------------------------------------------------------------------------*/
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
+ */
951
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) {
952
987
  /** Ootk -- Some variables imported from outside the class at the top */
953
988
  var fasx2 = 0.13130908;
@@ -958,7 +993,9 @@ var Sgp4 = /** @class */ (function () {
958
993
  var g44 = 1.8014998;
959
994
  var g52 = 1.050833;
960
995
  var g54 = 4.4108898;
961
- 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
962
999
  var stepp = 720.0;
963
1000
  var stepn = -720.0;
964
1001
  var step2 = 259200.0;
@@ -970,29 +1007,33 @@ var Sgp4 = /** @class */ (function () {
970
1007
  argpm += domdt * t;
971
1008
  nodem += dnodt * t;
972
1009
  mm += dmdt * t;
973
- // sgp4fix for negative inclinations
974
- // the following if statement should be commented out
975
- // if (inclm < 0.0)
976
- // {
977
- // inclm = -inclm;
978
- // argpm = argpm - PI;
979
- // nodem = nodem + PI;
980
- // }
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
+ */
981
1020
  /* - update resonances : numerical (euler-maclaurin) integration - */
982
1021
  /* ------------------------- epoch restart ---------------------- */
983
- // sgp4fix for propagator problems
984
- // the following integration works for negative time steps and periods
985
- // the specific changes are unknown because the original code was so convoluted
986
- // sgp4fix take out atime = 0.0 and fix for faster operation
987
- // 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 */
988
1029
  if (irez !== 0) {
989
- // sgp4fix streamline check
1030
+ // Sgp4fix streamline check
990
1031
  if (atime === 0.0 || t * atime <= 0.0 || Math.abs(t) < Math.abs(atime)) {
991
1032
  atime = 0.0;
992
1033
  xni = no;
993
1034
  xli = xlamo;
994
1035
  }
995
- // sgp4fix move check outside loop
1036
+ // Sgp4fix move check outside loop
996
1037
  var delt = void 0;
997
1038
  if (t > 0.0) {
998
1039
  delt = stepp;
@@ -1000,11 +1041,13 @@ var Sgp4 = /** @class */ (function () {
1000
1041
  else {
1001
1042
  delt = stepn;
1002
1043
  }
1003
- var xndt = void 0, xldot = void 0, xnddt = void 0, xomi = void 0, x2omi = void 0, x2li = void 0, ft = void 0;
1004
- 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
1005
1046
  while (iretn === 381) {
1006
- // ------------------- dot terms calculated -------------
1007
- // ----------- near - synchronous resonance terms -------
1047
+ /*
1048
+ * ------------------- dot terms calculated -------------
1049
+ * ----------- near - synchronous resonance terms -------
1050
+ */
1008
1051
  if (irez !== 2) {
1009
1052
  xndt =
1010
1053
  del1 * Math.sin(xli - fasx2) + del2 * Math.sin(2.0 * (xli - fasx4)) + del3 * Math.sin(3.0 * (xli - fasx6));
@@ -1045,10 +1088,12 @@ var Sgp4 = /** @class */ (function () {
1045
1088
  d5433 * Math.cos(-xomi + x2li - g54);
1046
1089
  xnddt *= xldot;
1047
1090
  }
1048
- // ----------------------- integrator -------------------
1049
- // sgp4fix move end checks to end of routine
1091
+ /*
1092
+ * ----------------------- integrator -------------------
1093
+ * sgp4fix move end checks to end of routine
1094
+ */
1050
1095
  if (Math.abs(t - atime) >= stepp) {
1051
- // iret = 0; /** Ootk -- This has no value */
1096
+ // Iret = 0; /** Ootk -- This has no value */
1052
1097
  iretn = 381;
1053
1098
  }
1054
1099
  else {
@@ -1060,7 +1105,7 @@ var Sgp4 = /** @class */ (function () {
1060
1105
  xni += xndt * delt + xnddt * step2;
1061
1106
  atime += delt;
1062
1107
  }
1063
- } // while iretn = 381
1108
+ } // While iretn = 381
1064
1109
  nm = xni + xndt * ft + xnddt * ft * ft * 0.5;
1065
1110
  var xl = xli + xldot * ft + xndt * ft * ft * 0.5;
1066
1111
  if (irez !== 1) {
@@ -1074,76 +1119,82 @@ var Sgp4 = /** @class */ (function () {
1074
1119
  nm = no + dndt;
1075
1120
  }
1076
1121
  return [em, argpm, inclm, mm, nodem, nm];
1077
- }; // dspace
1078
- /*-----------------------------------------------------------------------------
1079
- *
1080
- * procedure initl
1081
- *
1082
- * this procedure initializes the sgp4 propagator. all the initialization is
1083
- * consolidated here instead of having multiple loops inside other routines.
1084
- *
1085
- * author : david vallado 719-573-2600 28 jun 2005
1086
- *
1087
- * inputs :
1088
- * satn - satellite number - not needed, placed in satrec
1089
- * xke - reciprocal of tumin
1090
- * j2 - j2 zonal harmonic
1091
- * ecco - eccentricity 0.0 - 1.0
1092
- * epoch - epoch time in days from jan 0, 1950. 0 hr
1093
- * inclo - inclination of satellite
1094
- * no - mean motion of satellite
1095
- *
1096
- * outputs :
1097
- * ainv - 1.0 / a
1098
- * ao - semi major axis
1099
- * con41 -
1100
- * con42 - 1.0 - 5.0 cos(i)
1101
- * cosio - cosine of inclination
1102
- * cosio2 - cosio squared
1103
- * eccsq - eccentricity squared
1104
- * method - flag for deep space 'd', 'n'
1105
- * omeosq - 1.0 - ecco * ecco
1106
- * posq - semi-parameter squared
1107
- * rp - radius of perigee
1108
- * rteosq - square root of (1.0 - ecco*ecco)
1109
- * sinio - sine of inclination
1110
- * gsto - gst at time of observation rad
1111
- * no - mean motion of satellite
1112
- *
1113
- * locals :
1114
- * ak -
1115
- * d1 -
1116
- * del -
1117
- * adel -
1118
- * po -
1119
- *
1120
- * coupling :
1121
- * getgravconst- no longer used
1122
- * gstime - find greenwich sidereal time from the julian date
1123
- *
1124
- * references :
1125
- * hoots, roehrich, norad spacetrack report #3 1980
1126
- * hoots, norad spacetrack report #6 1986
1127
- * hoots, schumacher and glover 2004
1128
- * vallado, crawford, hujsak, kelso 2006
1129
- ----------------------------------------------------------------------------*/
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
+ */
1130
1177
  Sgp4.initl = function (options) {
1131
- // sgp4fix satn not needed. include in satrec in case needed later
1132
- // int satn,
1133
- // sgp4fix just pass in xke and j2
1134
- // 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
+ */
1135
1184
  var opsmode = options.opsmode, ecco = options.ecco, epoch = options.epoch, inclo = options.inclo, xke = options.xke, j2 = options.j2;
1136
1185
  var no = options.no;
1137
1186
  /* --------------------- local variables ------------------------ */
1138
1187
  var PI = Math.PI;
1139
1188
  var TAU = PI * 2;
1140
1189
  var x2o3 = 2.0 / 3.0;
1141
- // sgp4fix use old way of finding gst
1190
+ // Sgp4fix use old way of finding gst
1142
1191
  /** Ootk -- Some variables imported from outside the class at the top */
1143
- // ----------------------- earth constants ---------------------
1144
- // sgp4fix identify constants and allow alternate values
1145
- // only xke and j2 are used here so pass them in directly
1146
- // 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
+ */
1147
1198
  // ------------- calculate auxillary epoch quantities ----------
1148
1199
  var eccsq = ecco * ecco;
1149
1200
  var omeosq = 1.0 - eccsq;
@@ -1156,7 +1207,7 @@ var Sgp4 = /** @class */ (function () {
1156
1207
  var delPrime = d1 / (ak * ak);
1157
1208
  var adel = ak * (1.0 - delPrime * delPrime - delPrime * (1.0 / 3.0 + (134.0 * delPrime * delPrime) / 81.0));
1158
1209
  delPrime = d1 / (adel * adel);
1159
- no = no / (1.0 + delPrime);
1210
+ no /= 1.0 + delPrime;
1160
1211
  var ao = Math.pow((xke / no), x2o3);
1161
1212
  var sinio = Math.sin(inclo);
1162
1213
  var po = ao * omeosq;
@@ -1166,18 +1217,24 @@ var Sgp4 = /** @class */ (function () {
1166
1217
  var posq = po * po;
1167
1218
  var rp = ao * (1.0 - ecco);
1168
1219
  var method = 'n';
1169
- // sgp4fix modern approach to finding sidereal time
1220
+ // Sgp4fix modern approach to finding sidereal time
1170
1221
  /** Ootk -- Continue allowing AFSPC mode for SGP4 Validation */
1171
1222
  var gsto;
1172
- if (opsmode == 'a') {
1173
- // sgp4fix use old way of finding gst
1174
- // 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
+ */
1175
1228
  var ts70 = epoch - 7305.0;
1176
1229
  var ds70 = Math.floor(ts70 + 1.0e-8);
1177
1230
  var tfrac = ts70 - ds70;
1178
- // 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
1179
1234
  var c1 = 1.72027916940703639e-2;
1235
+ // eslint-disable-next-line @typescript-eslint/no-loss-of-precision
1180
1236
  var thgr70 = 1.7321343856509374;
1237
+ // eslint-disable-next-line @typescript-eslint/no-loss-of-precision
1181
1238
  var fk5r = 5.07551419432269442e-15;
1182
1239
  var c1p2p = c1 + TAU;
1183
1240
  gsto = (thgr70 + c1 * ds70 + c1p2p * tfrac + ts70 * ts70 * fk5r) % TAU;
@@ -1206,95 +1263,99 @@ var Sgp4 = /** @class */ (function () {
1206
1263
  sinio: sinio,
1207
1264
  gsto: gsto,
1208
1265
  };
1209
- }; // initl
1210
- /*-----------------------------------------------------------------------------
1211
- *
1212
- * procedure sgp4init
1213
- *
1214
- * this procedure initializes variables for sgp4.
1215
- *
1216
- * author : david vallado 719-573-2600 28 jun 2005
1217
- *
1218
- * inputs :
1219
- * opsmode - mode of operation afspc or improved 'a', 'i'
1220
- * whichconst - which set of constants to use 72, 84
1221
- * satn - satellite number
1222
- * bstar - sgp4 type drag coefficient kg/m2er
1223
- * ecco - eccentricity
1224
- * epoch - epoch time in days from jan 0, 1950. 0 hr
1225
- * argpo - argument of perigee (output if ds)
1226
- * inclo - inclination
1227
- * mo - mean anomaly (output if ds)
1228
- * no - mean motion
1229
- * nodeo - right ascension of ascending node
1230
- *
1231
- * outputs :
1232
- * rec - common values for subsequent calls
1233
- * return code - non-zero on error.
1234
- * 1 - mean elements, ecc >= 1.0 or ecc < -0.001 or a < 0.95 er
1235
- * 2 - mean motion less than 0.0
1236
- * 3 - pert elements, ecc < 0.0 or ecc > 1.0
1237
- * 4 - semi-latus rectum < 0.0
1238
- * 5 - epoch elements are sub-orbital
1239
- * 6 - satellite has decayed
1240
- *
1241
- * locals :
1242
- * cnodm , snodm , cosim , sinim , cosomm , sinomm
1243
- * cc1sq , cc2 , cc3
1244
- * coef , coef1
1245
- * cosio4 -
1246
- * day -
1247
- * dndt -
1248
- * em - eccentricity
1249
- * emsq - eccentricity squared
1250
- * eeta -
1251
- * etasq -
1252
- * gam -
1253
- * argpm - argument of perigee
1254
- * nodem -
1255
- * inclm - inclination
1256
- * mm - mean anomaly
1257
- * nm - mean motion
1258
- * perige - perigee
1259
- * PInvsq -
1260
- * psisq -
1261
- * qzms24 -
1262
- * rtemsq -
1263
- * s1, s2, s3, s4, s5, s6, s7 -
1264
- * sfour -
1265
- * ss1, ss2, ss3, ss4, ss5, ss6, ss7 -
1266
- * sz1, sz2, sz3
1267
- * sz11, sz12, sz13, sz21, sz22, sz23, sz31, sz32, sz33 -
1268
- * tc -
1269
- * temp -
1270
- * temp1, temp2, temp3 -
1271
- * tsi -
1272
- * xPIdot -
1273
- * xhdot1 -
1274
- * z1, z2, z3 -
1275
- * z11, z12, z13, z21, z22, z23, z31, z32, z33 -
1276
- *
1277
- * coupling :
1278
- * getgravconst-
1279
- * initl -
1280
- * dscom -
1281
- * dpper -
1282
- * dsinit -
1283
- * sgp4 -
1284
- *
1285
- * references :
1286
- * hoots, roehrich, norad spacetrack report #3 1980
1287
- * hoots, norad spacetrack report #6 1986
1288
- * hoots, schumacher and glover 2004
1289
- * vallado, crawford, hujsak, kelso 2006
1290
- ----------------------------------------------------------------------------*/
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
+ */
1291
1350
  Sgp4.sgp4init = function (satrec, options) {
1292
1351
  /* eslint-disable no-param-reassign */
1293
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;
1294
1353
  /* ------------------------ initialization --------------------- */
1295
- // sgp4fix divisor for divide by zero check on inclination
1296
- // the old check used 1.0 + Math.cos(PI-1.0e-9), but then compared it to
1297
- // 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
+ */
1298
1359
  // ----------- set all near earth variables to zero ------------
1299
1360
  satrec.isimp = 0;
1300
1361
  satrec.method = 'n';
@@ -1381,8 +1442,10 @@ var Sgp4 = /** @class */ (function () {
1381
1442
  satrec.xli = 0.0;
1382
1443
  satrec.xni = 0.0;
1383
1444
  /* ------------------------ earth constants ----------------------- */
1384
- // sgp4fix identify constants and allow alternate values
1385
- // 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
+ */
1386
1449
  var gravResults = Sgp4.getgravconst(whichconst);
1387
1450
  satrec.tumin = gravResults.tumin;
1388
1451
  satrec.mus = gravResults.mus;
@@ -1396,11 +1459,12 @@ var Sgp4 = /** @class */ (function () {
1396
1459
  var j4 = gravResults.j4;
1397
1460
  var xke = gravResults.xke;
1398
1461
  var j3oj2 = gravResults.j3oj2;
1399
- //-------------------------------------------------------------------------
1462
+ // -------------------------------------------------------------------------
1400
1463
  satrec.error = 0;
1401
1464
  satrec.operationmode = opsmode;
1402
- // new alpha5 or 9-digit number
1403
- /** 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
1404
1468
  * Ex. A2525 = 102525
1405
1469
  * Ex. Z1234 = 351234
1406
1470
  */
@@ -1411,33 +1475,39 @@ var Sgp4 = /** @class */ (function () {
1411
1475
  else {
1412
1476
  satrec.satnum = satn;
1413
1477
  }
1414
- // sgp4fix - note the following variables are also passed directly via satrec.
1415
- // it is possible to streamline the sgp4init call by deleting the "x"
1416
- // variables, but the user would need to set the satrec.* values first. we
1417
- // 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
+ */
1418
1484
  satrec.bstar = xbstar;
1419
- // sgp4fix allow additional parameters in the struct
1485
+ // Sgp4fix allow additional parameters in the struct
1420
1486
  satrec.ndot = xndot;
1421
1487
  satrec.nddot = xnddot;
1422
1488
  satrec.ecco = xecco;
1423
1489
  satrec.argpo = xargpo;
1424
1490
  satrec.inclo = xinclo;
1425
1491
  satrec.mo = xmo;
1426
- // sgp4fix rename variables to clarify which mean motion is intended
1492
+ // Sgp4fix rename variables to clarify which mean motion is intended
1427
1493
  satrec.no = xno;
1428
1494
  satrec.nodeo = xnodeo;
1429
- // single averaged mean elements
1430
- // satrec.am = satrec.em = satrec.im = satrec.Om = satrec.mm = satrec.nm = 0.0;
1431
- // ------------------------ earth constants -----------------------
1432
- // sgp4fix identify constants and allow alternate values
1433
- // 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
+ */
1434
1504
  var ss = 78.0 / satrec.radiusearthkm + 1.0;
1435
- // sgp4fix use multiply for speed instead of pow
1505
+ // Sgp4fix use multiply for speed instead of pow
1436
1506
  var qzms2ttemp = (120.0 - 78.0) / satrec.radiusearthkm;
1437
1507
  var qzms2t = qzms2ttemp * qzms2ttemp * qzms2ttemp * qzms2ttemp;
1438
1508
  satrec.init = 'y';
1439
1509
  satrec.t = 0.0;
1440
- // sgp4fix remove satn as it is not needed in initl
1510
+ // Sgp4fix remove satn as it is not needed in initl
1441
1511
  var initlOptions = {
1442
1512
  ecco: satrec.ecco,
1443
1513
  epoch: epoch,
@@ -1453,18 +1523,20 @@ var Sgp4 = /** @class */ (function () {
1453
1523
  satrec.no = initlResult.no;
1454
1524
  satrec.con41 = initlResult.con41;
1455
1525
  satrec.gsto = initlResult.gsto;
1456
- 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));
1457
1527
  satrec.alta = satrec.a * (1.0 + satrec.ecco) - 1.0;
1458
1528
  satrec.altp = satrec.a * (1.0 - satrec.ecco) - 1.0;
1459
1529
  satrec.error = 0;
1460
- // sgp4fix remove this check as it is unnecessary
1461
- // the mrt check in sgp4 handles decaying satellite cases even if the starting
1462
- // condition is below the surface of te earth
1463
- // if (rp < 1.0)
1464
- // {
1465
- // printf("// *** satn%d epoch elts sub-orbital ***\n", satn);
1466
- // satrec.error = 5;
1467
- // }
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
+ */
1468
1540
  if (omeosq >= 0.0 || satrec.no >= 0.0) {
1469
1541
  satrec.isimp = 0;
1470
1542
  if (rp < 220.0 / satrec.radiusearthkm + 1.0) {
@@ -1479,7 +1551,7 @@ var Sgp4 = /** @class */ (function () {
1479
1551
  if (perige < 98.0) {
1480
1552
  sfour = 20.0;
1481
1553
  }
1482
- // sgp4fix use multiply for speed instead of pow
1554
+ // Sgp4fix use multiply for speed instead of pow
1483
1555
  var qzms24temp = (120.0 - sfour) / satrec.radiusearthkm;
1484
1556
  qzms24 = qzms24temp * qzms24temp * qzms24temp * qzms24temp;
1485
1557
  sfour = sfour / satrec.radiusearthkm + 1.0;
@@ -1536,7 +1608,7 @@ var Sgp4 = /** @class */ (function () {
1536
1608
  }
1537
1609
  satrec.nodecf = 3.5 * omeosq * xhdot1 * satrec.cc1;
1538
1610
  satrec.t2cof = 1.5 * satrec.cc1;
1539
- // sgp4fix for divide by zero with xinco = 180 deg
1611
+ // Sgp4fix for divide by zero with xinco = 180 deg
1540
1612
  if (Math.abs(cosio + 1.0) > 1.5e-12) {
1541
1613
  satrec.xlcof = (-0.25 * j3oj2 * sinio * (3.0 + 5.0 * cosio)) / (1.0 + cosio);
1542
1614
  }
@@ -1544,7 +1616,7 @@ var Sgp4 = /** @class */ (function () {
1544
1616
  satrec.xlcof = (-0.25 * j3oj2 * sinio * (3.0 + 5.0 * cosio)) / temp4;
1545
1617
  }
1546
1618
  satrec.aycof = -0.5 * j3oj2 * sinio;
1547
- // sgp4fix use multiply for speed instead of pow
1619
+ // Sgp4fix use multiply for speed instead of pow
1548
1620
  var delmotemp = 1.0 + satrec.eta * Math.cos(satrec.mo);
1549
1621
  satrec.delmo = delmotemp * delmotemp * delmotemp;
1550
1622
  satrec.sinmao = Math.sin(satrec.mo);
@@ -1763,109 +1835,119 @@ var Sgp4 = /** @class */ (function () {
1763
1835
  12.0 * satrec.cc1 * satrec.d3 +
1764
1836
  6.0 * satrec.d2 * satrec.d2 +
1765
1837
  15.0 * cc1sq * (2.0 * satrec.d2 + cc1sq));
1766
- } // if omeosq = 0 ...
1767
- /* finally propogate to zero epoch to initialize all others. */
1768
- // sgp4fix take out check to let satellites process until they are actually below earth surface
1769
- // if(satrec.error == 0)
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
+ */
1770
1844
  }
1771
1845
  Sgp4.propagate(satrec, 0);
1772
1846
  satrec.init = 'n';
1773
- //sgp4fix return boolean. satrec.error contains any error codes
1774
- // return satrec; -- no reason to return anything in JS
1775
- }; // sgp4init
1776
- /*----------------------------------------------------------------------------
1777
- *
1778
- * procedure sgp4
1779
- *
1780
- * this procedure is the sgp4 prediction model from space command. this is an
1781
- * updated and combined version of sgp4 and sdp4, which were originally
1782
- * published separately in spacetrack report //3. this version follows the
1783
- * methodology from the aiaa paper (2006) describing the history and
1784
- * development of the code.
1785
- *
1786
- * author : david vallado 719-573-2600 28 jun 2005
1787
- *
1788
- * inputs :
1789
- * satrec - initialised structure from sgp4init() call.
1790
- * tsince - time since epoch (minutes)
1791
- *
1792
- * outputs :
1793
- * r - position vector km
1794
- * v - velocity km/sec
1795
- * return code - non-zero on error.
1796
- * 1 - mean elements, ecc >= 1.0 or ecc < -0.001 or a < 0.95 er
1797
- * 2 - mean motion less than 0.0
1798
- * 3 - pert elements, ecc < 0.0 or ecc > 1.0
1799
- * 4 - semi-latus rectum < 0.0
1800
- * 5 - epoch elements are sub-orbital
1801
- * 6 - satellite has decayed
1802
- *
1803
- * locals :
1804
- * am -
1805
- * axnl, aynl -
1806
- * betal -
1807
- * cosim , sinim , cosomm , sinomm , cnod , snod , cos2u ,
1808
- * sin2u , coseo1 , sineo1 , cosi , sini , cosip , sinip ,
1809
- * cosisq , cossu , sinsu , cosu , sinu
1810
- * delm -
1811
- * delomg -
1812
- * dndt -
1813
- * eccm -
1814
- * emsq -
1815
- * ecose -
1816
- * el2 -
1817
- * eo1 -
1818
- * eccp -
1819
- * esine -
1820
- * argpm -
1821
- * argpp -
1822
- * omgadf -
1823
- * pl -
1824
- * r -
1825
- * rtemsq -
1826
- * rdotl -
1827
- * rl -
1828
- * rvdot -
1829
- * rvdotl -
1830
- * su -
1831
- * t2 , t3 , t4 , tc
1832
- * tem5, temp , temp1 , temp2 , tempa , tempe , templ
1833
- * u , ux , uy , uz , vx , vy , vz
1834
- * inclm - inclination
1835
- * mm - mean anomaly
1836
- * nm - mean motion
1837
- * nodem - right asc of ascending node
1838
- * xinc -
1839
- * xincp -
1840
- * xl -
1841
- * xlm -
1842
- * mp -
1843
- * xmdf -
1844
- * xmx -
1845
- * xmy -
1846
- * nodedf -
1847
- * xnode -
1848
- * nodep -
1849
- * np -
1850
- *
1851
- * coupling :
1852
- * getgravconst-
1853
- * dpper
1854
- * dspace
1855
- *
1856
- * references :
1857
- * hoots, roehrich, norad spacetrack report //3 1980
1858
- * hoots, norad spacetrack report //6 1986
1859
- * hoots, schumacher and glover 2004
1860
- * vallado, crawford, hujsak, kelso 2006
1861
- ----------------------------------------------------------------------------*/
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
+ */
1862
1940
  Sgp4.propagate = function (satrec, tsince) {
1863
1941
  /* ------------------ set mathematical constants --------------- */
1864
- // sgp4fix divisor for divide by zero check on inclination
1865
- // the old check used 1.0 + cos(PI-1.0e-9), but then compared it to
1866
- // 1.5 e-12, so the threshold was changed to 1.5e-12 for consistency
1867
- // sgp4fix identify constants and allow alternate values
1868
- // 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
+ */
1869
1951
  var xke = satrec.xke, j2 = satrec.j2, j3oj2 = satrec.j3oj2;
1870
1952
  var vkmpersec = (satrec.radiusearthkm * satrec.xke) / 60.0;
1871
1953
  // --------------------- clear sgp4 error flag -----------------
@@ -1884,7 +1966,7 @@ var Sgp4 = /** @class */ (function () {
1884
1966
  var templ = satrec.t2cof * t2;
1885
1967
  if (satrec.isimp !== 1) {
1886
1968
  var delomg = satrec.omgcof * satrec.t;
1887
- // sgp4fix use mutliply for speed instead of pow
1969
+ // Sgp4fix use mutliply for speed instead of pow
1888
1970
  var delmtemp = 1.0 + satrec.eta * Math.cos(xmdf);
1889
1971
  var delm = satrec.xmcof * (delmtemp * delmtemp * delmtemp - satrec.delmo);
1890
1972
  var temp_1 = delomg + delm;
@@ -1903,27 +1985,31 @@ var Sgp4 = /** @class */ (function () {
1903
1985
  var tc = satrec.t;
1904
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);
1905
1987
  em = dspaceResult[0], argpm = dspaceResult[1], inclm = dspaceResult[2], mm = dspaceResult[3], nodem = dspaceResult[4], nm = dspaceResult[5];
1906
- } // if methjod = d
1988
+ } // If methjod = d
1907
1989
  if (nm <= 0.0) {
1908
- // printf("// error nm %f\n", nm);
1990
+ // Printf("// error nm %f\n", nm);
1909
1991
  satrec.error = 2;
1910
- // sgp4fix add return
1992
+ // Sgp4fix add return
1911
1993
  return { position: false, velocity: false };
1912
1994
  }
1913
1995
  var am = Math.pow((xke / nm), x2o3) * tempa * tempa;
1914
1996
  nm = xke / Math.pow(am, 1.5);
1915
1997
  em -= tempe;
1916
- // fix tolerance for error recognition
1917
- // 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
+ */
1918
2002
  /* istanbul ignore next | This is no longer possible*/
1919
2003
  if (em >= 1.0 || em < -0.001) {
1920
- // || (am < 0.95)
1921
- // printf("// error em %f\n", em);
2004
+ /*
2005
+ * || (am < 0.95)
2006
+ * printf("// error em %f\n", em);
2007
+ */
1922
2008
  satrec.error = 1;
1923
- // sgp4fix to return if there is an error in eccentricity
2009
+ // Sgp4fix to return if there is an error in eccentricity
1924
2010
  return { position: false, velocity: false };
1925
2011
  }
1926
- // sgp4fix fix tolerance to avoid a divide by zero
2012
+ // Sgp4fix fix tolerance to avoid a divide by zero
1927
2013
  if (em < 1.0e-6) {
1928
2014
  em = 1.0e-6;
1929
2015
  }
@@ -1933,15 +2019,17 @@ var Sgp4 = /** @class */ (function () {
1933
2019
  argpm %= TAU;
1934
2020
  xlm %= TAU;
1935
2021
  mm = (xlm - argpm - nodem) % TAU;
1936
- // sgp4fix recover singly averaged mean elements
1937
- // TODO: Skip these?
1938
- // satrec.am = am;
1939
- // satrec.em = em;
1940
- // satrec.im = inclm;
1941
- // satrec.Om = nodem;
1942
- // satrec.om = argpm;
1943
- // satrec.mm = mm;
1944
- // 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
+ */
1945
2033
  // ----------------- compute extra mean quantities -------------
1946
2034
  var sinim = Math.sin(inclm);
1947
2035
  var cosim = Math.cos(inclm);
@@ -1973,9 +2061,9 @@ var Sgp4 = /** @class */ (function () {
1973
2061
  argpp -= PI;
1974
2062
  }
1975
2063
  if (ep < 0.0 || ep > 1.0) {
1976
- // printf("// error ep %f\n", ep);
2064
+ // Printf("// error ep %f\n", ep);
1977
2065
  satrec.error = 3;
1978
- // sgp4fix add return
2066
+ // Sgp4fix add return
1979
2067
  return { position: false, velocity: false };
1980
2068
  }
1981
2069
  }
@@ -1984,7 +2072,7 @@ var Sgp4 = /** @class */ (function () {
1984
2072
  sinip = Math.sin(xincp);
1985
2073
  cosip = Math.cos(xincp);
1986
2074
  satrec.aycof = -0.5 * j3oj2 * sinip;
1987
- // sgp4fix for divide by zero for xincp = 180 deg
2075
+ // Sgp4fix for divide by zero for xincp = 180 deg
1988
2076
  /* istanbul ignore next | This is no longer possible*/
1989
2077
  if (Math.abs(cosip + 1.0) > 1.5e-12) {
1990
2078
  satrec.xlcof = (-0.25 * j3oj2 * sinip * (3.0 + 5.0 * cosip)) / (1.0 + cosip);
@@ -2002,9 +2090,11 @@ var Sgp4 = /** @class */ (function () {
2002
2090
  var eo1 = u;
2003
2091
  var tem5 = 9999.9;
2004
2092
  var ktr = 1;
2005
- // sgp4fix for kepler iteration
2006
- // the following iteration needs better limits on corrections
2007
- var sineo1, coseo1;
2093
+ /*
2094
+ * Sgp4fix for kepler iteration
2095
+ * the following iteration needs better limits on corrections
2096
+ */
2097
+ var coseo1, sineo1;
2008
2098
  while (Math.abs(tem5) >= 1.0e-12 && ktr <= 10) {
2009
2099
  sineo1 = Math.sin(eo1);
2010
2100
  coseo1 = Math.cos(eo1);
@@ -2027,9 +2117,9 @@ var Sgp4 = /** @class */ (function () {
2027
2117
  var el2 = axnl * axnl + aynl * aynl;
2028
2118
  var pl = am * (1.0 - el2);
2029
2119
  if (pl < 0.0) {
2030
- // printf("// error pl %f\n", pl);
2120
+ // Printf("// error pl %f\n", pl);
2031
2121
  satrec.error = 4;
2032
- // sgp4fix add return
2122
+ // Sgp4fix add return
2033
2123
  return { position: false, velocity: false };
2034
2124
  }
2035
2125
  var rl = am * (1.0 - ecose);
@@ -2054,9 +2144,9 @@ var Sgp4 = /** @class */ (function () {
2054
2144
  }
2055
2145
  var mrt = rl * (1.0 - 1.5 * temp2 * betal * satrec.con41) + 0.5 * temp1 * satrec.x1mth2 * cos2u;
2056
2146
  /** Moved this up to reduce unnecessary computation if you are going to return false anyway */
2057
- // sgp4fix for decaying satellites
2147
+ // Sgp4fix for decaying satellites
2058
2148
  if (mrt < 1.0) {
2059
- // printf("// decay condition %11.6f \n",mrt);
2149
+ // Printf("// decay condition %11.6f \n",mrt);
2060
2150
  satrec.error = 6;
2061
2151
  return {
2062
2152
  position: false,
@@ -2099,43 +2189,45 @@ var Sgp4 = /** @class */ (function () {
2099
2189
  velocity: v,
2100
2190
  };
2101
2191
  };
2102
- /* -----------------------------------------------------------------------------
2103
- *
2104
- * function getgravconst
2105
- *
2106
- * this function gets constants for the propagator. note that mu is identified to
2107
- * facilitiate comparisons with newer models. the common useage is wgs72.
2108
- *
2109
- * author : david vallado 719-573-2600 21 jul 2006
2110
- *
2111
- * inputs :
2112
- * whichconst - which set of constants to use wgs72old, wgs72, wgs84
2113
- *
2114
- * outputs :
2115
- * tumin - minutes in one time unit
2116
- * mu - earth gravitational parameter
2117
- * radiusearthkm - radius of the earth in km
2118
- * xke - reciprocal of tumin
2119
- * j2, j3, j4 - un-normalized zonal harmonic values
2120
- * j3oj2 - j3 divided by j2
2121
- *
2122
- * locals :
2123
- *
2124
- * coupling :
2125
- * none
2126
- *
2127
- * references :
2128
- * norad spacetrack report #3
2129
- * vallado, crawford, hujsak, kelso 2006
2130
- --------------------------------------------------------------------------- */
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
+ */
2131
2223
  Sgp4.getgravconst = function (whichconst) {
2132
- var tumin, mus, radiusearthkm, xke, j2, j3, j4, j3oj2;
2224
+ var j2, j3, j3oj2, j4, mus, radiusearthkm, tumin, xke;
2133
2225
  switch (whichconst) {
2134
2226
  // -- wgs-72 low precision str#3 constants --
2135
2227
  case 'wgs72old':
2136
- mus = 398600.79964; // in km3 / s2
2137
- radiusearthkm = 6378.135; // km
2138
- 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
2139
2231
  tumin = 1.0 / xke;
2140
2232
  j2 = 0.001082616;
2141
2233
  j3 = -0.00000253881;
@@ -2144,8 +2236,8 @@ var Sgp4 = /** @class */ (function () {
2144
2236
  break;
2145
2237
  // ------------ wgs-72 constants ------------
2146
2238
  case 'wgs72':
2147
- mus = 398600.8; // in km3 / s2
2148
- radiusearthkm = 6378.135; // km
2239
+ mus = 398600.8; // In km3 / s2
2240
+ radiusearthkm = 6378.135; // Km
2149
2241
  xke = 60.0 / Math.sqrt((radiusearthkm * radiusearthkm * radiusearthkm) / mus);
2150
2242
  tumin = 1.0 / xke;
2151
2243
  j2 = 0.001082616;
@@ -2155,8 +2247,8 @@ var Sgp4 = /** @class */ (function () {
2155
2247
  break;
2156
2248
  case 'wgs84':
2157
2249
  // ------------ wgs-84 constants ------------
2158
- mus = 398600.5; // in km3 / s2
2159
- radiusearthkm = 6378.137; // km
2250
+ mus = 398600.5; // In km3 / s2
2251
+ radiusearthkm = 6378.137; // Km
2160
2252
  xke = 60.0 / Math.sqrt((radiusearthkm * radiusearthkm * radiusearthkm) / mus);
2161
2253
  tumin = 1.0 / xke;
2162
2254
  j2 = 0.00108262998905;
@@ -2177,46 +2269,48 @@ var Sgp4 = /** @class */ (function () {
2177
2269
  j4: j4,
2178
2270
  j3oj2: j3oj2,
2179
2271
  };
2180
- }; // getgravconst
2181
- /* -----------------------------------------------------------------------------
2182
- *
2183
- * function twoline2rv
2184
- *
2185
- * this function converts the two line element set character string data to
2186
- * variables and initializes the sgp4 variables. several intermediate varaibles
2187
- * and quantities are determined. note that the result is a structure so multiple
2188
- * satellites can be processed simultaneously without having to reinitialize. the
2189
- * verification mode is an important option that permits quick checks of any
2190
- * changes to the underlying technical theory. this option works using a
2191
- * modified tle file in which the start, stop, and delta time values are
2192
- * included at the end of the second line of data. this only works with the
2193
- * verification mode. the catalog mode simply propagates from -1440 to 1440 min
2194
- * from epoch and is useful when performing entire catalog runs.
2195
- *
2196
- * author : david vallado 719-573-2600 1 mar 2001
2197
- *
2198
- * inputs :
2199
- * longstr1 - first line of the tle
2200
- * longstr2 - second line of the tle
2201
- * typerun - type of run verification 'v', catalog 'c',
2202
- * manual 'm'
2203
- * typeinput - type of manual input mfe 'm', epoch 'e', dayofyr 'd'
2204
- * opsmode - mode of operation afspc or improved 'a', 'i'
2205
- * whichconst - which set of constants to use 72, 84
2206
- *
2207
- * outputs :
2208
- * satrec - structure containing all the sgp4 satellite information
2209
- *
2210
- * coupling :
2211
- * getgravconst-
2212
- * days2mdhms - conversion of days to month, day, hour, minute, second
2213
- * jday - convert day month year hour minute second into julian date
2214
- * sgp4init - initialize the sgp4 variables
2215
- *
2216
- * references :
2217
- * norad spacetrack report #3
2218
- * vallado, crawford, hujsak, kelso 2006
2219
- --------------------------------------------------------------------------- */
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
+ */
2220
2314
  Sgp4.createSatrec = function (tleLine1, tleLine2, whichconst, opsmode) {
2221
2315
  if (whichconst === void 0) { whichconst = 'wgs72'; }
2222
2316
  if (opsmode === void 0) { opsmode = 'i'; }
@@ -2340,8 +2434,10 @@ var Sgp4 = /** @class */ (function () {
2340
2434
  d2211: null,
2341
2435
  nm: null,
2342
2436
  };
2343
- // sgp4fix no longer needed
2344
- // 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
+ */
2345
2441
  var xpdotp = 1440.0 / (2.0 * PI); // 229.1831180523293;
2346
2442
  satrec.error = 0;
2347
2443
  satrec.satnum = tleLine1.substring(2, 7);
@@ -2350,7 +2446,7 @@ var Sgp4 = /** @class */ (function () {
2350
2446
  satrec.ndot = parseFloat(tleLine1.substring(33, 43));
2351
2447
  satrec.nddot = parseFloat("".concat(tleLine1.substring(44, 45), ".").concat(tleLine1.substring(45, 50), "E").concat(tleLine1.substring(50, 52)));
2352
2448
  satrec.bstar = parseFloat("".concat(tleLine1.substring(53, 54), ".").concat(tleLine1.substring(54, 59), "E").concat(tleLine1.substring(59, 61)));
2353
- // satrec.satnum = tleLine2.substring(2, 7);
2449
+ // Satrec.satnum = tleLine2.substring(2, 7);
2354
2450
  satrec.inclo = parseFloat(tleLine2.substring(8, 16));
2355
2451
  satrec.nodeo = parseFloat(tleLine2.substring(17, 25));
2356
2452
  satrec.ecco = parseFloat(".".concat(tleLine2.substring(26, 33)));
@@ -2358,30 +2454,42 @@ var Sgp4 = /** @class */ (function () {
2358
2454
  satrec.mo = parseFloat(tleLine2.substring(43, 51));
2359
2455
  satrec.no = parseFloat(tleLine2.substring(52, 63));
2360
2456
  // ---- find no, ndot, nddot ----
2361
- satrec.no /= xpdotp; // rad/min
2457
+ satrec.no /= xpdotp; // Rad/min
2362
2458
  /** Ootk -- nexp and ibexp are calculated above using template literals */
2363
- // satrec.nddot = satrec.nddot * Math.pow(10.0, nexp);
2364
- // satrec.bstar = satrec.bstar * Math.pow(10.0, ibexp);
2365
- // ---- convert to sgp4 units ----
2366
- // 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
+ */
2367
2467
  /** Ootk -- Not sure why the following two lines are added. 1st and 2nd derivatives aren't even used anymore */
2368
- // satrec.ndot /= xpdotp * 1440.0; // ? * minperday
2369
- // satrec.nddot /= xpdotp * 1440.0 * 1440;
2468
+ /*
2469
+ * Satrec.ndot /= xpdotp * 1440.0; // ? * minperday
2470
+ * satrec.nddot /= xpdotp * 1440.0 * 1440;
2471
+ */
2370
2472
  // ---- find standard orbital elements ----
2371
2473
  satrec.inclo *= DEG2RAD;
2372
2474
  satrec.nodeo *= DEG2RAD;
2373
2475
  satrec.argpo *= DEG2RAD;
2374
2476
  satrec.mo *= DEG2RAD;
2375
- // sgp4fix not needed here
2376
- // satrec.alta = satrec.a * (1.0 + satrec.ecco) - 1.0;
2377
- // satrec.altp = satrec.a * (1.0 - satrec.ecco) - 1.0;
2378
- // ----------------------------------------------------------------
2379
- // find sgp4epoch time of element set
2380
- // remember that sgp4 uses units of days from 0 jan 1950 (sgp4epoch)
2381
- // and minutes from the epoch (time)
2382
- // ----------------------------------------------------------------
2383
- // ---------------- temp fix for years from 1957-2056 -------------------
2384
- // --------- 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
+ */
2385
2493
  if (satrec.epochyr < 57) {
2386
2494
  year = satrec.epochyr + 2000;
2387
2495
  }
@@ -2408,8 +2516,9 @@ var Sgp4 = /** @class */ (function () {
2408
2516
  xnodeo: satrec.nodeo,
2409
2517
  });
2410
2518
  return satrec;
2411
- }; // twoline2rv
2412
- /* -----------------------------------------------------------------------------
2519
+ }; // Twoline2rv
2520
+ /*
2521
+ * -----------------------------------------------------------------------------
2413
2522
  *
2414
2523
  * function gstime
2415
2524
  *
@@ -2433,10 +2542,11 @@ var Sgp4 = /** @class */ (function () {
2433
2542
  *
2434
2543
  * references :
2435
2544
  * vallado 2004, 191, eq 3-45
2436
- * --------------------------------------------------------------------------- */
2545
+ * ---------------------------------------------------------------------------
2546
+ */
2437
2547
  Sgp4.gstime = function (jdut1) {
2438
2548
  var tut1 = (jdut1 - 2451545.0) / 36525.0;
2439
- 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
2440
2550
  temp = ((temp * DEG2RAD) / 240.0) % TAU; // 360/86400 = 1/240, to deg, to rad
2441
2551
  // ------------------------ check quadrants ---------------------
2442
2552
  if (temp < 0.0) {
@@ -2448,11 +2558,10 @@ var Sgp4 = /** @class */ (function () {
2448
2558
  if (x < 0.0) {
2449
2559
  return -1.0;
2450
2560
  }
2451
- else {
2452
- return 1.0;
2453
- }
2454
- }; // sgn
2455
- /* -----------------------------------------------------------------------------
2561
+ return 1.0;
2562
+ }; // Sgn
2563
+ /*
2564
+ * -----------------------------------------------------------------------------
2456
2565
  *
2457
2566
  * function mag
2458
2567
  *
@@ -2471,39 +2580,43 @@ var Sgp4 = /** @class */ (function () {
2471
2580
  *
2472
2581
  * coupling :
2473
2582
  * none.
2474
- * --------------------------------------------------------------------------- */
2583
+ * ---------------------------------------------------------------------------
2584
+ */
2475
2585
  Sgp4.mag = function (x) {
2476
2586
  return Math.sqrt(x[0] * x[0] + x[1] * x[1] + x[2] * x[2]);
2477
- }; // mag
2478
- /* -----------------------------------------------------------------------------
2479
- *
2480
- * procedure cross_SGP4
2481
- *
2482
- * this procedure crosses two vectors.
2483
- *
2484
- * author : david vallado 719-573-2600 1 mar 2001
2485
- *
2486
- * inputs description range / units
2487
- * vec1 - vector number 1
2488
- * vec2 - vector number 2
2489
- *
2490
- * outputs :
2491
- * outvec - vector result of a x b
2492
- *
2493
- * locals :
2494
- * none.
2495
- *
2496
- * coupling :
2497
- * mag magnitude of a vector
2498
- ---------------------------------------------------------------------------- */
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
+ */
2499
2611
  Sgp4.cross = function (vec1, vec2) {
2500
2612
  var outvec = [0, 0, 0];
2501
2613
  outvec[0] = vec1[1] * vec2[2] - vec1[2] * vec2[1];
2502
2614
  outvec[1] = vec1[2] * vec2[0] - vec1[0] * vec2[2];
2503
2615
  outvec[2] = vec1[0] * vec2[1] - vec1[1] * vec2[0];
2504
2616
  return outvec;
2505
- }; // end cross
2506
- /* -----------------------------------------------------------------------------
2617
+ }; // End cross
2618
+ /*
2619
+ * -----------------------------------------------------------------------------
2507
2620
  *
2508
2621
  * function dot_SGP4
2509
2622
  *
@@ -2523,11 +2636,13 @@ var Sgp4 = /** @class */ (function () {
2523
2636
  *
2524
2637
  * coupling :
2525
2638
  * none.
2526
- * --------------------------------------------------------------------------- */
2639
+ * ---------------------------------------------------------------------------
2640
+ */
2527
2641
  Sgp4.dot = function (x, y) {
2528
2642
  return x[0] * y[0] + x[1] * y[1] + x[2] * y[2];
2529
- }; // dot
2530
- /* -----------------------------------------------------------------------------
2643
+ }; // Dot
2644
+ /*
2645
+ * -----------------------------------------------------------------------------
2531
2646
  *
2532
2647
  * procedure angle_SGP4
2533
2648
  *
@@ -2549,7 +2664,8 @@ var Sgp4 = /** @class */ (function () {
2549
2664
  *
2550
2665
  * coupling :
2551
2666
  * dot dot product of two vectors
2552
- * --------------------------------------------------------------------------- */
2667
+ * ---------------------------------------------------------------------------
2668
+ */
2553
2669
  Sgp4.angle = function (vec1, vec2) {
2554
2670
  var small = 0.00000001;
2555
2671
  var unknown = 999999.1; /** Ootk -- original 'undefined' is protected in JS */
@@ -2557,14 +2673,15 @@ var Sgp4 = /** @class */ (function () {
2557
2673
  var magv2 = Sgp4.mag(vec2);
2558
2674
  if (magv1 * magv2 > small * small) {
2559
2675
  var temp = Sgp4.dot(vec1, vec2) / (magv1 * magv2);
2560
- if (Math.abs(temp) > 1.0)
2561
- temp = Sgp4.sgn(temp) * 1.0;
2676
+ if (Math.abs(temp) > 1.0) {
2677
+ temp = Number(Sgp4.sgn(temp));
2678
+ }
2562
2679
  return Math.acos(temp);
2563
2680
  }
2564
- else
2565
- return unknown;
2566
- }; // angle
2567
- /* -----------------------------------------------------------------------------
2681
+ return unknown;
2682
+ }; // Angle
2683
+ /*
2684
+ * -----------------------------------------------------------------------------
2568
2685
  *
2569
2686
  * function asinh_SGP4
2570
2687
  *
@@ -2583,11 +2700,13 @@ var Sgp4 = /** @class */ (function () {
2583
2700
  *
2584
2701
  * coupling :
2585
2702
  * none.
2586
- * --------------------------------------------------------------------------- */
2703
+ * ---------------------------------------------------------------------------
2704
+ */
2587
2705
  Sgp4.asinh = function (xval) {
2588
2706
  return Math.log(xval + Math.sqrt(xval * xval + 1.0));
2589
- }; // asinh
2590
- /* -----------------------------------------------------------------------------
2707
+ }; // Asinh
2708
+ /*
2709
+ * -----------------------------------------------------------------------------
2591
2710
  *
2592
2711
  * function newtonnu_SGP4
2593
2712
  *
@@ -2620,52 +2739,55 @@ var Sgp4 = /** @class */ (function () {
2620
2739
  *
2621
2740
  * references :
2622
2741
  * vallado 2013, 77, alg 5
2623
- * --------------------------------------------------------------------------- */
2742
+ * ---------------------------------------------------------------------------
2743
+ */
2624
2744
  Sgp4.newtonnu = function (ecc, nu) {
2625
2745
  // --------------------- implementation ---------------------
2626
2746
  var e0 = 999999.9;
2627
2747
  var m = 999999.9;
2628
2748
  var small = 0.00000001;
2629
- // --------------------------- circular ------------------------
2630
2749
  if (Math.abs(ecc) < small) {
2750
+ // --------------------------- circular ------------------------
2631
2751
  m = nu;
2632
2752
  e0 = nu;
2633
2753
  }
2634
- // ---------------------- elliptical -----------------------
2635
2754
  else if (ecc < 1.0 - small) {
2755
+ // ---------------------- elliptical -----------------------
2636
2756
  var sine = (Math.sqrt(1.0 - ecc * ecc) * Math.sin(nu)) / (1.0 + ecc * Math.cos(nu));
2637
2757
  var cose = (ecc + Math.cos(nu)) / (1.0 + ecc * Math.cos(nu));
2638
2758
  e0 = Math.atan2(sine, cose);
2639
2759
  m = e0 - ecc * Math.sin(e0);
2640
2760
  }
2641
- // -------------------- hyperbolic --------------------
2642
2761
  else if (ecc > 1.0 + small) {
2762
+ // -------------------- hyperbolic --------------------
2643
2763
  if (ecc > 1.0 && Math.abs(nu) + 0.00001 < PI - Math.acos(1.0 / ecc)) {
2644
2764
  var sine = (Math.sqrt(ecc * ecc - 1.0) * Math.sin(nu)) / (1.0 + ecc * Math.cos(nu));
2645
2765
  e0 = Sgp4.asinh(sine);
2646
2766
  m = ecc * Sgp4.sinh(e0) - e0;
2647
2767
  }
2648
2768
  }
2649
- // ----------------- parabolic ---------------------
2650
2769
  else if (Math.abs(nu) < (168.0 * PI) / 180.0) {
2770
+ // ----------------- parabolic ---------------------
2651
2771
  e0 = Math.tan(nu * 0.5);
2652
2772
  m = e0 + (e0 * e0 * e0) / 3.0;
2653
2773
  }
2654
2774
  if (ecc < 1.0) {
2655
- m = m % (2.0 * PI);
2656
- if (m < 0.0)
2657
- m = m + 2.0 * PI;
2658
- 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;
2659
2780
  }
2660
2781
  return {
2661
2782
  e0: e0,
2662
2783
  m: m,
2663
2784
  };
2664
- }; // newtonnu
2785
+ }; // Newtonnu
2665
2786
  Sgp4.sinh = function (x) {
2666
2787
  return (Math.exp(x) - Math.exp(-x)) / 2;
2667
2788
  };
2668
- /* -----------------------------------------------------------------------------
2789
+ /*
2790
+ * -----------------------------------------------------------------------------
2669
2791
  *
2670
2792
  * function rv2coe_SGP4
2671
2793
  *
@@ -2720,7 +2842,8 @@ var Sgp4 = /** @class */ (function () {
2720
2842
  *
2721
2843
  * references :
2722
2844
  * vallado 2013, 113, alg 9, ex 2-5
2723
- * --------------------------------------------------------------------------- */
2845
+ * ---------------------------------------------------------------------------
2846
+ */
2724
2847
  Sgp4.rv2coe = function (r, v, mus) {
2725
2848
  var nbar = [0, 0, 0];
2726
2849
  var ebar = [0, 0, 0];
@@ -2740,14 +2863,18 @@ var Sgp4 = /** @class */ (function () {
2740
2863
  var hk;
2741
2864
  var sme;
2742
2865
  var i;
2743
- // switch this to an integer msvs seems to have probelms with this and strncpy_s
2744
- //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
+ */
2745
2870
  var typeorbit;
2746
- // here
2747
- // typeorbit = 1 = 'ei'
2748
- // typeorbit = 2 = 'ce'
2749
- // typeorbit = 3 = 'ci'
2750
- // typeorbit = 4 = 'ee'
2871
+ /*
2872
+ * Here
2873
+ * typeorbit = 1 = 'ei'
2874
+ * typeorbit = 2 = 'ce'
2875
+ * typeorbit = 3 = 'ci'
2876
+ * typeorbit = 4 = 'ee'
2877
+ */
2751
2878
  var halfpi = 0.5 * PI;
2752
2879
  var small = 0.00000001;
2753
2880
  var unknown = 999999.1; /** Ootk -- original undefined is illegal in JS */
@@ -2765,21 +2892,26 @@ var Sgp4 = /** @class */ (function () {
2765
2892
  magn = Sgp4.mag(nbar);
2766
2893
  var c1 = magv * magv - mus / magr;
2767
2894
  rdotv = Sgp4.dot(r, v);
2768
- for (i = 0; i <= 2; i++)
2895
+ for (i = 0; i <= 2; i++) {
2769
2896
  ebar[i] = (c1 * r[i] - rdotv * v[i]) / mus;
2897
+ }
2770
2898
  ecc = Sgp4.mag(ebar);
2771
2899
  // ------------ find a e and semi-latus rectum ----------
2772
2900
  sme = magv * magv * 0.5 - mus / magr;
2773
- if (Math.abs(sme) > small)
2901
+ if (Math.abs(sme) > small) {
2774
2902
  a = -mus / (2.0 * sme);
2775
- else
2903
+ }
2904
+ else {
2776
2905
  a = infinite;
2906
+ }
2777
2907
  p = (magh * magh) / mus;
2778
2908
  // ----------------- find inclination -------------------
2779
2909
  hk = hbar[2] / magh;
2780
2910
  incl = Math.acos(hk);
2781
- // -------- determine type of orbit for later use --------
2782
- // ------ elliptical, parabolic, hyperbolic inclined -------
2911
+ /*
2912
+ * -------- determine type of orbit for later use --------
2913
+ * ------ elliptical, parabolic, hyperbolic inclined -------
2914
+ */
2783
2915
  typeorbit = 1;
2784
2916
  if (ecc < small) {
2785
2917
  // ---------------- circular equatorial ---------------
@@ -2800,68 +2932,86 @@ var Sgp4 = /** @class */ (function () {
2800
2932
  // ---------- find right ascension of the ascending node ------------
2801
2933
  if (magn > small) {
2802
2934
  var temp = nbar[0] / magn;
2803
- if (Math.abs(temp) > 1.0)
2935
+ if (Math.abs(temp) > 1.0) {
2804
2936
  temp = Sgp4.sgn(temp);
2937
+ }
2805
2938
  omega = Math.acos(temp);
2806
- if (nbar[1] < 0.0)
2939
+ if (nbar[1] < 0.0) {
2807
2940
  omega = TAU - omega;
2941
+ }
2808
2942
  }
2809
- else
2943
+ else {
2810
2944
  omega = unknown;
2945
+ }
2811
2946
  // ---------------- find argument of perigee ---------------
2812
- if (typeorbit == 1) {
2947
+ if (typeorbit === 1) {
2813
2948
  argp = Sgp4.angle(nbar, ebar);
2814
- if (ebar[2] < 0.0)
2949
+ if (ebar[2] < 0.0) {
2815
2950
  argp = TAU - argp;
2951
+ }
2816
2952
  }
2817
- else
2953
+ else {
2818
2954
  argp = unknown;
2955
+ }
2819
2956
  // ------------ find true anomaly at epoch -------------
2820
- if (typeorbit == 1 || typeorbit == 4) {
2957
+ if (typeorbit === 1 || typeorbit === 4) {
2821
2958
  nu = Sgp4.angle(ebar, r);
2822
- if (rdotv < 0.0)
2959
+ if (rdotv < 0.0) {
2823
2960
  nu = TAU - nu;
2961
+ }
2824
2962
  }
2825
- else
2963
+ else {
2826
2964
  nu = unknown;
2965
+ }
2827
2966
  // ---- find argument of latitude - circular inclined -----
2828
- if (typeorbit == 3) {
2967
+ if (typeorbit === 3) {
2829
2968
  arglat = Sgp4.angle(nbar, r);
2830
- if (r[2] < 0.0)
2969
+ if (r[2] < 0.0) {
2831
2970
  arglat = TAU - arglat;
2971
+ }
2832
2972
  m = arglat;
2833
2973
  }
2834
- else
2974
+ else {
2835
2975
  arglat = unknown;
2836
- if (ecc > small && typeorbit == 4) {
2976
+ }
2977
+ if (ecc > small && typeorbit === 4) {
2837
2978
  var temp = ebar[0] / ecc;
2838
- if (Math.abs(temp) > 1.0)
2979
+ if (Math.abs(temp) > 1.0) {
2839
2980
  temp = Sgp4.sgn(temp);
2981
+ }
2840
2982
  lonper = Math.acos(temp);
2841
- if (ebar[1] < 0.0)
2983
+ if (ebar[1] < 0.0) {
2842
2984
  lonper = TAU - lonper;
2843
- if (incl > halfpi)
2985
+ }
2986
+ if (incl > halfpi) {
2844
2987
  lonper = TAU - lonper;
2988
+ }
2845
2989
  }
2846
- else
2990
+ else {
2847
2991
  lonper = unknown;
2992
+ }
2848
2993
  // -------- find true longitude - circular equatorial ------
2849
- if (magr > small && typeorbit == 2) {
2994
+ if (magr > small && typeorbit === 2) {
2850
2995
  var temp = r[0] / magr;
2851
- if (Math.abs(temp) > 1.0)
2996
+ if (Math.abs(temp) > 1.0) {
2852
2997
  temp = Sgp4.sgn(temp);
2998
+ }
2853
2999
  truelon = Math.acos(temp);
2854
- if (r[1] < 0.0)
3000
+ if (r[1] < 0.0) {
2855
3001
  truelon = TAU - truelon;
2856
- if (incl > halfpi)
3002
+ }
3003
+ if (incl > halfpi) {
2857
3004
  truelon = TAU - truelon;
3005
+ }
2858
3006
  m = truelon;
2859
3007
  }
2860
- else
3008
+ else {
2861
3009
  truelon = unknown;
3010
+ }
2862
3011
  // ------------ find mean anomaly for all orbits -----------
2863
- if (typeorbit == 1 || typeorbit == 4)
3012
+ if (typeorbit === 1 || typeorbit === 4) {
2864
3013
  m = Sgp4.newtonnu(ecc, nu).m;
3014
+ }
2865
3015
  }
2866
3016
  else {
2867
3017
  p = unknown;
@@ -2889,8 +3039,9 @@ var Sgp4 = /** @class */ (function () {
2889
3039
  truelon: truelon,
2890
3040
  lonper: lonper,
2891
3041
  };
2892
- }; // rv2coe
2893
- /* -----------------------------------------------------------------------------
3042
+ }; // Rv2coe
3043
+ /*
3044
+ * -----------------------------------------------------------------------------
2894
3045
  *
2895
3046
  * procedure jday
2896
3047
  *
@@ -2922,24 +3073,26 @@ var Sgp4 = /** @class */ (function () {
2922
3073
  * references :
2923
3074
  * vallado 2013, 183, alg 14, ex 3-4
2924
3075
  *
2925
- * --------------------------------------------------------------------------- */
3076
+ * ---------------------------------------------------------------------------
3077
+ */
2926
3078
  Sgp4.jday = function (year, mon, day, hr, minute, sec) {
2927
3079
  var jd = 367.0 * year -
2928
3080
  Math.floor(7 * (year + Math.floor((mon + 9) / 12.0)) * 0.25) +
2929
3081
  Math.floor((275 * mon) / 9.0) +
2930
3082
  day +
2931
- 1721013.5; // use - 678987.0 to go to mjd directly
3083
+ 1721013.5; // Use - 678987.0 to go to mjd directly
2932
3084
  var jdFrac = (sec + minute * 60.0 + hr * 3600.0) / 86400.0;
2933
- // check that the day and fractional day are correct
3085
+ // Check that the day and fractional day are correct
2934
3086
  if (Math.abs(jdFrac) > 1.0) {
2935
3087
  var dtt = Math.floor(jdFrac);
2936
- jd = jd + dtt;
2937
- jdFrac = jdFrac - dtt;
3088
+ jd += dtt;
3089
+ jdFrac -= dtt;
2938
3090
  }
2939
3091
  // - 0.5*sgn(100.0*year + mon - 190002.5) + 0.5;
2940
3092
  return { jd: jd, jdFrac: jdFrac };
2941
- }; // jday
2942
- /* -----------------------------------------------------------------------------
3093
+ }; // Jday
3094
+ /*
3095
+ * -----------------------------------------------------------------------------
2943
3096
  *
2944
3097
  * procedure days2mdhms
2945
3098
  *
@@ -2974,14 +3127,17 @@ var Sgp4 = /** @class */ (function () {
2974
3127
  *
2975
3128
  * coupling :
2976
3129
  * none.
2977
- * --------------------------------------------------------------------------- */
3130
+ * ---------------------------------------------------------------------------
3131
+ */
2978
3132
  Sgp4.days2mdhms = function (year, days) {
2979
3133
  var lmonth = [31, year % 4 === 0 ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
2980
3134
  var dayofyr = Math.floor(days);
2981
3135
  // ----------------- find month and day of month ----------------
2982
3136
  /** Ootk -- Incorporated in the above declaration */
2983
- // if ((year % 4) == 0)
2984
- // lmonth[2] = 29;
3137
+ /*
3138
+ * If ((year % 4) == 0)
3139
+ * lmonth[2] = 29;
3140
+ */
2985
3141
  var i = 1;
2986
3142
  var inttemp = 0;
2987
3143
  while (dayofyr > inttemp + lmonth[i - 1] && i < 12) {
@@ -3003,8 +3159,9 @@ var Sgp4 = /** @class */ (function () {
3003
3159
  minute: minute,
3004
3160
  sec: sec,
3005
3161
  };
3006
- }; // days2mdhms
3007
- /* -----------------------------------------------------------------------------
3162
+ }; // Days2mdhms
3163
+ /*
3164
+ * -----------------------------------------------------------------------------
3008
3165
  *
3009
3166
  * procedure invjday
3010
3167
  *
@@ -3043,20 +3200,21 @@ var Sgp4 = /** @class */ (function () {
3043
3200
  *
3044
3201
  * references :
3045
3202
  * vallado 2013, 203, alg 22, ex 3-13
3046
- * --------------------------------------------------------------------------- */
3203
+ * ---------------------------------------------------------------------------
3204
+ */
3047
3205
  Sgp4.invjday = function (jd, jdfrac) {
3048
3206
  var leapyrs;
3049
3207
  var days;
3050
- // check jdfrac for multiple days
3208
+ // Check jdfrac for multiple days
3051
3209
  if (Math.abs(jdfrac) >= 1.0) {
3052
- jd = jd + Math.floor(jdfrac);
3053
- jdfrac = jdfrac - Math.floor(jdfrac);
3210
+ jd += Math.floor(jdfrac);
3211
+ jdfrac -= Math.floor(jdfrac);
3054
3212
  }
3055
- // check for fraction of a day included in the jd
3213
+ // Check for fraction of a day included in the jd
3056
3214
  var dt = jd - Math.floor(jd) - 0.5;
3057
3215
  if (Math.abs(dt) > 0.00000001) {
3058
- jd = jd - dt;
3059
- jdfrac = jdfrac + dt;
3216
+ jd -= dt;
3217
+ jdfrac += dt;
3060
3218
  }
3061
3219
  /* --------------- find year and days of the year --------------- */
3062
3220
  var temp = jd - 2415019.5;
@@ -3066,7 +3224,7 @@ var Sgp4 = /** @class */ (function () {
3066
3224
  days = Math.floor(temp - ((year - 1900) * 365.0 + leapyrs));
3067
3225
  /* ------------ check for case of beginning of a year ----------- */
3068
3226
  if (days + jdfrac < 1.0) {
3069
- year = year - 1;
3227
+ year -= 1;
3070
3228
  leapyrs = Math.floor((year - 1901) * 0.25);
3071
3229
  days = Math.floor(temp - ((year - 1900) * 365.0 + leapyrs));
3072
3230
  }
@@ -3080,7 +3238,7 @@ var Sgp4 = /** @class */ (function () {
3080
3238
  minute: minute,
3081
3239
  sec: sec,
3082
3240
  };
3083
- }; // invjday
3241
+ }; // Invjday
3084
3242
  return Sgp4;
3085
3243
  }());
3086
3244
  export { Sgp4 };