ootk 1.8.1 → 2.0.1

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.
Files changed (72) hide show
  1. package/.eslintrc.json +1 -1
  2. package/dist/objects/base-object.d.ts +1 -1
  3. package/dist/objects/detailed-sat.d.ts +1 -1
  4. package/dist/objects/sat.d.ts +4 -1
  5. package/dist/objects/sensor.d.ts +35 -21
  6. package/dist/objects/space-object.d.ts +1 -1
  7. package/dist/objects/star.d.ts +6 -6
  8. package/dist/ootk.d.ts +2 -1
  9. package/dist/ootk.js +1 -1
  10. package/dist/ootk.js.LICENSE.txt +3 -3
  11. package/dist/sgp4/Sgp4Assembly.d.ts +5 -0
  12. package/dist/sgp4/sgp4.d.ts +34 -34
  13. package/dist/tle/tle.d.ts +3 -3
  14. package/dist/transforms/transforms.d.ts +1 -1
  15. package/dist/types/types.d.ts +38 -30
  16. package/dist/utils/constants.d.ts +1 -1
  17. package/dist/utils/moon-math.d.ts +6 -6
  18. package/dist/utils/sun-math.d.ts +8 -8
  19. package/dist/utils/utils.d.ts +4 -3
  20. package/lib/objects/base-object.d.ts +1 -1
  21. package/lib/objects/base-object.js +1 -1
  22. package/lib/objects/base-object.js.map +1 -1
  23. package/lib/objects/detailed-sat.d.ts +1 -1
  24. package/lib/objects/detailed-sat.js +1 -1
  25. package/lib/objects/sat.d.ts +4 -1
  26. package/lib/objects/sat.js +42 -7
  27. package/lib/objects/sat.js.map +1 -1
  28. package/lib/objects/sensor.d.ts +35 -21
  29. package/lib/objects/sensor.js +19 -5
  30. package/lib/objects/sensor.js.map +1 -1
  31. package/lib/objects/space-object.d.ts +1 -1
  32. package/lib/objects/space-object.js +1 -1
  33. package/lib/objects/star.d.ts +6 -6
  34. package/lib/objects/star.js +6 -6
  35. package/lib/objects/star.js.map +1 -1
  36. package/lib/ootk.d.ts +2 -1
  37. package/lib/ootk.js +2 -1
  38. package/lib/ootk.js.map +1 -1
  39. package/lib/sgp4/Sgp4Assembly.d.ts +5 -0
  40. package/lib/sgp4/Sgp4Assembly.js +75 -0
  41. package/lib/sgp4/Sgp4Assembly.js.map +1 -0
  42. package/lib/sgp4/sgp4.d.ts +34 -34
  43. package/lib/sgp4/sgp4.js +2927 -2906
  44. package/lib/sgp4/sgp4.js.map +1 -1
  45. package/lib/tle/tle.d.ts +3 -3
  46. package/lib/tle/tle.js +1 -1
  47. package/lib/transforms/transforms.d.ts +1 -1
  48. package/lib/transforms/transforms.js +8 -8
  49. package/lib/transforms/transforms.js.map +1 -1
  50. package/lib/types/types.d.ts +38 -30
  51. package/lib/types/types.js.map +1 -1
  52. package/lib/utils/constants.d.ts +1 -1
  53. package/lib/utils/constants.js +1 -1
  54. package/lib/utils/moon-math.d.ts +6 -6
  55. package/lib/utils/moon-math.js +4 -4
  56. package/lib/utils/moon-math.js.map +1 -1
  57. package/lib/utils/sun-math.d.ts +8 -8
  58. package/lib/utils/sun-math.js +17 -17
  59. package/lib/utils/sun-math.js.map +1 -1
  60. package/lib/utils/utils.d.ts +4 -3
  61. package/lib/utils/utils.js +2 -2
  62. package/lib/utils/utils.js.map +1 -1
  63. package/package.json +8 -8
  64. package/.asc/asconfig.json +0 -22
  65. package/.asc/assembly/index.ts +0 -1143
  66. package/.asc/ex/asconfig.json +0 -22
  67. package/.asc/ex/assembly/index.ts +0 -5
  68. package/.asc/ex/index.html +0 -10
  69. package/.asc/ex/package.json +0 -19
  70. package/.asc/ex/tests/index.js +0 -4
  71. package/.asc/package.json +0 -19
  72. package/.asc/tests/index.js +0 -4
@@ -1,1143 +0,0 @@
1
- const PI: f64 = Math.PI;
2
- const TAU: f64 = PI * 2;
3
- const DEG2RAD: f64 = PI / 180.0;
4
-
5
- class StateVector {
6
- error: f64;
7
- p1: f64;
8
- p2: f64;
9
- p3: f64;
10
- v1: f64;
11
- v2: f64;
12
- v3: f64;
13
- }
14
-
15
- class DspaceResults {
16
- atime: f64 = atime;
17
- em: f64 = em;
18
- argpm: f64 = argpm;
19
- inclm: f64 = inclm;
20
- xli: f64 = xli;
21
- mm: f64 = mm;
22
- xni: f64 = xni;
23
- nodem: f64 = nodem;
24
- dndt: f64 = dndt;
25
- nm: f64 = nm;
26
- constructor(
27
- atime: f64,
28
- em: f64,
29
- argpm: f64,
30
- inclm: f64,
31
- xli: f64,
32
- mm: f64,
33
- xni: f64,
34
- nodem: f64,
35
- dndt: f64,
36
- nm: f64,
37
- ) {
38
- this.atime = atime;
39
- this.em = em;
40
- this.argpm = argpm;
41
- this.inclm = inclm;
42
- this.xli = xli;
43
- this.mm = mm;
44
- this.xni = xni;
45
- this.nodem = nodem;
46
- this.dndt = dndt;
47
- this.nm = nm;
48
- }
49
- }
50
-
51
- class DpperResult {
52
- ep: f64;
53
- inclp: f64;
54
- nodep: f64;
55
- argpp: f64;
56
- mp: f64;
57
- constructor(ep: f64, inclp: f64, nodep: f64, argpp: f64, mp: f64) {
58
- this.ep = ep;
59
- this.inclp = inclp;
60
- this.nodep = nodep;
61
- this.argpp = argpp;
62
- this.mp = mp;
63
- }
64
- }
65
-
66
- /*----------------------------------------------------------------------------
67
- *
68
- * procedure sgp4
69
- *
70
- * this procedure is the sgp4 prediction model from space command. this is an
71
- * updated and combined version of sgp4 and sdp4, which were originally
72
- * published separately in spacetrack report //3. this version follows the
73
- * methodology from the aiaa paper (2006) describing the history and
74
- * development of the code.
75
- *
76
- * author : david vallado 719-573-2600 28 jun 2005
77
- *
78
- * inputs :
79
- * satrec - initialised structure from sgp4init() call.
80
- * tsince - time since epoch (minutes)
81
- *
82
- * outputs :
83
- * r - position vector km
84
- * v - velocity km/sec
85
- * return code - non-zero on error.
86
- * 1 - mean elements, ecc >= 1.0 or ecc < -0.001 or a < 0.95 er
87
- * 2 - mean motion less than 0.0
88
- * 3 - pert elements, ecc < 0.0 or ecc > 1.0
89
- * 4 - semi-latus rectum < 0.0
90
- * 5 - epoch elements are sub-orbital
91
- * 6 - satellite has decayed
92
- *
93
- * locals :
94
- * am -
95
- * axnl, aynl -
96
- * betal -
97
- * cosim , sinim , cosomm , sinomm , cnod , snod , cos2u ,
98
- * sin2u , coseo1 , sineo1 , cosi , sini , cosip , sinip ,
99
- * cosisq , cossu , sinsu , cosu , sinu
100
- * delm -
101
- * delomg -
102
- * dndt -
103
- * eccm -
104
- * emsq -
105
- * ecose -
106
- * el2 -
107
- * eo1 -
108
- * eccp -
109
- * esine -
110
- * argpm -
111
- * argpp -
112
- * omgadf -
113
- * pl -
114
- * r -
115
- * rtemsq -
116
- * rdotl -
117
- * rl -
118
- * rvdot -
119
- * rvdotl -
120
- * su -
121
- * t2 , t3 , t4 , tc
122
- * tem5, temp , temp1 , temp2 , tempa , tempe , templ
123
- * u , ux , uy , uz , vx , vy , vz
124
- * inclm - inclination
125
- * mm - mean anomaly
126
- * nm - mean motion
127
- * nodem - right asc of ascending node
128
- * xinc -
129
- * xincp -
130
- * xl -
131
- * xlm -
132
- * mp -
133
- * xmdf -
134
- * xmx -
135
- * xmy -
136
- * nodedf -
137
- * xnode -
138
- * nodep -
139
- * np -
140
- *
141
- * coupling :
142
- * getgravconst-
143
- * dpper
144
- * dspace
145
- *
146
- * references :
147
- * hoots, roehrich, norad spacetrack report //3 1980
148
- * hoots, norad spacetrack report //6 1986
149
- * hoots, schumacher and glover 2004
150
- * vallado, crawford, hujsak, kelso 2006
151
- ----------------------------------------------------------------------------*/
152
-
153
- /* -----------------------------------------------------------------------------
154
- *
155
- * function getgravconst
156
- *
157
- * this function gets constants for the propagator. note that mu is identified to
158
- * facilitiate comparisons with newer models. the common useage is wgs72.
159
- *
160
- * author : david vallado 719-573-2600 21 jul 2006
161
- *
162
- * inputs :
163
- * whichconst - which set of constants to use wgs72old, wgs72, wgs84
164
- *
165
- * outputs :
166
- * tumin - minutes in one time unit
167
- * mu - earth gravitational parameter
168
- * radiusearthkm - radius of the earth in km
169
- * xke - reciprocal of tumin
170
- * j2, j3, j4 - un-normalized zonal harmonic values
171
- * j3oj2 - j3 divided by j2
172
- *
173
- * locals :
174
- *
175
- * coupling :
176
- * none
177
- *
178
- * references :
179
- * norad spacetrack report #3
180
- * vallado, crawford, hujsak, kelso 2006
181
- --------------------------------------------------------------------------- */
182
- export function propagate(
183
- a: f64,
184
- am: f64,
185
- alta: f64,
186
- altp: f64,
187
- argpdot: f64,
188
- argpo: f64,
189
- aycof: f64,
190
- bstar: f64,
191
- cc1: f64,
192
- cc4: f64,
193
- cc5: f64,
194
- con41: f64,
195
- d2: f64,
196
- d3: f64,
197
- d4: f64,
198
- d5232: f64,
199
- d5421: f64,
200
- d5433: f64,
201
- dedt: f64,
202
- delmo: f64,
203
- del1: f64,
204
- ecco: f64,
205
- em: f64,
206
- epochdays: f64,
207
- epochyr: f64,
208
- error: f64,
209
- eta: f64,
210
- gsto: f64,
211
- im: f64,
212
- inclo: f64,
213
- init: string,
214
- isimp: f64,
215
- jdsatepoch: f64,
216
- mdot: f64,
217
- method: string,
218
- mo: f64,
219
- mm: f64,
220
- nddot: f64,
221
- ndot: f64,
222
- no: f64,
223
- nodecf: f64,
224
- nodedot: f64,
225
- nodeo: f64,
226
- om: f64,
227
- Om: f64,
228
- omgcof: f64,
229
- operationmode: string,
230
- satnum: string,
231
- sinmao: f64,
232
- t: f64,
233
- t2cof: f64,
234
- t3cof: f64,
235
- t4cof: f64,
236
- t5cof: f64,
237
- x1mth2: f64,
238
- x7thm1: f64,
239
- xlcof: f64,
240
- xmcof: f64,
241
- xfact: f64,
242
- xlamo: f64,
243
- xli: f64,
244
- xgh4: f64,
245
- xgh3: f64,
246
- xh2: f64,
247
- xi2: f64,
248
- xi3: f64,
249
- xl2: f64,
250
- xl3: f64,
251
- xl4: f64,
252
- zmol: f64,
253
- zmos: f64,
254
- dmdt: f64,
255
- dnodt: f64,
256
- domdt: f64,
257
- e3: f64,
258
- ee2: f64,
259
- peo: f64,
260
- pgho: f64,
261
- pho: f64,
262
- PInco: f64,
263
- plo: f64,
264
- se2: f64,
265
- se3: f64,
266
- sgh2: f64,
267
- sgh3: f64,
268
- sgh4: f64,
269
- sh2: f64,
270
- sh3: f64,
271
- si2: f64,
272
- si3: f64,
273
- sl2: f64,
274
- sl3: f64,
275
- sl4: f64,
276
- xgh2: f64,
277
- xh3: f64,
278
- tumin: f64,
279
- radiusearthkm: f64,
280
- irez: f64,
281
- d3210: f64,
282
- d3222: f64,
283
- d4410: f64,
284
- d4422: f64,
285
- d5220: f64,
286
- del2: f64,
287
- del3: f64,
288
- didt: f64,
289
- atime: f64,
290
- j2: f64,
291
- j3: f64,
292
- j4: f64,
293
- mus: f64,
294
- xke: f64,
295
- j3oj2: f64,
296
- xni: f64,
297
- d2201: f64,
298
- d2211: f64,
299
- nm: f64,
300
- tsince: f64,
301
- ): StateVector {
302
- /* ------------------ set mathematical constants --------------- */
303
- // sgp4fix divisor for divide by zero check on inclination
304
- // the old check used 1.0 + cos(PI-1.0e-9), but then compared it to
305
- // 1.5 e-12, so the threshold was changed to 1.5e-12 for consistency
306
-
307
- const x2o3 = 2.0 / 3.0;
308
- const temp4 = 1.5e-12;
309
-
310
- // sgp4fix identify constants and allow alternate values
311
- // getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 );
312
- const vkmpersec = (radiusearthkm * xke) / 60.0;
313
-
314
- // --------------------- clear sgp4 error flag -----------------
315
- t = tsince;
316
- error = 0;
317
-
318
- // ------- update for secular gravity and atmospheric drag -----
319
- let xmdf = mo + mdot * t;
320
- let argpdf = argpo + argpdot * t;
321
- let nodedf = nodeo + nodedot * t;
322
- let argpm = argpdf;
323
- let mm = xmdf;
324
- let t2 = t * t;
325
- let nodem = nodedf + nodecf * t2;
326
- let tempa = 1.0 - cc1 * t;
327
- let tempe = bstar * cc4 * t;
328
- let templ = t2cof * t2;
329
-
330
- if (isimp !== 1) {
331
- let delomg = omgcof * t;
332
- // sgp4fix use mutliply for speed instead of pow
333
- let delmtemp = 1.0 + eta * Math.cos(xmdf);
334
- let delm = xmcof * (delmtemp * delmtemp * delmtemp - delmo);
335
- let temp = delomg + delm;
336
- mm = xmdf + temp;
337
- argpm = argpdf - temp;
338
- let t3 = t2 * t;
339
- let t4 = t3 * t;
340
- tempa = tempa - d2 * t2 - d3 * t3 - d4 * t4;
341
- tempe += bstar * cc5 * (Math.sin(mm) - sinmao);
342
- templ = templ + t3cof * t3 + t4 * (t4cof + t * t5cof);
343
- }
344
- let nm = no;
345
- let em = ecco;
346
- let inclm = inclo;
347
- if (method === 'd') {
348
- let tc = t;
349
-
350
- const dspaceResult = dspace(
351
- irez,
352
- d2201,
353
- d2211,
354
- d3210,
355
- d3222,
356
- d4410,
357
- d4422,
358
- d5220,
359
- d5232,
360
- d5421,
361
- d5433,
362
- dedt,
363
- del1,
364
- del2,
365
- del3,
366
- didt,
367
- dmdt,
368
- dnodt,
369
- domdt,
370
- argpo,
371
- argpdot,
372
- t,
373
- tc,
374
- gsto,
375
- xfact,
376
- xlamo,
377
- no,
378
- atime,
379
- em,
380
- argpm,
381
- inclm,
382
- xli,
383
- mm,
384
- xni,
385
- nodem,
386
- nm,
387
- );
388
-
389
- em = dspaceResult.em;
390
- argpm = dspaceResult.argpm;
391
- inclm = dspaceResult.inclm;
392
- mm = dspaceResult.mm;
393
- nodem = dspaceResult.nodem;
394
- nm = dspaceResult.nm;
395
- } // if methjod = d
396
-
397
- if (nm <= 0.0) {
398
- // printf("// error nm %f\n", nm);
399
- error = 2;
400
- // sgp4fix add return
401
- return {
402
- error: error,
403
- p1: 0.0,
404
- p2: 0.0,
405
- p3: 0.0,
406
- v1: 0.0,
407
- v2: 0.0,
408
- v3: 0.0,
409
- };
410
- }
411
-
412
- let am = (xke / nm) ** x2o3 * tempa * tempa;
413
- nm = xke / am ** 1.5;
414
- em -= tempe;
415
-
416
- // fix tolerance for error recognition
417
- // sgp4fix am is fixed from the previous nm check
418
- /* istanbul ignore next | This is no longer possible*/
419
- if (em >= 1.0 || em < -0.001) {
420
- // || (am < 0.95)
421
- // printf("// error em %f\n", em);
422
- error = 1;
423
- // sgp4fix to return if there is an error in eccentricity
424
- return {
425
- error: error,
426
- p1: 0.0,
427
- p2: 0.0,
428
- p3: 0.0,
429
- v1: 0.0,
430
- v2: 0.0,
431
- v3: 0.0,
432
- };
433
- }
434
-
435
- // sgp4fix fix tolerance to avoid a divide by zero
436
- if (em < 1.0e-6) {
437
- em = 1.0e-6;
438
- }
439
- mm += no * templ;
440
- let xlm = mm + argpm + nodem;
441
-
442
- nodem %= TAU;
443
- argpm %= TAU;
444
- xlm %= TAU;
445
- mm = (xlm - argpm - nodem) % TAU;
446
-
447
- // sgp4fix recover singly averaged mean elements
448
- am = am;
449
- em = em;
450
- im = inclm;
451
- Om = nodem;
452
- om = argpm;
453
- mm = mm;
454
- nm = nm;
455
-
456
- // ----------------- compute extra mean quantities -------------
457
- let sinim = Math.sin(inclm);
458
- let cosim = Math.cos(inclm);
459
-
460
- // -------------------- add lunar-solar periodics --------------
461
- let ep = em;
462
- let xincp = inclm;
463
- let argpp = argpm;
464
- let nodep = nodem;
465
- let mp = mm;
466
- let sinip = sinim;
467
- let cosip = cosim;
468
- if (method === 'd') {
469
- const dpperResult = dpper(
470
- e3,
471
- ee2,
472
- peo,
473
- pgho,
474
- pho,
475
- PInco,
476
- plo,
477
- se2,
478
- se3,
479
- sgh2,
480
- sgh3,
481
- sgh4,
482
- sh2,
483
- sh3,
484
- si2,
485
- si3,
486
- sl2,
487
- sl3,
488
- sl4,
489
- t,
490
- xgh2,
491
- xgh3,
492
- xgh4,
493
- xh2,
494
- xh3,
495
- xi2,
496
- xi3,
497
- xl2,
498
- xl3,
499
- xl4,
500
- zmol,
501
- zmos,
502
- ep,
503
- xincp,
504
- nodep,
505
- argpp,
506
- mp,
507
- operationmode,
508
- 'n',
509
- );
510
-
511
- ep = dpperResult.ep;
512
- xincp = dpperResult.inclp;
513
- nodep = dpperResult.nodep;
514
- argpp = dpperResult.argpp;
515
- mp = dpperResult.mp;
516
-
517
- if (xincp < 0.0) {
518
- xincp = -xincp;
519
- nodep += PI;
520
- argpp -= PI;
521
- }
522
- if (ep < 0.0 || ep > 1.0) {
523
- // printf("// error ep %f\n", ep);
524
- error = 3;
525
- // sgp4fix add return
526
- return {
527
- error: error,
528
- p1: 0.0,
529
- p2: 0.0,
530
- p3: 0.0,
531
- v1: 0.0,
532
- v2: 0.0,
533
- v3: 0.0,
534
- };
535
- }
536
- }
537
-
538
- // -------------------- long period periodics ------------------
539
- if (method === 'd') {
540
- sinip = Math.sin(xincp);
541
- cosip = Math.cos(xincp);
542
- aycof = -0.5 * j3oj2 * sinip;
543
-
544
- // sgp4fix for divide by zero for xincp = 180 deg
545
- /* istanbul ignore next | This is no longer possible*/
546
- if (Math.abs(cosip + 1.0) > 1.5e-12) {
547
- xlcof = (-0.25 * j3oj2 * sinip * (3.0 + 5.0 * cosip)) / (1.0 + cosip);
548
- } else {
549
- xlcof = (-0.25 * j3oj2 * sinip * (3.0 + 5.0 * cosip)) / temp4;
550
- }
551
- }
552
-
553
- let axnl = ep * Math.cos(argpp);
554
- let temp = 1.0 / (am * (1.0 - ep * ep));
555
- let aynl = ep * Math.sin(argpp) + temp * aycof;
556
- let xl = mp + argpp + nodep + temp * xlcof * axnl;
557
-
558
- // --------------------- solve kepler's equation ---------------
559
- let u = (xl - nodep) % TAU;
560
- let eo1 = u;
561
- let tem5 = 9999.9;
562
- let ktr = 1;
563
- // sgp4fix for kepler iteration
564
- // the following iteration needs better limits on corrections
565
- let sineo1: f64;
566
- let coseo1: f64;
567
- while (Math.abs(tem5) >= 1.0e-12 && ktr <= 10) {
568
- sineo1 = Math.sin(eo1);
569
- coseo1 = Math.cos(eo1);
570
- tem5 = 1.0 - coseo1 * axnl - sineo1 * aynl;
571
- tem5 = (u - aynl * coseo1 + axnl * sineo1 - eo1) / tem5;
572
- if (Math.abs(tem5) >= 0.95) {
573
- if (tem5 > 0.0) {
574
- tem5 = 0.95;
575
- } else {
576
- tem5 = -0.95;
577
- }
578
- }
579
- eo1 += tem5;
580
- ktr += 1;
581
- }
582
-
583
- // ------------- short period preliminary quantities -----------
584
- let ecose = axnl * coseo1 + aynl * sineo1;
585
- let esine = axnl * sineo1 - aynl * coseo1;
586
- let el2 = axnl * axnl + aynl * aynl;
587
- let pl = am * (1.0 - el2);
588
- if (pl < 0.0) {
589
- // printf("// error pl %f\n", pl);
590
- error = 4;
591
- // sgp4fix add return
592
- return {
593
- error: error,
594
- p1: 0.0,
595
- p2: 0.0,
596
- p3: 0.0,
597
- v1: 0.0,
598
- v2: 0.0,
599
- v3: 0.0,
600
- };
601
- }
602
-
603
- let rl = am * (1.0 - ecose);
604
- let rdotl = (Math.sqrt(am) * esine) / rl;
605
- let rvdotl = Math.sqrt(pl) / rl;
606
- let betal = Math.sqrt(1.0 - el2);
607
- temp = esine / (1.0 + betal);
608
- let sinu = (am / rl) * (sineo1 - aynl - axnl * temp);
609
- let cosu = (am / rl) * (coseo1 - axnl + aynl * temp);
610
- let su = Math.atan2(sinu, cosu);
611
- let sin2u = (cosu + cosu) * sinu;
612
- let cos2u = 1.0 - 2.0 * sinu * sinu;
613
- temp = 1.0 / pl;
614
- let temp1 = 0.5 * j2 * temp;
615
- let temp2 = temp1 * temp;
616
-
617
- // -------------- update for short period periodics ------------
618
- if (method === 'd') {
619
- let cosisq = cosip * cosip;
620
- con41 = 3.0 * cosisq - 1.0;
621
- x1mth2 = 1.0 - cosisq;
622
- x7thm1 = 7.0 * cosisq - 1.0;
623
- }
624
-
625
- let mrt = rl * (1.0 - 1.5 * temp2 * betal * con41) + 0.5 * temp1 * x1mth2 * cos2u;
626
-
627
- /** Moved this up to reduce unnecessary computation if you are going to return false anyway */
628
- // sgp4fix for decaying satellites
629
- if (mrt < 1.0) {
630
- // printf("// decay condition %11.6f \n",mrt);
631
- error = 6;
632
- return {
633
- error: error,
634
- p1: 0.0,
635
- p2: 0.0,
636
- p3: 0.0,
637
- v1: 0.0,
638
- v2: 0.0,
639
- v3: 0.0,
640
- };
641
- }
642
-
643
- su -= 0.25 * temp2 * x7thm1 * sin2u;
644
- let xnode = nodep + 1.5 * temp2 * cosip * sin2u;
645
- let xinc = xincp + 1.5 * temp2 * cosip * sinip * cos2u;
646
- let mvt = rdotl - (nm * temp1 * x1mth2 * sin2u) / xke;
647
- let rvdot = rvdotl + (nm * temp1 * (x1mth2 * cos2u + 1.5 * con41)) / xke;
648
-
649
- // --------------------- orientation vectors -------------------
650
- let sinsu = Math.sin(su);
651
- let cossu = Math.cos(su);
652
- let snod = Math.sin(xnode);
653
- let cnod = Math.cos(xnode);
654
- let sini = Math.sin(xinc);
655
- let cosi = Math.cos(xinc);
656
- let xmx = -snod * cosi;
657
- let xmy = cnod * cosi;
658
- let ux = xmx * sinsu + cnod * cossu;
659
- let uy = xmy * sinsu + snod * cossu;
660
- let uz = sini * sinsu;
661
- let vx = xmx * cossu - cnod * sinsu;
662
- let vy = xmy * cossu - snod * sinsu;
663
- let vz = sini * cossu;
664
-
665
- // --------- position and velocity (in km and km/sec) ----------
666
- let r = [mrt * ux * radiusearthkm, mrt * uy * radiusearthkm, mrt * uz * radiusearthkm];
667
-
668
- let v = [
669
- (mvt * ux + rvdot * vx) * vkmpersec,
670
- (mvt * uy + rvdot * vy) * vkmpersec,
671
- (mvt * uz + rvdot * vz) * vkmpersec,
672
- ];
673
-
674
- return {
675
- error: error,
676
- p1: r[0],
677
- p2: r[1],
678
- p3: r[2],
679
- v1: v[0],
680
- v2: v[1],
681
- v3: v[2],
682
- };
683
- }
684
-
685
- /*-----------------------------------------------------------------------------
686
- *
687
- * procedure dspace
688
- *
689
- * this procedure provides deep space contributions to mean elements for
690
- * perturbing third body. these effects have been averaged over one
691
- * revolution of the sun and moon. for earth resonance effects, the
692
- * effects have been averaged over no revolutions of the satellite.
693
- * (mean motion)
694
- *
695
- * author : david vallado 719-573-2600 28 jun 2005
696
- *
697
- * inputs :
698
- * d2201, d2211, d3210, d3222, d4410, d4422, d5220, d5232, d5421, d5433 -
699
- * dedt -
700
- * del1, del2, del3 -
701
- * didt -
702
- * dmdt -
703
- * dnodt -
704
- * domdt -
705
- * irez - flag for resonance 0-none, 1-one day, 2-half day
706
- * argpo - argument of perigee
707
- * argpdot - argument of perigee dot (rate)
708
- * t - time
709
- * tc -
710
- * gsto - gst
711
- * xfact -
712
- * xlamo -
713
- * no - mean motion
714
- * atime -
715
- * em - eccentricity
716
- * ft -
717
- * argpm - argument of perigee
718
- * inclm - inclination
719
- * xli -
720
- * mm - mean anomaly
721
- * xni - mean motion
722
- * nodem - right ascension of ascending node
723
- *
724
- * outputs :
725
- * atime -
726
- * em - eccentricity
727
- * argpm - argument of perigee
728
- * inclm - inclination
729
- * xli -
730
- * mm - mean anomaly
731
- * xni -
732
- * nodem - right ascension of ascending node
733
- * dndt -
734
- * nm - mean motion
735
- *
736
- * locals :
737
- * delt -
738
- * ft -
739
- * theta -
740
- * x2li -
741
- * x2omi -
742
- * xl -
743
- * xldot -
744
- * xnddt -
745
- * xndt -
746
- * xomi -
747
- *
748
- * coupling :
749
- * none -
750
- *
751
- * references :
752
- * hoots, roehrich, norad spacetrack report #3 1980
753
- * hoots, norad spacetrack report #6 1986
754
- * hoots, schumacher and glover 2004
755
- * vallado, crawford, hujsak, kelso 2006
756
- ----------------------------------------------------------------------------*/
757
- function dspace(
758
- irez: f64,
759
- d2201: f64,
760
- d2211: f64,
761
- d3210: f64,
762
- d3222: f64,
763
- d4410: f64,
764
- d4422: f64,
765
- d5220: f64,
766
- d5232: f64,
767
- d5421: f64,
768
- d5433: f64,
769
- dedt: f64,
770
- del1: f64,
771
- del2: f64,
772
- del3: f64,
773
- didt: f64,
774
- dmdt: f64,
775
- dnodt: f64,
776
- domdt: f64,
777
- argpo: f64,
778
- argpdot: f64,
779
- t: f64,
780
- tc: f64,
781
- gsto: f64,
782
- xfact: f64,
783
- xlamo: f64,
784
- no: f64,
785
- atime: f64,
786
- em: f64,
787
- argpm: f64,
788
- inclm: f64,
789
- xli: f64,
790
- mm: f64,
791
- xni: f64,
792
- nodem: f64,
793
- nm: f64,
794
- ): DspaceResults {
795
- /** Ootk -- Declared at the top of the file instead */
796
- const fasx2 = 0.13130908;
797
- const fasx4 = 2.8843198;
798
- const fasx6 = 0.37448087;
799
- const g22 = 5.7686396;
800
- const g32 = 0.95240898;
801
- const g44 = 1.8014998;
802
- const g52 = 1.050833;
803
- const g54 = 4.4108898;
804
- const rptim = 4.37526908801129966e-3; // equates to 7.29211514668855e-5 rad/sec
805
- const stepp = 720.0;
806
- const stepn = -720.0;
807
- const step2 = 259200.0;
808
-
809
- // ----------- calculate deep space resonance effects -----------
810
- let dndt = 0.0;
811
- let theta = (gsto + tc * rptim) % TAU;
812
- em += dedt * t;
813
-
814
- inclm += didt * t;
815
- argpm += domdt * t;
816
- nodem += dnodt * t;
817
- mm += dmdt * t;
818
-
819
- // sgp4fix for negative inclinations
820
- // the following if statement should be commented out
821
- // if (inclm < 0.0)
822
- // {
823
- // inclm = -inclm;
824
- // argpm = argpm - PI;
825
- // nodem = nodem + PI;
826
- // }
827
- /* - update resonances : numerical (euler-maclaurin) integration - */
828
- /* ------------------------- epoch restart ---------------------- */
829
- // sgp4fix for propagator problems
830
- // the following integration works for negative time steps and periods
831
- // the specific changes are unknown because the original code was so convoluted
832
- // sgp4fix take out atime = 0.0 and fix for faster operation
833
- // ft = 0.0; /** Ootk -- This has no value */
834
- if (irez !== 0) {
835
- // sgp4fix streamline check
836
- if (atime === 0.0 || t * atime <= 0.0 || Math.abs(t) < Math.abs(atime)) {
837
- atime = 0.0;
838
- xni = no;
839
- xli = xlamo;
840
- }
841
-
842
- // sgp4fix move check outside loop
843
- let delt: f64;
844
- if (t > 0.0) {
845
- delt = stepp;
846
- } else {
847
- delt = stepn;
848
- }
849
-
850
- let xndt: f64, xldot: f64, xnddt: f64, xomi: f64, x2omi: f64, x2li: f64, ft: f64;
851
- let iretn = 381; // added for do loop
852
- while (iretn === 381) {
853
- // ------------------- dot terms calculated -------------
854
- // ----------- near - synchronous resonance terms -------
855
- if (irez !== 2) {
856
- xndt =
857
- del1 * Math.sin(xli - fasx2) + del2 * Math.sin(2.0 * (xli - fasx4)) + del3 * Math.sin(3.0 * (xli - fasx6));
858
- xldot = xni + xfact;
859
- xnddt =
860
- del1 * Math.cos(xli - fasx2) +
861
- 2.0 * del2 * Math.cos(2.0 * (xli - fasx4)) +
862
- 3.0 * del3 * Math.cos(3.0 * (xli - fasx6));
863
- xnddt *= xldot;
864
- } else {
865
- // --------- near - half-day resonance terms --------
866
- xomi = argpo + argpdot * atime;
867
- x2omi = xomi + xomi;
868
- x2li = xli + xli;
869
- xndt =
870
- d2201 * Math.sin(x2omi + xli - g22) +
871
- d2211 * Math.sin(xli - g22) +
872
- d3210 * Math.sin(xomi + xli - g32) +
873
- d3222 * Math.sin(-xomi + xli - g32) +
874
- d4410 * Math.sin(x2omi + x2li - g44) +
875
- d4422 * Math.sin(x2li - g44) +
876
- d5220 * Math.sin(xomi + xli - g52) +
877
- d5232 * Math.sin(-xomi + xli - g52) +
878
- d5421 * Math.sin(xomi + x2li - g54) +
879
- d5433 * Math.sin(-xomi + x2li - g54);
880
- xldot = xni + xfact;
881
- xnddt =
882
- d2201 * Math.cos(x2omi + xli - g22) +
883
- d2211 * Math.cos(xli - g22) +
884
- d3210 * Math.cos(xomi + xli - g32) +
885
- d3222 * Math.cos(-xomi + xli - g32) +
886
- d5220 * Math.cos(xomi + xli - g52) +
887
- d5232 * Math.cos(-xomi + xli - g52) +
888
- 2.0 * d4410 * Math.cos(x2omi + x2li - g44) +
889
- d4422 * Math.cos(x2li - g44) +
890
- d5421 * Math.cos(xomi + x2li - g54) +
891
- d5433 * Math.cos(-xomi + x2li - g54);
892
- xnddt *= xldot;
893
- }
894
-
895
- // ----------------------- integrator -------------------
896
- // sgp4fix move end checks to end of routine
897
- if (Math.abs(t - atime) >= stepp) {
898
- // iret = 0; /** Ootk -- This has no value */
899
- iretn = 381;
900
- } else {
901
- ft = t - atime;
902
- iretn = 0;
903
- }
904
-
905
- if (iretn === 381) {
906
- xli += xldot * delt + xndt * step2;
907
- xni += xndt * delt + xnddt * step2;
908
- atime += delt;
909
- }
910
- } // while iretn = 381
911
-
912
- nm = xni + xndt * ft + xnddt * ft * ft * 0.5;
913
- let xl = xli + xldot * ft + xndt * ft * ft * 0.5;
914
- if (irez !== 1) {
915
- mm = xl - 2.0 * nodem + 2.0 * theta;
916
- dndt = nm - no;
917
- } else {
918
- mm = xl - nodem - argpm + theta;
919
- dndt = nm - no;
920
- }
921
- nm = no + dndt;
922
- }
923
-
924
- return new DspaceResults(atime, em, argpm, inclm, xli, mm, xni, nodem, dndt, nm);
925
- } // dspace
926
-
927
- /* -----------------------------------------------------------------------------
928
- *
929
- * procedure dpper
930
- *
931
- * this procedure provides deep space long period periodic contributions
932
- * to the mean elements. by design, these periodics are zero at epoch.
933
- * this used to be dscom which included initialization, but it's really a
934
- * recurring function.
935
- *
936
- * author : david vallado 719-573-2600 28 jun 2005
937
- *
938
- * inputs :
939
- * e3 -
940
- * ee2 -
941
- * peo -
942
- * pgho -
943
- * pho -
944
- * PInco -
945
- * plo -
946
- * se2 , se3 , sgh2, sgh3, sgh4, sh2, sh3, si2, si3, sl2, sl3, sl4 -
947
- * t -
948
- * xh2, xh3, xi2, xi3, xl2, xl3, xl4 -
949
- * zmol -
950
- * zmos -
951
- * ep - eccentricity 0.0 - 1.0
952
- * inclo - inclination - needed for lyddane modification
953
- * nodep - right ascension of ascending node
954
- * argpp - argument of perigee
955
- * mp - mean anomaly
956
- *
957
- * outputs :
958
- * ep - eccentricity 0.0 - 1.0
959
- * inclp - inclination
960
- * nodep - right ascension of ascending node
961
- * argpp - argument of perigee
962
- * mp - mean anomaly
963
- *
964
- * locals :
965
- * alfdp -
966
- * betdp -
967
- * cosip , sinip , cosop , sinop ,
968
- * dalf -
969
- * dbet -
970
- * dls -
971
- * f2, f3 -
972
- * pe -
973
- * pgh -
974
- * ph -
975
- * PInc -
976
- * pl -
977
- * sel , ses , sghl , sghs , shl , shs , sil , sinzf , sis ,
978
- * sll , sls
979
- * xls -
980
- * xnoh -
981
- * zf -
982
- * zm -
983
- *
984
- * coupling :
985
- * none.
986
- *
987
- * references :
988
- * hoots, roehrich, norad spacetrack report #3 1980
989
- * hoots, norad spacetrack report #6 1986
990
- * hoots, schumacher and glover 2004
991
- * vallado, crawford, hujsak, kelso 2006
992
- ----------------------------------------------------------------------------*/
993
- function dpper(
994
- e3: f64,
995
- ee2: f64,
996
- peo: f64,
997
- pgho: f64,
998
- pho: f64,
999
- PInco: f64,
1000
- plo: f64,
1001
- se2: f64,
1002
- se3: f64,
1003
- sgh2: f64,
1004
- sgh3: f64,
1005
- sgh4: f64,
1006
- sh2: f64,
1007
- sh3: f64,
1008
- si2: f64,
1009
- si3: f64,
1010
- sl2: f64,
1011
- sl3: f64,
1012
- sl4: f64,
1013
- t: f64,
1014
- xgh2: f64,
1015
- xgh3: f64,
1016
- xgh4: f64,
1017
- xh2: f64,
1018
- xh3: f64,
1019
- xi2: f64,
1020
- xi3: f64,
1021
- xl2: f64,
1022
- xl3: f64,
1023
- xl4: f64,
1024
- zmol: f64,
1025
- zmos: f64,
1026
- ep: f64,
1027
- inclp: f64,
1028
- nodep: f64,
1029
- argpp: f64,
1030
- mp: f64,
1031
- opsmode: string,
1032
- init: string,
1033
- ): DpperResult {
1034
- // ---------------------- constants -----------------------------
1035
- /** Ootk -- Declared outside the class at the top */
1036
- const zns = 1.19459e-5;
1037
- const zes = 0.01675;
1038
- const znl = 1.5835218e-4;
1039
- const zel = 0.0549;
1040
-
1041
- // --------------- calculate time varying periodics -----------
1042
- let zm = zmos + zns * t;
1043
- // be sure that the initial call has time set to zero
1044
- if (init === 'y') {
1045
- zm = zmos;
1046
- }
1047
- let zf = zm + 2.0 * zes * Math.sin(zm);
1048
- let sinzf = Math.sin(zf);
1049
- let f2 = 0.5 * sinzf * sinzf - 0.25;
1050
- let f3 = -0.5 * sinzf * Math.cos(zf);
1051
- let ses = se2 * f2 + se3 * f3;
1052
- let sis = si2 * f2 + si3 * f3;
1053
- let sls = sl2 * f2 + sl3 * f3 + sl4 * sinzf;
1054
- let sghs = sgh2 * f2 + sgh3 * f3 + sgh4 * sinzf;
1055
- let shs = sh2 * f2 + sh3 * f3;
1056
- zm = zmol + znl * t;
1057
- if (init === 'y') {
1058
- zm = zmol;
1059
- }
1060
- zf = zm + 2.0 * zel * Math.sin(zm);
1061
- sinzf = Math.sin(zf);
1062
- f2 = 0.5 * sinzf * sinzf - 0.25;
1063
- f3 = -0.5 * sinzf * Math.cos(zf);
1064
- let sel = ee2 * f2 + e3 * f3;
1065
- let sil = xi2 * f2 + xi3 * f3;
1066
- let sll = xl2 * f2 + xl3 * f3 + xl4 * sinzf;
1067
- let sghl = xgh2 * f2 + xgh3 * f3 + xgh4 * sinzf;
1068
- let shll = xh2 * f2 + xh3 * f3;
1069
- let pe = ses + sel;
1070
- let PInc = sis + sil;
1071
- let pl = sls + sll;
1072
- let pgh = sghs + sghl;
1073
- let ph = shs + shll;
1074
-
1075
- if (init === 'n') {
1076
- pe -= peo;
1077
- PInc -= PInco;
1078
- pl -= plo;
1079
- pgh -= pgho;
1080
- ph -= pho;
1081
- inclp += PInc;
1082
- ep += pe;
1083
- let sinip = Math.sin(inclp);
1084
- let cosip = Math.cos(inclp);
1085
-
1086
- /* ----------------- apply periodics directly ------------ */
1087
- // sgp4fix for lyddane choice
1088
- // strn3 used original inclination - this is technically feasible
1089
- // gsfc used perturbed inclination - also technically feasible
1090
- // probably best to readjust the 0.2 limit value and limit discontinuity
1091
- // 0.2 rad = 11.45916 deg
1092
- // use next line for original strn3 approach and original inclination
1093
- // if (inclo >= 0.2)
1094
- // use next line for gsfc version and perturbed inclination
1095
- if (inclp >= 0.2) {
1096
- ph /= sinip;
1097
- pgh -= cosip * ph;
1098
- argpp += pgh;
1099
- nodep += ph;
1100
- mp += pl;
1101
- } else {
1102
- // ---- apply periodics with lyddane modification ----
1103
- let sinop = Math.sin(nodep);
1104
- let cosop = Math.cos(nodep);
1105
- let alfdp = sinip * sinop;
1106
- let betdp = sinip * cosop;
1107
- let dalf = ph * cosop + PInc * cosip * sinop;
1108
- let dbet = -ph * sinop + PInc * cosip * cosop;
1109
- alfdp += dalf;
1110
- betdp += dbet;
1111
- nodep %= TAU;
1112
- // sgp4fix for afspc written intrinsic functions
1113
- // nodep used without a trigonometric function ahead
1114
- /* istanbul ignore next */
1115
- if (nodep < 0.0 && opsmode === 'a') {
1116
- nodep += TAU;
1117
- }
1118
- let xls = mp + argpp + cosip * nodep;
1119
- let dls = pl + pgh - PInc * nodep * sinip;
1120
- xls += dls;
1121
- let xnoh = nodep;
1122
- nodep = Math.atan2(alfdp, betdp);
1123
- // sgp4fix for afspc written intrinsic functions
1124
- // nodep used without a trigonometric function ahead
1125
- /* istanbul ignore next */
1126
- if (nodep < 0.0 && opsmode === 'a') {
1127
- nodep += TAU;
1128
- }
1129
- if (Math.abs(xnoh - nodep) > PI) {
1130
- /* istanbul ignore next */
1131
- if (nodep < xnoh) {
1132
- nodep += TAU;
1133
- } else {
1134
- nodep -= TAU;
1135
- }
1136
- }
1137
- mp += pl;
1138
- argpp = xls - mp - cosip * nodep;
1139
- }
1140
- } // if init == 'n'
1141
-
1142
- return new DpperResult(ep, inclp, nodep, argpp, mp);
1143
- } // dpper