ootk 1.0.4 → 1.0.6

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 (44) hide show
  1. package/CHANGELOG.md +19 -33
  2. package/LICENSE.MD +21 -21
  3. package/README.md +128 -128
  4. package/asc/asconfig.json +22 -0
  5. package/asc/assembly/index.ts +1143 -0
  6. package/asc/ex/asconfig.json +22 -0
  7. package/asc/ex/assembly/index.ts +5 -0
  8. package/asc/ex/index.html +10 -0
  9. package/asc/ex/package.json +19 -0
  10. package/asc/ex/tests/index.js +4 -0
  11. package/asc/package.json +19 -0
  12. package/asc/tests/index.js +4 -0
  13. package/dist/ootk.js +1 -3850
  14. package/lib/ootk.d.ts +3 -4
  15. package/lib/ootk.js +3 -4
  16. package/lib/ootk.js.map +1 -1
  17. package/lib/{ootk-sgp4.d.ts → sgp4.d.ts} +6 -140
  18. package/lib/{ootk-sgp4.js → sgp4.js} +545 -555
  19. package/lib/sgp4.js.map +1 -0
  20. package/lib/transforms.d.ts +58 -0
  21. package/lib/{ootk-transforms.js → transforms.js} +3 -4
  22. package/lib/transforms.js.map +1 -0
  23. package/lib/{ootk-utils.d.ts → utils/constants.d.ts} +6 -11
  24. package/lib/utils/constants.js +31 -0
  25. package/lib/utils/constants.js.map +1 -0
  26. package/lib/utils/types.d.ts +164 -0
  27. package/lib/utils/types.js +2 -0
  28. package/lib/utils/types.js.map +1 -0
  29. package/lib/utils.d.ts +33 -0
  30. package/lib/{ootk-utils.js → utils.js} +12 -6
  31. package/lib/utils.js.map +1 -0
  32. package/package.json +15 -16
  33. package/sandbox.html +8 -0
  34. package/dist/ootk-sgp4.js +0 -3471
  35. package/dist/ootk-sgp4.min.js +0 -34
  36. package/dist/ootk-transforms.js +0 -340
  37. package/dist/ootk-transforms.min.js +0 -1
  38. package/dist/ootk-utils.js +0 -149
  39. package/dist/ootk-utils.min.js +0 -1
  40. package/dist/ootk.min.js +0 -60
  41. package/lib/ootk-sgp4.js.map +0 -1
  42. package/lib/ootk-transforms.d.ts +0 -141
  43. package/lib/ootk-transforms.js.map +0 -1
  44. package/lib/ootk-utils.js.map +0 -1
package/dist/ootk-sgp4.js DELETED
@@ -1,3471 +0,0 @@
1
- (function webpackUniversalModuleDefinition(root, factory) {
2
- if(typeof exports === 'object' && typeof module === 'object')
3
- module.exports = factory();
4
- else if(typeof define === 'function' && define.amd)
5
- define([], factory);
6
- else if(typeof exports === 'object')
7
- exports["Ootk"] = factory();
8
- else
9
- root["Ootk"] = factory();
10
- })(this, function() {
11
- return /******/ (() => { // webpackBootstrap
12
- /******/ "use strict";
13
- /******/ var __webpack_modules__ = ({
14
-
15
- /***/ 333:
16
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
17
-
18
- __webpack_require__.r(__webpack_exports__);
19
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
20
- /* harmony export */ "Sgp4": () => /* binding */ Sgp4
21
- /* harmony export */ });
22
- /**
23
- * @author Theodore Kruczek.
24
- * @description Orbital Object ToolKit (OOTK) is a collection of tools for working
25
- * with satellites and other orbital objects.
26
- *
27
- * @file The Sgp4 module contains a TypeScript port of the 2020 version of
28
- * sgp4unit.cpp from "Fundamentals of Astrodynamics and Applications" by David
29
- * Vallado. All of the original comments and notes are inserted in the code below
30
- * in order provide context to the functions and clarify any adjustments made for
31
- * TypeScript/JavaScript compatibility.
32
- *
33
- * @copyright MIT License.
34
- * Copyright (c) 2020-2021 Theodore Kruczek
35
- *
36
- * Permission is hereby granted, free of charge, to any person obtaining a copy
37
- * of this software and associated documentation files (the "Software"), to deal
38
- * in the Software without restriction, including without limitation the rights
39
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
40
- * copies of the Software, and to permit persons to whom the Software is
41
- * furnished to do so, subject to the following conditions:
42
- *
43
- * The above copyright notice and this permission notice shall be included in all
44
- * copies or substantial portions of the Software.
45
- *
46
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
47
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
48
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
49
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
50
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
51
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
52
- * SOFTWARE.
53
- */
54
-
55
- /* ----------------------------------------------------------------
56
- *
57
- * sgp4unit.cpp
58
- *
59
- * this file contains the sgp4 procedures for analytical propagation
60
- * of a satellite. the code was originally released in the 1980 and 1986
61
- * spacetrack papers. a detailed discussion of the theory and history
62
- * may be found in the 2006 aiaa paper by vallado, crawford, hujsak,
63
- * and kelso.
64
- *
65
- * companion code for
66
- * fundamentals of astrodynamics and applications
67
- * 2013
68
- * by david vallado
69
- *
70
- * (w) 719-573-2600, email dvallado@agi.com, davallado@gmail.com
71
- *
72
- * current :
73
- * 12 mar 20 david vallado
74
- * chg satnum to string for alpha 5 or 9-digit
75
- * changes :
76
- * 7 dec 15 david vallado
77
- * fix jd, jdfrac
78
- * 3 nov 14 david vallado
79
- * update to msvs2013 c++
80
- * 30 aug 10 david vallado
81
- * delete unused variables in initl
82
- * replace pow integer 2, 3 with multiplies for speed
83
- * 3 nov 08 david vallado
84
- * put returns in for error codes
85
- * 29 sep 08 david vallado
86
- * fix atime for faster operation in dspace
87
- * add operationmode for afspc (a) or improved (i)
88
- * performance mode
89
- * 16 jun 08 david vallado
90
- * update small eccentricity check
91
- * 16 nov 07 david vallado
92
- * misc fixes for better compliance
93
- * 20 apr 07 david vallado
94
- * misc fixes for constants
95
- * 11 aug 06 david vallado
96
- * chg lyddane choice back to strn3, constants, misc doc
97
- * 15 dec 05 david vallado
98
- * misc fixes
99
- * 26 jul 05 david vallado
100
- * fixes for paper
101
- * note that each fix is preceded by a
102
- * comment with "sgp4fix" and an explanation of
103
- * what was changed
104
- * 10 aug 04 david vallado
105
- * 2nd printing baseline working
106
- * 14 may 01 david vallado
107
- * 2nd edition baseline
108
- * 80 norad
109
- * original baseline
110
- * ---------------------------------------------------------------- */
111
- var PI = Math.PI;
112
- var TAU = PI * 2;
113
- var DEG2RAD = PI / 180.0;
114
- var x2o3 = 2.0 / 3.0;
115
- var xpdotp = 1440.0 / (2.0 * PI); // 229.1831180523293;
116
-
117
- var zes = 0.01675;
118
- var zel = 0.0549;
119
- var c1ss = 2.9864797e-6;
120
- var c1l = 4.7968065e-7;
121
- var zsinis = 0.39785416;
122
- var zcosis = 0.91744867;
123
- var zcosgs = 0.1945905;
124
- var zsings = -0.98088458;
125
- var q22 = 1.7891679e-6;
126
- var q31 = 2.1460748e-6;
127
- var q33 = 2.2123015e-7;
128
- var root22 = 1.7891679e-6;
129
- var root44 = 7.3636953e-9;
130
- var root54 = 2.1765803e-9;
131
- var rptim = 4.37526908801129966e-3; // equates to 7.29211514668855e-5 rad/sec
132
-
133
- var root32 = 3.7393792e-7;
134
- var root52 = 1.1428639e-7;
135
- var znl = 1.5835218e-4;
136
- var zns = 1.19459e-5;
137
- var temp4 = 1.5e-12;
138
- var fasx2 = 0.13130908;
139
- var fasx4 = 2.8843198;
140
- var fasx6 = 0.37448087;
141
- var g22 = 5.7686396;
142
- var g32 = 0.95240898;
143
- var g44 = 1.8014998;
144
- var g52 = 1.050833;
145
- var g54 = 4.4108898;
146
- var stepp = 720.0;
147
- var stepn = -720.0;
148
- var step2 = 259200.0;
149
- /**
150
- * Ootk code is run synchronously and often on super tight loops, so lets reuse the variables as much as possible.
151
- */
152
- // prettier-ignore
153
-
154
- var axnl, aynl, xl, u, ktr, vkmpersec, ecose, esine, el2, pl, rl, rdotl, rvdotl, betal, sinu, cosu, sin2u, coseo1, sineo1, cosip, sinip, cosisq, delm, delomg, eo1, argpm, argpp, su, t3, t4, tc, tem5, temp, tempa, tempe, templ, inclm, mm, nm, nodem, xincp, xlm, mp, nodep, xmdf, argpdf, nodedf, t2, delmtemp, em, dspaceOptions, dspaceResult, am, ep, cosim, sinim, dpperResult, dpperParameters, method, ts70, ds70, c1, tfrac, thgr70, fk5r, c1p2p, dndt, ft, delt, xndt, xldot, xnddt, x2omi, xomi, x2li, theta, tut1, snodm, cnodm, sinomm, cosomm, betasq, rtemsq, peo, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, cc, x1, x2, x3, x4, x5, x6, x7, x8, zcosg, zsing, zcosh, zsinh, zcosi, zsini, ss1, ss2, ss3, ss4, ss5, ss6, ss7, sz1, sz2, sz3, sz11, sz12, sz13, sz21, sz22, sz23, sz31, sz32, sz33, s1, s2, s3, s4, s5, s6, s7, z1, z2, z3, z11, z12, z13, z21, z22, z23, z31, z32, z33, f220, f221, f311, f321, f322, f330, f441, f442, f522, f523, f542, f543, g200, g201, g211, g300, g310, g322, g410, g422, g520, g521, g532, g533, sini2, temp1, xno2, ainv2, aonv, cos2u, mrt, temp2, xnode, xinc, mvt, rvdot, sinsu, cossu, snod, cnod, cosi, sini, xmx, xmy, ux, uy, uz, vx, vy, vz, r, v, year, satrec, dsinitResult, dsinitOptions, ao, mon, day, hr, minute, sec, ss, qzms24temp, qzms2ttemp, initlOptions, initlResult, cosio, delmotemp, dscomOptions, dscomResult, dpperOptions, sinio, qzms2t, con42, cosio2, lmonth, dayofyr, inttemp, i, eccsq, omeosq, rteosq, ak, d1, adel, po, ses, sis, sls, sghs, shs, sel, sil, sll, con41, ainv, posq, rp, sghl, shll, PInco, plo, pho, ctem, zcosil, zsinhl, stem, zsingl, zsinil, gam, zy, pgho, zcoshl, xnoi, zcosgl, zmol, zmos, se2, se3, si2, si3, sl2, sl3, sl4, sgh2, xnodce, sh3, sgh4, sh2, ee2, e3, xi2, xi3, xl2, xl3, xl4, sgh3, xgh2, xgh3, xgh4, xh2, xh3, sgs, emo, emsqo, eoc, alfdp, betdp, cosop, sinop, dalf, dbet, dls, f2, f3, pe, pgh, ph, PInc, sinzf, xls, xnoh, zf, zm, cc1sq, cc2, cc3, coef, coef1, cosio4, emsq, eeta, etasq, perige, PInvsq, psisq, qzms24, sfour, temp3, tsi, xPIdot, xhdot1, leadingChar, gsto, lsflg, j2, j3, j3oj2, j4, xke, mus, radiusearthkm, tumin;
155
-
156
- var Sgp4 =
157
- /** @class */
158
- function () {
159
- function Sgp4() {}
160
- /* -----------------------------------------------------------------------------
161
- *
162
- * procedure dpper
163
- *
164
- * this procedure provides deep space long period periodic contributions
165
- * to the mean elements. by design, these periodics are zero at epoch.
166
- * this used to be dscom which included initialization, but it's really a
167
- * recurring function.
168
- *
169
- * author : david vallado 719-573-2600 28 jun 2005
170
- *
171
- * inputs :
172
- * e3 -
173
- * ee2 -
174
- * peo -
175
- * pgho -
176
- * pho -
177
- * PInco -
178
- * plo -
179
- * se2 , se3 , sgh2, sgh3, sgh4, sh2, sh3, si2, si3, sl2, sl3, sl4 -
180
- * t -
181
- * xh2, xh3, xi2, xi3, xl2, xl3, xl4 -
182
- * zmol -
183
- * zmos -
184
- * ep - eccentricity 0.0 - 1.0
185
- * inclo - inclination - needed for lyddane modification
186
- * nodep - right ascension of ascending node
187
- * argpp - argument of perigee
188
- * mp - mean anomaly
189
- *
190
- * outputs :
191
- * ep - eccentricity 0.0 - 1.0
192
- * inclp - inclination
193
- * nodep - right ascension of ascending node
194
- * argpp - argument of perigee
195
- * mp - mean anomaly
196
- *
197
- * locals :
198
- * alfdp -
199
- * betdp -
200
- * cosip , sinip , cosop , sinop ,
201
- * dalf -
202
- * dbet -
203
- * dls -
204
- * f2, f3 -
205
- * pe -
206
- * pgh -
207
- * ph -
208
- * PInc -
209
- * pl -
210
- * sel , ses , sghl , sghs , shl , shs , sil , sinzf , sis ,
211
- * sll , sls
212
- * xls -
213
- * xnoh -
214
- * zf -
215
- * zm -
216
- *
217
- * coupling :
218
- * none.
219
- *
220
- * references :
221
- * hoots, roehrich, norad spacetrack report #3 1980
222
- * hoots, norad spacetrack report #6 1986
223
- * hoots, schumacher and glover 2004
224
- * vallado, crawford, hujsak, kelso 2006
225
- ----------------------------------------------------------------------------*/
226
-
227
-
228
- Sgp4.dpper = function (satrec, options) {
229
- var e3 = satrec.e3,
230
- ee2 = satrec.ee2,
231
- peo = satrec.peo,
232
- pgho = satrec.pgho,
233
- pho = satrec.pho,
234
- PInco = satrec.PInco,
235
- plo = satrec.plo,
236
- se2 = satrec.se2,
237
- se3 = satrec.se3,
238
- sgh2 = satrec.sgh2,
239
- sgh3 = satrec.sgh3,
240
- sgh4 = satrec.sgh4,
241
- sh2 = satrec.sh2,
242
- sh3 = satrec.sh3,
243
- si2 = satrec.si2,
244
- si3 = satrec.si3,
245
- sl2 = satrec.sl2,
246
- sl3 = satrec.sl3,
247
- sl4 = satrec.sl4,
248
- t = satrec.t,
249
- xgh2 = satrec.xgh2,
250
- xgh3 = satrec.xgh3,
251
- xgh4 = satrec.xgh4,
252
- xh2 = satrec.xh2,
253
- xh3 = satrec.xh3,
254
- xi2 = satrec.xi2,
255
- xi3 = satrec.xi3,
256
- xl2 = satrec.xl2,
257
- xl3 = satrec.xl3,
258
- xl4 = satrec.xl4,
259
- zmol = satrec.zmol,
260
- zmos = satrec.zmos;
261
- var ep = options.ep,
262
- inclp = options.inclp,
263
- nodep = options.nodep,
264
- argpp = options.argpp,
265
- mp = options.mp;
266
- var _a = options.opsmode,
267
- opsmode = _a === void 0 ? i : _a,
268
- init = options.init; // ---------------------- constants -----------------------------
269
-
270
- /** Ootk -- Declared outside the class at the top */
271
- // zns = 1.19459e-5;
272
- // zes = 0.01675;
273
- // znl = 1.5835218e-4;
274
- // zel = 0.0549;
275
- // --------------- calculate time varying periodics -----------
276
-
277
- zm = zmos + zns * t; // be sure that the initial call has time set to zero
278
-
279
- if (init === 'y') {
280
- zm = zmos;
281
- }
282
-
283
- zf = zm + 2.0 * zes * Math.sin(zm);
284
- sinzf = Math.sin(zf);
285
- f2 = 0.5 * sinzf * sinzf - 0.25;
286
- f3 = -0.5 * sinzf * Math.cos(zf);
287
- ses = se2 * f2 + se3 * f3;
288
- sis = si2 * f2 + si3 * f3;
289
- sls = sl2 * f2 + sl3 * f3 + sl4 * sinzf;
290
- sghs = sgh2 * f2 + sgh3 * f3 + sgh4 * sinzf;
291
- shs = sh2 * f2 + sh3 * f3;
292
- zm = zmol + znl * t;
293
-
294
- if (init === 'y') {
295
- zm = zmol;
296
- }
297
-
298
- zf = zm + 2.0 * zel * Math.sin(zm);
299
- sinzf = Math.sin(zf);
300
- f2 = 0.5 * sinzf * sinzf - 0.25;
301
- f3 = -0.5 * sinzf * Math.cos(zf);
302
- sel = ee2 * f2 + e3 * f3;
303
- sil = xi2 * f2 + xi3 * f3;
304
- sll = xl2 * f2 + xl3 * f3 + xl4 * sinzf;
305
- sghl = xgh2 * f2 + xgh3 * f3 + xgh4 * sinzf;
306
- shll = xh2 * f2 + xh3 * f3;
307
- pe = ses + sel;
308
- PInc = sis + sil;
309
- pl = sls + sll;
310
- pgh = sghs + sghl;
311
- ph = shs + shll;
312
-
313
- if (init === 'n') {
314
- pe -= peo;
315
- PInc -= PInco;
316
- pl -= plo;
317
- pgh -= pgho;
318
- ph -= pho;
319
- inclp += PInc;
320
- ep += pe;
321
- sinip = Math.sin(inclp);
322
- cosip = Math.cos(inclp);
323
- /* ----------------- apply periodics directly ------------ */
324
- // sgp4fix for lyddane choice
325
- // strn3 used original inclination - this is technically feasible
326
- // gsfc used perturbed inclination - also technically feasible
327
- // probably best to readjust the 0.2 limit value and limit discontinuity
328
- // 0.2 rad = 11.45916 deg
329
- // use next line for original strn3 approach and original inclination
330
- // if (inclo >= 0.2)
331
- // use next line for gsfc version and perturbed inclination
332
-
333
- if (inclp >= 0.2) {
334
- ph /= sinip;
335
- pgh -= cosip * ph;
336
- argpp += pgh;
337
- nodep += ph;
338
- mp += pl;
339
- } else {
340
- // ---- apply periodics with lyddane modification ----
341
- sinop = Math.sin(nodep);
342
- cosop = Math.cos(nodep);
343
- alfdp = sinip * sinop;
344
- betdp = sinip * cosop;
345
- dalf = ph * cosop + PInc * cosip * sinop;
346
- dbet = -ph * sinop + PInc * cosip * cosop;
347
- alfdp += dalf;
348
- betdp += dbet;
349
- nodep %= TAU; // sgp4fix for afspc written intrinsic functions
350
- // nodep used without a trigonometric function ahead
351
-
352
- /* istanbul ignore next */
353
-
354
- if (nodep < 0.0 && opsmode === 'a') {
355
- nodep += TAU;
356
- }
357
-
358
- xls = mp + argpp + cosip * nodep;
359
- dls = pl + pgh - PInc * nodep * sinip;
360
- xls += dls;
361
- xnoh = nodep;
362
- nodep = Math.atan2(alfdp, betdp); // sgp4fix for afspc written intrinsic functions
363
- // nodep used without a trigonometric function ahead
364
-
365
- /* istanbul ignore next */
366
-
367
- if (nodep < 0.0 && opsmode === 'a') {
368
- nodep += TAU;
369
- }
370
-
371
- if (Math.abs(xnoh - nodep) > PI) {
372
- /* istanbul ignore next */
373
- if (nodep < xnoh) {
374
- nodep += TAU;
375
- } else {
376
- nodep -= TAU;
377
- }
378
- }
379
-
380
- mp += pl;
381
- argpp = xls - mp - cosip * nodep;
382
- }
383
- } // if init == 'n'
384
-
385
-
386
- return {
387
- ep: ep,
388
- inclp: inclp,
389
- nodep: nodep,
390
- argpp: argpp,
391
- mp: mp
392
- };
393
- }; // dpper
394
-
395
- /*-----------------------------------------------------------------------------
396
- *
397
- * procedure dscom
398
- *
399
- * this procedure provides deep space common items used by both the secular
400
- * and periodics subroutines. input is provided as shown. this routine
401
- * used to be called dpper, but the functions inside weren't well organized.
402
- *
403
- * author : david vallado 719-573-2600 28 jun 2005
404
- *
405
- * inputs :
406
- * epoch -
407
- * ep - eccentricity
408
- * argpp - argument of perigee
409
- * tc -
410
- * inclp - inclination
411
- * nodep - right ascension of ascending node
412
- * np - mean motion
413
- *
414
- * outputs :
415
- * sinim , cosim , sinomm , cosomm , snodm , cnodm
416
- * day -
417
- * e3 -
418
- * ee2 -
419
- * em - eccentricity
420
- * emsq - eccentricity squared
421
- * gam -
422
- * peo -
423
- * pgho -
424
- * pho -
425
- * PInco -
426
- * plo -
427
- * rtemsq -
428
- * se2, se3 -
429
- * sgh2, sgh3, sgh4 -
430
- * sh2, sh3, si2, si3, sl2, sl3, sl4 -
431
- * s1, s2, s3, s4, s5, s6, s7 -
432
- * ss1, ss2, ss3, ss4, ss5, ss6, ss7, sz1, sz2, sz3 -
433
- * sz11, sz12, sz13, sz21, sz22, sz23, sz31, sz32, sz33 -
434
- * xgh2, xgh3, xgh4, xh2, xh3, xi2, xi3, xl2, xl3, xl4 -
435
- * nm - mean motion
436
- * z1, z2, z3, z11, z12, z13, z21, z22, z23, z31, z32, z33 -
437
- * zmol -
438
- * zmos -
439
- *
440
- * locals :
441
- * a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 -
442
- * betasq -
443
- * cc -
444
- * ctem, stem -
445
- * x1, x2, x3, x4, x5, x6, x7, x8 -
446
- * xnodce -
447
- * xnoi -
448
- * zcosg , zsing , zcosgl , zsingl , zcosh , zsinh , zcoshl , zsinhl ,
449
- * zcosi , zsini , zcosil , zsinil ,
450
- * zx -
451
- * zy -
452
- *
453
- * coupling :
454
- * none.
455
- *
456
- * references :
457
- * hoots, roehrich, norad spacetrack report #3 1980
458
- * hoots, norad spacetrack report #6 1986
459
- * hoots, schumacher and glover 2004
460
- * vallado, crawford, hujsak, kelso 2006
461
- ----------------------------------------------------------------------------*/
462
-
463
-
464
- Sgp4.dscom = function (options) {
465
- var epoch = options.epoch,
466
- ep = options.ep,
467
- argpp = options.argpp,
468
- tc = options.tc,
469
- inclp = options.inclp,
470
- nodep = options.nodep,
471
- np = options.np; // -------------------------- constants -------------------------
472
-
473
- /** Ootk -- These are declared outside the class at the top of the file */
474
- // zes = 0.01675;
475
- // zel = 0.0549;
476
- // c1ss = 2.9864797e-6;
477
- // c1l = 4.7968065e-7;
478
- // zsinis = 0.39785416;
479
- // zcosis = 0.91744867;
480
- // zcosgs = 0.1945905;
481
- // zsings = -0.98088458;
482
- // TAU = 2.0 * Math.PI;
483
- // --------------------- local variables ------------------------
484
-
485
- nm = np;
486
- em = ep;
487
- snodm = Math.sin(nodep);
488
- cnodm = Math.cos(nodep);
489
- sinomm = Math.sin(argpp);
490
- cosomm = Math.cos(argpp);
491
- sinim = Math.sin(inclp);
492
- cosim = Math.cos(inclp);
493
- emsq = em * em;
494
- betasq = 1.0 - emsq;
495
- rtemsq = Math.sqrt(betasq); // ----------------- initialize lunar solar terms ---------------
496
-
497
- peo = 0.0;
498
- PInco = 0.0;
499
- plo = 0.0;
500
- pgho = 0.0;
501
- pho = 0.0;
502
- day = epoch + 18261.5 + tc / 1440.0;
503
- xnodce = (4.523602 - 9.2422029e-4 * day) % TAU;
504
- stem = Math.sin(xnodce);
505
- ctem = Math.cos(xnodce);
506
- zcosil = 0.91375164 - 0.03568096 * ctem;
507
- zsinil = Math.sqrt(1.0 - zcosil * zcosil);
508
- zsinhl = 0.089683511 * stem / zsinil;
509
- zcoshl = Math.sqrt(1.0 - zsinhl * zsinhl);
510
- gam = 5.8351514 + 0.001944368 * day;
511
- var zx = 0.39785416 * stem / zsinil;
512
- zy = zcoshl * ctem + 0.91744867 * zsinhl * stem;
513
- zx = Math.atan2(zx, zy);
514
- zx += gam - xnodce;
515
- zcosgl = Math.cos(zx);
516
- zsingl = Math.sin(zx); // ------------------------- do solar terms ---------------------
517
-
518
- zcosg = zcosgs;
519
- zsing = zsings;
520
- zcosi = zcosis;
521
- zsini = zsinis;
522
- zcosh = cnodm;
523
- zsinh = snodm;
524
- cc = c1ss;
525
- xnoi = 1.0 / nm;
526
-
527
- for (lsflg = 1; lsflg <= 2; lsflg++) {
528
- a1 = zcosg * zcosh + zsing * zcosi * zsinh;
529
- a3 = -zsing * zcosh + zcosg * zcosi * zsinh;
530
- a7 = -zcosg * zsinh + zsing * zcosi * zcosh;
531
- a8 = zsing * zsini;
532
- a9 = zsing * zsinh + zcosg * zcosi * zcosh;
533
- a10 = zcosg * zsini;
534
- a2 = cosim * a7 + sinim * a8;
535
- a4 = cosim * a9 + sinim * a10;
536
- a5 = -sinim * a7 + cosim * a8;
537
- a6 = -sinim * a9 + cosim * a10;
538
- x1 = a1 * cosomm + a2 * sinomm;
539
- x2 = a3 * cosomm + a4 * sinomm;
540
- x3 = -a1 * sinomm + a2 * cosomm;
541
- x4 = -a3 * sinomm + a4 * cosomm;
542
- x5 = a5 * sinomm;
543
- x6 = a6 * sinomm;
544
- x7 = a5 * cosomm;
545
- x8 = a6 * cosomm;
546
- z31 = 12.0 * x1 * x1 - 3.0 * x3 * x3;
547
- z32 = 24.0 * x1 * x2 - 6.0 * x3 * x4;
548
- z33 = 12.0 * x2 * x2 - 3.0 * x4 * x4;
549
- z1 = 3.0 * (a1 * a1 + a2 * a2) + z31 * emsq;
550
- z2 = 6.0 * (a1 * a3 + a2 * a4) + z32 * emsq;
551
- z3 = 3.0 * (a3 * a3 + a4 * a4) + z33 * emsq;
552
- z11 = -6.0 * a1 * a5 + emsq * (-24.0 * x1 * x7 - 6.0 * x3 * x5);
553
- z12 = -6.0 * (a1 * a6 + a3 * a5) + emsq * (-24.0 * (x2 * x7 + x1 * x8) + -6.0 * (x3 * x6 + x4 * x5));
554
- z13 = -6.0 * a3 * a6 + emsq * (-24.0 * x2 * x8 - 6.0 * x4 * x6);
555
- z21 = 6.0 * a2 * a5 + emsq * (24.0 * x1 * x5 - 6.0 * x3 * x7);
556
- z22 = 6.0 * (a4 * a5 + a2 * a6) + emsq * (24.0 * (x2 * x5 + x1 * x6) - 6.0 * (x4 * x7 + x3 * x8));
557
- z23 = 6.0 * a4 * a6 + emsq * (24.0 * x2 * x6 - 6.0 * x4 * x8);
558
- z1 = z1 + z1 + betasq * z31;
559
- z2 = z2 + z2 + betasq * z32;
560
- z3 = z3 + z3 + betasq * z33;
561
- s3 = cc * xnoi;
562
- s2 = -0.5 * s3 / rtemsq;
563
- s4 = s3 * rtemsq;
564
- s1 = -15.0 * em * s4;
565
- s5 = x1 * x3 + x2 * x4;
566
- s6 = x2 * x3 + x1 * x4;
567
- s7 = x2 * x4 - x1 * x3; // ----------------------- do lunar terms -------------------
568
-
569
- if (lsflg === 1) {
570
- ss1 = s1;
571
- ss2 = s2;
572
- ss3 = s3;
573
- ss4 = s4;
574
- ss5 = s5;
575
- ss6 = s6;
576
- ss7 = s7;
577
- sz1 = z1;
578
- sz2 = z2;
579
- sz3 = z3;
580
- sz11 = z11;
581
- sz12 = z12;
582
- sz13 = z13;
583
- sz21 = z21;
584
- sz22 = z22;
585
- sz23 = z23;
586
- sz31 = z31;
587
- sz32 = z32;
588
- sz33 = z33;
589
- zcosg = zcosgl;
590
- zsing = zsingl;
591
- zcosi = zcosil;
592
- zsini = zsinil;
593
- zcosh = zcoshl * cnodm + zsinhl * snodm;
594
- zsinh = snodm * zcoshl - cnodm * zsinhl;
595
- cc = c1l;
596
- }
597
- }
598
-
599
- zmol = (4.7199672 + (0.2299715 * day - gam)) % TAU;
600
- zmos = (6.2565837 + 0.017201977 * day) % TAU; // ------------------------ do solar terms ----------------------
601
-
602
- se2 = 2.0 * ss1 * ss6;
603
- se3 = 2.0 * ss1 * ss7;
604
- si2 = 2.0 * ss2 * sz12;
605
- si3 = 2.0 * ss2 * (sz13 - sz11);
606
- sl2 = -2.0 * ss3 * sz2;
607
- sl3 = -2.0 * ss3 * (sz3 - sz1);
608
- sl4 = -2.0 * ss3 * (-21.0 - 9.0 * emsq) * zes;
609
- sgh2 = 2.0 * ss4 * sz32;
610
- sgh3 = 2.0 * ss4 * (sz33 - sz31);
611
- sgh4 = -18.0 * ss4 * zes;
612
- sh2 = -2.0 * ss2 * sz22;
613
- sh3 = -2.0 * ss2 * (sz23 - sz21); // ------------------------ do lunar terms ----------------------
614
-
615
- ee2 = 2.0 * s1 * s6;
616
- e3 = 2.0 * s1 * s7;
617
- xi2 = 2.0 * s2 * z12;
618
- xi3 = 2.0 * s2 * (z13 - z11);
619
- xl2 = -2.0 * s3 * z2;
620
- xl3 = -2.0 * s3 * (z3 - z1);
621
- xl4 = -2.0 * s3 * (-21.0 - 9.0 * emsq) * zel;
622
- xgh2 = 2.0 * s4 * z32;
623
- xgh3 = 2.0 * s4 * (z33 - z31);
624
- xgh4 = -18.0 * s4 * zel;
625
- xh2 = -2.0 * s2 * z22;
626
- xh3 = -2.0 * s2 * (z23 - z21);
627
- return {
628
- snodm: snodm,
629
- cnodm: cnodm,
630
- sinim: sinim,
631
- cosim: cosim,
632
- sinomm: sinomm,
633
- cosomm: cosomm,
634
- day: day,
635
- e3: e3,
636
- ee2: ee2,
637
- em: em,
638
- emsq: emsq,
639
- gam: gam,
640
- peo: peo,
641
- pgho: pgho,
642
- pho: pho,
643
- PInco: PInco,
644
- plo: plo,
645
- rtemsq: rtemsq,
646
- se2: se2,
647
- se3: se3,
648
- sgh2: sgh2,
649
- sgh3: sgh3,
650
- sgh4: sgh4,
651
- sh2: sh2,
652
- sh3: sh3,
653
- si2: si2,
654
- si3: si3,
655
- sl2: sl2,
656
- sl3: sl3,
657
- sl4: sl4,
658
- s1: s1,
659
- s2: s2,
660
- s3: s3,
661
- s4: s4,
662
- s5: s5,
663
- s6: s6,
664
- s7: s7,
665
- ss1: ss1,
666
- ss2: ss2,
667
- ss3: ss3,
668
- ss4: ss4,
669
- ss5: ss5,
670
- ss6: ss6,
671
- ss7: ss7,
672
- sz1: sz1,
673
- sz2: sz2,
674
- sz3: sz3,
675
- sz11: sz11,
676
- sz12: sz12,
677
- sz13: sz13,
678
- sz21: sz21,
679
- sz22: sz22,
680
- sz23: sz23,
681
- sz31: sz31,
682
- sz32: sz32,
683
- sz33: sz33,
684
- xgh2: xgh2,
685
- xgh3: xgh3,
686
- xgh4: xgh4,
687
- xh2: xh2,
688
- xh3: xh3,
689
- xi2: xi2,
690
- xi3: xi3,
691
- xl2: xl2,
692
- xl3: xl3,
693
- xl4: xl4,
694
- nm: nm,
695
- z1: z1,
696
- z2: z2,
697
- z3: z3,
698
- z11: z11,
699
- z12: z12,
700
- z13: z13,
701
- z21: z21,
702
- z22: z22,
703
- z23: z23,
704
- z31: z31,
705
- z32: z32,
706
- z33: z33,
707
- zmol: zmol,
708
- zmos: zmos
709
- };
710
- }; // dscom
711
-
712
- /*-----------------------------------------------------------------------------
713
- *
714
- * procedure dsinit
715
- *
716
- * this procedure provides deep space contributions to mean motion dot due
717
- * to geopotential resonance with half day and one day orbits.
718
- *
719
- * author : david vallado 719-573-2600 28 jun 2005
720
- *
721
- * inputs :
722
- * cosim, sinim-
723
- * emsq - eccentricity squared
724
- * argpo - argument of perigee
725
- * s1, s2, s3, s4, s5 -
726
- * ss1, ss2, ss3, ss4, ss5 -
727
- * sz1, sz3, sz11, sz13, sz21, sz23, sz31, sz33 -
728
- * t - time
729
- * tc -
730
- * gsto - greenwich sidereal time rad
731
- * mo - mean anomaly
732
- * mdot - mean anomaly dot (rate)
733
- * no - mean motion
734
- * nodeo - right ascension of ascending node
735
- * nodedot - right ascension of ascending node dot (rate)
736
- * xPIdot -
737
- * z1, z3, z11, z13, z21, z23, z31, z33 -
738
- * eccm - eccentricity
739
- * argpm - argument of perigee
740
- * inclm - inclination
741
- * mm - mean anomaly
742
- * xn - mean motion
743
- * nodem - right ascension of ascending node
744
- *
745
- * outputs :
746
- * em - eccentricity
747
- * argpm - argument of perigee
748
- * inclm - inclination
749
- * mm - mean anomaly
750
- * nm - mean motion
751
- * nodem - right ascension of ascending node
752
- * irez - flag for resonance 0-none, 1-one day, 2-half day
753
- * atime -
754
- * d2201, d2211, d3210, d3222, d4410, d4422, d5220, d5232, d5421, d5433 -
755
- * dedt -
756
- * didt -
757
- * dmdt -
758
- * dndt -
759
- * dnodt -
760
- * domdt -
761
- * del1, del2, del3 -
762
- * ses , sghl , sghs , sgs , shl , shs , sis , sls
763
- * theta -
764
- * xfact -
765
- * xlamo -
766
- * xli -
767
- * xni
768
- *
769
- * locals :
770
- * ainv2 -
771
- * aonv -
772
- * cosisq -
773
- * eoc -
774
- * f220, f221, f311, f321, f322, f330, f441, f442, f522, f523, f542, f543 -
775
- * g200, g201, g211, g300, g310, g322, g410, g422, g520, g521, g532, g533 -
776
- * sini2 -
777
- * temp -
778
- * temp1 -
779
- * theta -
780
- * xno2 -
781
- *
782
- * coupling :
783
- * getgravconst
784
- *
785
- * references :
786
- * hoots, roehrich, norad spacetrack report #3 1980
787
- * hoots, norad spacetrack report #6 1986
788
- * hoots, schumacher and glover 2004
789
- * vallado, crawford, hujsak, kelso 2006
790
- ----------------------------------------------------------------------------*/
791
-
792
-
793
- Sgp4.dsinit = function (options) {
794
- var // sgp4fix just send in xke as a constant and eliminate getgravconst call
795
- // gravconsttype whichconst,
796
- xke = options.xke,
797
- cosim = options.cosim,
798
- argpo = options.argpo,
799
- s1 = options.s1,
800
- s2 = options.s2,
801
- s3 = options.s3,
802
- s4 = options.s4,
803
- s5 = options.s5,
804
- sinim = options.sinim,
805
- ss1 = options.ss1,
806
- ss2 = options.ss2,
807
- ss3 = options.ss3,
808
- ss4 = options.ss4,
809
- ss5 = options.ss5,
810
- sz1 = options.sz1,
811
- sz3 = options.sz3,
812
- sz11 = options.sz11,
813
- sz13 = options.sz13,
814
- sz21 = options.sz21,
815
- sz23 = options.sz23,
816
- sz31 = options.sz31,
817
- sz33 = options.sz33,
818
- t = options.t,
819
- tc = options.tc,
820
- gsto = options.gsto,
821
- mo = options.mo,
822
- mdot = options.mdot,
823
- no = options.no,
824
- nodeo = options.nodeo,
825
- nodedot = options.nodedot,
826
- xPIdot = options.xPIdot,
827
- z1 = options.z1,
828
- z3 = options.z3,
829
- z11 = options.z11,
830
- z13 = options.z13,
831
- z21 = options.z21,
832
- z23 = options.z23,
833
- z31 = options.z31,
834
- z33 = options.z33,
835
- ecco = options.ecco,
836
- eccsq = options.eccsq;
837
- var emsq = options.emsq,
838
- em = options.em,
839
- argpm = options.argpm,
840
- inclm = options.inclm,
841
- mm = options.mm,
842
- nm = options.nm,
843
- nodem = options.nodem,
844
- irez = options.irez,
845
- atime = options.atime,
846
- d2201 = options.d2201,
847
- d2211 = options.d2211,
848
- d3210 = options.d3210,
849
- d3222 = options.d3222,
850
- d4410 = options.d4410,
851
- d4422 = options.d4422,
852
- d5220 = options.d5220,
853
- d5232 = options.d5232,
854
- d5421 = options.d5421,
855
- d5433 = options.d5433,
856
- dedt = options.dedt,
857
- didt = options.didt,
858
- dmdt = options.dmdt,
859
- dnodt = options.dnodt,
860
- domdt = options.domdt,
861
- del1 = options.del1,
862
- del2 = options.del2,
863
- del3 = options.del3,
864
- xfact = options.xfact,
865
- xlamo = options.xlamo,
866
- xli = options.xli,
867
- xni = options.xni;
868
- /* --------------------- local variables ------------------------ */
869
-
870
- /** Ootk -- these are declared at the top instead */
871
- // q22 = 1.7891679e-6;
872
- // q31 = 2.1460748e-6;
873
- // q33 = 2.2123015e-7;
874
- // root22 = 1.7891679e-6;
875
- // root44 = 7.3636953e-9;
876
- // root54 = 2.1765803e-9;
877
- // rptim = 4.37526908801129966e-3; // equates to 7.29211514668855e-5 rad/sec
878
- // root32 = 3.7393792e-7;
879
- // root52 = 1.1428639e-7;
880
- // x2o3 = 2.0 / 3.0;
881
- // znl = 1.5835218e-4;
882
- // zns = 1.19459e-5;
883
- // sgp4fix identify constants and allow alternate values
884
- // just xke is used here so pass it in rather than have multiple calls
885
- // getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 );
886
- // -------------------- deep space initialization ------------
887
-
888
- irez = 0;
889
-
890
- if (nm < 0.0052359877 && nm > 0.0034906585) {
891
- irez = 1;
892
- }
893
-
894
- if (nm >= 8.26e-3 && nm <= 9.24e-3 && em >= 0.5) {
895
- irez = 2;
896
- } // ------------------------ do solar terms -------------------
897
-
898
-
899
- ses = ss1 * zns * ss5;
900
- sis = ss2 * zns * (sz11 + sz13);
901
- sls = -zns * ss3 * (sz1 + sz3 - 14.0 - 6.0 * emsq);
902
- sghs = ss4 * zns * (sz31 + sz33 - 6.0);
903
- var shs = -zns * ss2 * (sz21 + sz23); // sgp4fix for 180 deg incl
904
-
905
- if (inclm < 5.2359877e-2 || inclm > PI - 5.2359877e-2) {
906
- shs = 0.0;
907
- }
908
-
909
- if (sinim !== 0.0) {
910
- shs /= sinim;
911
- }
912
-
913
- sgs = sghs - cosim * shs; // ------------------------- do lunar terms ------------------
914
-
915
- dedt = ses + s1 * znl * s5;
916
- didt = sis + s2 * znl * (z11 + z13);
917
- dmdt = sls - znl * s3 * (z1 + z3 - 14.0 - 6.0 * emsq);
918
- sghl = s4 * znl * (z31 + z33 - 6.0);
919
- var shll = -znl * s2 * (z21 + z23); // sgp4fix for 180 deg incl
920
-
921
- if (inclm < 5.2359877e-2 || inclm > PI - 5.2359877e-2) {
922
- shll = 0.0;
923
- }
924
-
925
- domdt = sgs + sghl;
926
- dnodt = shs;
927
-
928
- if (sinim !== 0.0) {
929
- domdt -= cosim / sinim * shll;
930
- dnodt += shll / sinim;
931
- } // ----------- calculate deep space resonance effects --------
932
-
933
-
934
- dndt = 0.0;
935
- theta = (gsto + tc * rptim) % TAU;
936
- em += dedt * t;
937
- inclm += didt * t;
938
- argpm += domdt * t;
939
- nodem += dnodt * t;
940
- mm += dmdt * t; // sgp4fix for negative inclinations
941
- // the following if statement should be commented out
942
- // if (inclm < 0.0)
943
- // {
944
- // inclm = -inclm;
945
- // argpm = argpm - PI;
946
- // nodem = nodem + PI;
947
- // }
948
- // -------------- initialize the resonance terms -------------
949
-
950
- if (irez !== 0) {
951
- aonv = Math.pow(nm / xke, x2o3); // ---------- geopotential resonance for 12 hour orbits ------
952
-
953
- if (irez === 2) {
954
- cosisq = cosim * cosim;
955
- emo = em;
956
- em = ecco;
957
- emsqo = emsq;
958
- emsq = eccsq;
959
- eoc = em * emsq;
960
- g201 = -0.306 - (em - 0.64) * 0.44;
961
-
962
- if (em <= 0.65) {
963
- g211 = 3.616 - 13.247 * em + 16.29 * emsq;
964
- g310 = -19.302 + 117.39 * em - 228.419 * emsq + 156.591 * eoc;
965
- g322 = -18.9068 + 109.7927 * em - 214.6334 * emsq + 146.5816 * eoc;
966
- g410 = -41.122 + 242.694 * em - 471.094 * emsq + 313.953 * eoc;
967
- g422 = -146.407 + 841.88 * em - 1629.014 * emsq + 1083.435 * eoc;
968
- g520 = -532.114 + 3017.977 * em - 5740.032 * emsq + 3708.276 * eoc;
969
- } else {
970
- g211 = -72.099 + 331.819 * em - 508.738 * emsq + 266.724 * eoc;
971
- g310 = -346.844 + 1582.851 * em - 2415.925 * emsq + 1246.113 * eoc;
972
- g322 = -342.585 + 1554.908 * em - 2366.899 * emsq + 1215.972 * eoc;
973
- g410 = -1052.797 + 4758.686 * em - 7193.992 * emsq + 3651.957 * eoc;
974
- g422 = -3581.69 + 16178.11 * em - 24462.77 * emsq + 12422.52 * eoc;
975
-
976
- if (em > 0.715) {
977
- g520 = -5149.66 + 29936.92 * em - 54087.36 * emsq + 31324.56 * eoc;
978
- } else {
979
- g520 = 1464.74 - 4664.75 * em + 3763.64 * emsq;
980
- }
981
- }
982
-
983
- if (em < 0.7) {
984
- g533 = -919.2277 + 4988.61 * em - 9064.77 * emsq + 5542.21 * eoc;
985
- g521 = -822.71072 + 4568.6173 * em - 8491.4146 * emsq + 5337.524 * eoc;
986
- g532 = -853.666 + 4690.25 * em - 8624.77 * emsq + 5341.4 * eoc;
987
- } else {
988
- g533 = -37995.78 + 161616.52 * em - 229838.2 * emsq + 109377.94 * eoc;
989
- g521 = -51752.104 + 218913.95 * em - 309468.16 * emsq + 146349.42 * eoc;
990
- g532 = -40023.88 + 170470.89 * em - 242699.48 * emsq + 115605.82 * eoc;
991
- }
992
-
993
- sini2 = sinim * sinim;
994
- f220 = 0.75 * (1.0 + 2.0 * cosim + cosisq);
995
- f221 = 1.5 * sini2;
996
- f321 = 1.875 * sinim * (1.0 - 2.0 * cosim - 3.0 * cosisq);
997
- f322 = -1.875 * sinim * (1.0 + 2.0 * cosim - 3.0 * cosisq);
998
- f441 = 35.0 * sini2 * f220;
999
- f442 = 39.375 * sini2 * sini2;
1000
- f522 = 9.84375 * sinim * (sini2 * (1.0 - 2.0 * cosim - 5.0 * cosisq) + 0.33333333 * (-2.0 + 4.0 * cosim + 6.0 * cosisq));
1001
- f523 = sinim * (4.92187512 * sini2 * (-2.0 - 4.0 * cosim + 10.0 * cosisq) + 6.56250012 * (1.0 + 2.0 * cosim - 3.0 * cosisq));
1002
- f542 = 29.53125 * sinim * (2.0 - 8.0 * cosim + cosisq * (-12.0 + 8.0 * cosim + 10.0 * cosisq));
1003
- f543 = 29.53125 * sinim * (-2.0 - 8.0 * cosim + cosisq * (12.0 + 8.0 * cosim - 10.0 * cosisq));
1004
- xno2 = nm * nm;
1005
- ainv2 = aonv * aonv;
1006
- temp1 = 3.0 * xno2 * ainv2;
1007
- temp = temp1 * root22;
1008
- d2201 = temp * f220 * g201;
1009
- d2211 = temp * f221 * g211;
1010
- temp1 *= aonv;
1011
- temp = temp1 * root32;
1012
- d3210 = temp * f321 * g310;
1013
- d3222 = temp * f322 * g322;
1014
- temp1 *= aonv;
1015
- temp = 2.0 * temp1 * root44;
1016
- d4410 = temp * f441 * g410;
1017
- d4422 = temp * f442 * g422;
1018
- temp1 *= aonv;
1019
- temp = temp1 * root52;
1020
- d5220 = temp * f522 * g520;
1021
- d5232 = temp * f523 * g532;
1022
- temp = 2.0 * temp1 * root54;
1023
- d5421 = temp * f542 * g521;
1024
- d5433 = temp * f543 * g533;
1025
- xlamo = (mo + nodeo + nodeo - (theta + theta)) % TAU;
1026
- xfact = mdot + dmdt + 2.0 * (nodedot + dnodt - rptim) - no;
1027
- em = emo;
1028
- emsq = emsqo;
1029
- } // ---------------- synchronous resonance terms --------------
1030
-
1031
-
1032
- if (irez === 1) {
1033
- g200 = 1.0 + emsq * (-2.5 + 0.8125 * emsq);
1034
- g310 = 1.0 + 2.0 * emsq;
1035
- g300 = 1.0 + emsq * (-6.0 + 6.60937 * emsq);
1036
- f220 = 0.75 * (1.0 + cosim) * (1.0 + cosim);
1037
- f311 = 0.9375 * sinim * sinim * (1.0 + 3.0 * cosim) - 0.75 * (1.0 + cosim);
1038
- f330 = 1.0 + cosim;
1039
- f330 *= 1.875 * f330 * f330;
1040
- del1 = 3.0 * nm * nm * aonv * aonv;
1041
- del2 = 2.0 * del1 * f220 * g200 * q22;
1042
- del3 = 3.0 * del1 * f330 * g300 * q33 * aonv;
1043
- del1 = del1 * f311 * g310 * q31 * aonv;
1044
- xlamo = (mo + nodeo + argpo - theta) % TAU;
1045
- xfact = mdot + xPIdot + dmdt + domdt + dnodt - (no + rptim);
1046
- } // ------------ for sgp4, initialize the integrator ----------
1047
-
1048
-
1049
- xli = xlamo;
1050
- xni = no;
1051
- atime = 0.0;
1052
- nm = no + dndt;
1053
- }
1054
-
1055
- return {
1056
- em: em,
1057
- argpm: argpm,
1058
- inclm: inclm,
1059
- mm: mm,
1060
- nm: nm,
1061
- nodem: nodem,
1062
- irez: irez,
1063
- atime: atime,
1064
- d2201: d2201,
1065
- d2211: d2211,
1066
- d3210: d3210,
1067
- d3222: d3222,
1068
- d4410: d4410,
1069
- d4422: d4422,
1070
- d5220: d5220,
1071
- d5232: d5232,
1072
- d5421: d5421,
1073
- d5433: d5433,
1074
- dedt: dedt,
1075
- didt: didt,
1076
- dmdt: dmdt,
1077
- dndt: dndt,
1078
- dnodt: dnodt,
1079
- domdt: domdt,
1080
- del1: del1,
1081
- del2: del2,
1082
- del3: del3,
1083
- xfact: xfact,
1084
- xlamo: xlamo,
1085
- xli: xli,
1086
- xni: xni
1087
- };
1088
- }; // dsinit
1089
-
1090
- /*-----------------------------------------------------------------------------
1091
- *
1092
- * procedure dspace
1093
- *
1094
- * this procedure provides deep space contributions to mean elements for
1095
- * perturbing third body. these effects have been averaged over one
1096
- * revolution of the sun and moon. for earth resonance effects, the
1097
- * effects have been averaged over no revolutions of the satellite.
1098
- * (mean motion)
1099
- *
1100
- * author : david vallado 719-573-2600 28 jun 2005
1101
- *
1102
- * inputs :
1103
- * d2201, d2211, d3210, d3222, d4410, d4422, d5220, d5232, d5421, d5433 -
1104
- * dedt -
1105
- * del1, del2, del3 -
1106
- * didt -
1107
- * dmdt -
1108
- * dnodt -
1109
- * domdt -
1110
- * irez - flag for resonance 0-none, 1-one day, 2-half day
1111
- * argpo - argument of perigee
1112
- * argpdot - argument of perigee dot (rate)
1113
- * t - time
1114
- * tc -
1115
- * gsto - gst
1116
- * xfact -
1117
- * xlamo -
1118
- * no - mean motion
1119
- * atime -
1120
- * em - eccentricity
1121
- * ft -
1122
- * argpm - argument of perigee
1123
- * inclm - inclination
1124
- * xli -
1125
- * mm - mean anomaly
1126
- * xni - mean motion
1127
- * nodem - right ascension of ascending node
1128
- *
1129
- * outputs :
1130
- * atime -
1131
- * em - eccentricity
1132
- * argpm - argument of perigee
1133
- * inclm - inclination
1134
- * xli -
1135
- * mm - mean anomaly
1136
- * xni -
1137
- * nodem - right ascension of ascending node
1138
- * dndt -
1139
- * nm - mean motion
1140
- *
1141
- * locals :
1142
- * delt -
1143
- * ft -
1144
- * theta -
1145
- * x2li -
1146
- * x2omi -
1147
- * xl -
1148
- * xldot -
1149
- * xnddt -
1150
- * xndt -
1151
- * xomi -
1152
- *
1153
- * coupling :
1154
- * none -
1155
- *
1156
- * references :
1157
- * hoots, roehrich, norad spacetrack report #3 1980
1158
- * hoots, norad spacetrack report #6 1986
1159
- * hoots, schumacher and glover 2004
1160
- * vallado, crawford, hujsak, kelso 2006
1161
- ----------------------------------------------------------------------------*/
1162
-
1163
-
1164
- Sgp4.dspace = function (options) {
1165
- var irez = options.irez,
1166
- d2201 = options.d2201,
1167
- d2211 = options.d2211,
1168
- d3210 = options.d3210,
1169
- d3222 = options.d3222,
1170
- d4410 = options.d4410,
1171
- d4422 = options.d4422,
1172
- d5220 = options.d5220,
1173
- d5232 = options.d5232,
1174
- d5421 = options.d5421,
1175
- d5433 = options.d5433,
1176
- dedt = options.dedt,
1177
- del1 = options.del1,
1178
- del2 = options.del2,
1179
- del3 = options.del3,
1180
- didt = options.didt,
1181
- dmdt = options.dmdt,
1182
- dnodt = options.dnodt,
1183
- domdt = options.domdt,
1184
- argpo = options.argpo,
1185
- argpdot = options.argpdot,
1186
- t = options.t,
1187
- tc = options.tc,
1188
- gsto = options.gsto,
1189
- xfact = options.xfact,
1190
- xlamo = options.xlamo,
1191
- no = options.no;
1192
- var atime = options.atime,
1193
- em = options.em,
1194
- argpm = options.argpm,
1195
- inclm = options.inclm,
1196
- xli = options.xli,
1197
- mm = options.mm,
1198
- xni = options.xni,
1199
- nodem = options.nodem,
1200
- nm = options.nm;
1201
- /** Ootk -- Declared at the top of the file instead */
1202
- // fasx2 = 0.13130908;
1203
- // fasx4 = 2.8843198;
1204
- // fasx6 = 0.37448087;
1205
- // g22 = 5.7686396;
1206
- // g32 = 0.95240898;
1207
- // g44 = 1.8014998;
1208
- // g52 = 1.050833;
1209
- // g54 = 4.4108898;
1210
- // rptim = 4.37526908801129966e-3; // equates to 7.29211514668855e-5 rad/sec
1211
- // stepp = 720.0;
1212
- // stepn = -720.0;
1213
- // step2 = 259200.0;
1214
- // ----------- calculate deep space resonance effects -----------
1215
-
1216
- dndt = 0.0;
1217
- theta = (gsto + tc * rptim) % TAU;
1218
- em += dedt * t;
1219
- inclm += didt * t;
1220
- argpm += domdt * t;
1221
- nodem += dnodt * t;
1222
- mm += dmdt * t; // sgp4fix for negative inclinations
1223
- // the following if statement should be commented out
1224
- // if (inclm < 0.0)
1225
- // {
1226
- // inclm = -inclm;
1227
- // argpm = argpm - PI;
1228
- // nodem = nodem + PI;
1229
- // }
1230
-
1231
- /* - update resonances : numerical (euler-maclaurin) integration - */
1232
-
1233
- /* ------------------------- epoch restart ---------------------- */
1234
- // sgp4fix for propagator problems
1235
- // the following integration works for negative time steps and periods
1236
- // the specific changes are unknown because the original code was so convoluted
1237
- // sgp4fix take out atime = 0.0 and fix for faster operation
1238
- // ft = 0.0; /** Ootk -- This has no value */
1239
-
1240
- if (irez !== 0) {
1241
- // sgp4fix streamline check
1242
- if (atime === 0.0 || t * atime <= 0.0 || Math.abs(t) < Math.abs(atime)) {
1243
- atime = 0.0;
1244
- xni = no;
1245
- xli = xlamo;
1246
- } // sgp4fix move check outside loop
1247
-
1248
-
1249
- if (t > 0.0) {
1250
- delt = stepp;
1251
- } else {
1252
- delt = stepn;
1253
- }
1254
-
1255
- var iretn = 381; // added for do loop
1256
-
1257
- while (iretn === 381) {
1258
- // ------------------- dot terms calculated -------------
1259
- // ----------- near - synchronous resonance terms -------
1260
- if (irez !== 2) {
1261
- xndt = del1 * Math.sin(xli - fasx2) + del2 * Math.sin(2.0 * (xli - fasx4)) + del3 * Math.sin(3.0 * (xli - fasx6));
1262
- xldot = xni + xfact;
1263
- xnddt = del1 * Math.cos(xli - fasx2) + 2.0 * del2 * Math.cos(2.0 * (xli - fasx4)) + 3.0 * del3 * Math.cos(3.0 * (xli - fasx6));
1264
- xnddt *= xldot;
1265
- } else {
1266
- // --------- near - half-day resonance terms --------
1267
- xomi = argpo + argpdot * atime;
1268
- x2omi = xomi + xomi;
1269
- x2li = xli + xli;
1270
- xndt = d2201 * Math.sin(x2omi + xli - g22) + d2211 * Math.sin(xli - g22) + d3210 * Math.sin(xomi + xli - g32) + d3222 * Math.sin(-xomi + xli - g32) + d4410 * Math.sin(x2omi + x2li - g44) + d4422 * Math.sin(x2li - g44) + d5220 * Math.sin(xomi + xli - g52) + d5232 * Math.sin(-xomi + xli - g52) + d5421 * Math.sin(xomi + x2li - g54) + d5433 * Math.sin(-xomi + x2li - g54);
1271
- xldot = xni + xfact;
1272
- xnddt = d2201 * Math.cos(x2omi + xli - g22) + d2211 * Math.cos(xli - g22) + d3210 * Math.cos(xomi + xli - g32) + d3222 * Math.cos(-xomi + xli - g32) + d5220 * Math.cos(xomi + xli - g52) + d5232 * Math.cos(-xomi + xli - g52) + 2.0 * d4410 * Math.cos(x2omi + x2li - g44) + d4422 * Math.cos(x2li - g44) + d5421 * Math.cos(xomi + x2li - g54) + d5433 * Math.cos(-xomi + x2li - g54);
1273
- xnddt *= xldot;
1274
- } // ----------------------- integrator -------------------
1275
- // sgp4fix move end checks to end of routine
1276
-
1277
-
1278
- if (Math.abs(t - atime) >= stepp) {
1279
- // iret = 0; /** Ootk -- This has no value */
1280
- iretn = 381;
1281
- } else {
1282
- ft = t - atime;
1283
- iretn = 0;
1284
- }
1285
-
1286
- if (iretn === 381) {
1287
- xli += xldot * delt + xndt * step2;
1288
- xni += xndt * delt + xnddt * step2;
1289
- atime += delt;
1290
- }
1291
- } // while iretn = 381
1292
-
1293
-
1294
- nm = xni + xndt * ft + xnddt * ft * ft * 0.5;
1295
- xl = xli + xldot * ft + xndt * ft * ft * 0.5;
1296
-
1297
- if (irez !== 1) {
1298
- mm = xl - 2.0 * nodem + 2.0 * theta;
1299
- dndt = nm - no;
1300
- } else {
1301
- mm = xl - nodem - argpm + theta;
1302
- dndt = nm - no;
1303
- }
1304
-
1305
- nm = no + dndt;
1306
- }
1307
-
1308
- return {
1309
- atime: atime,
1310
- em: em,
1311
- argpm: argpm,
1312
- inclm: inclm,
1313
- xli: xli,
1314
- mm: mm,
1315
- xni: xni,
1316
- nodem: nodem,
1317
- dndt: dndt,
1318
- nm: nm
1319
- };
1320
- }; // dspace
1321
-
1322
- /*-----------------------------------------------------------------------------
1323
- *
1324
- * procedure initl
1325
- *
1326
- * this procedure initializes the sgp4 propagator. all the initialization is
1327
- * consolidated here instead of having multiple loops inside other routines.
1328
- *
1329
- * author : david vallado 719-573-2600 28 jun 2005
1330
- *
1331
- * inputs :
1332
- * satn - satellite number - not needed, placed in satrec
1333
- * xke - reciprocal of tumin
1334
- * j2 - j2 zonal harmonic
1335
- * ecco - eccentricity 0.0 - 1.0
1336
- * epoch - epoch time in days from jan 0, 1950. 0 hr
1337
- * inclo - inclination of satellite
1338
- * no - mean motion of satellite
1339
- *
1340
- * outputs :
1341
- * ainv - 1.0 / a
1342
- * ao - semi major axis
1343
- * con41 -
1344
- * con42 - 1.0 - 5.0 cos(i)
1345
- * cosio - cosine of inclination
1346
- * cosio2 - cosio squared
1347
- * eccsq - eccentricity squared
1348
- * method - flag for deep space 'd', 'n'
1349
- * omeosq - 1.0 - ecco * ecco
1350
- * posq - semi-parameter squared
1351
- * rp - radius of perigee
1352
- * rteosq - square root of (1.0 - ecco*ecco)
1353
- * sinio - sine of inclination
1354
- * gsto - gst at time of observation rad
1355
- * no - mean motion of satellite
1356
- *
1357
- * locals :
1358
- * ak -
1359
- * d1 -
1360
- * del -
1361
- * adel -
1362
- * po -
1363
- *
1364
- * coupling :
1365
- * getgravconst- no longer used
1366
- * gstime - find greenwich sidereal time from the julian date
1367
- *
1368
- * references :
1369
- * hoots, roehrich, norad spacetrack report #3 1980
1370
- * hoots, norad spacetrack report #6 1986
1371
- * hoots, schumacher and glover 2004
1372
- * vallado, crawford, hujsak, kelso 2006
1373
- ----------------------------------------------------------------------------*/
1374
-
1375
-
1376
- Sgp4.initl = function (options) {
1377
- // sgp4fix satn not needed. include in satrec in case needed later
1378
- // int satn,
1379
- // sgp4fix just pass in xke and j2
1380
- // gravconsttype whichconst,
1381
- var opsmode = options.opsmode,
1382
- ecco = options.ecco,
1383
- epoch = options.epoch,
1384
- inclo = options.inclo,
1385
- xke = options.xke,
1386
- j2 = options.j2;
1387
- var no = options.no;
1388
- /* --------------------- local variables ------------------------ */
1389
-
1390
- /** Ootk -- Declared at the top of the file */
1391
- // sgp4fix use old way of finding gst
1392
-
1393
- /** Ootk -- Declared at the top of the file */
1394
- // ----------------------- earth constants ---------------------
1395
- // sgp4fix identify constants and allow alternate values
1396
- // only xke and j2 are used here so pass them in directly
1397
- // getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 )
1398
- // ------------- calculate auxillary epoch quantities ----------
1399
-
1400
- eccsq = ecco * ecco;
1401
- omeosq = 1.0 - eccsq;
1402
- rteosq = Math.sqrt(omeosq);
1403
- cosio = Math.cos(inclo);
1404
- cosio2 = cosio * cosio; // ------------------ un-kozai the mean motion -----------------
1405
-
1406
- ak = Math.pow(xke / no, x2o3);
1407
- d1 = 0.75 * j2 * (3.0 * cosio2 - 1.0) / (rteosq * omeosq);
1408
- var delPrime = d1 / (ak * ak);
1409
- adel = ak * (1.0 - delPrime * delPrime - delPrime * (1.0 / 3.0 + 134.0 * delPrime * delPrime / 81.0));
1410
- delPrime = d1 / (adel * adel);
1411
- no = no / (1.0 + delPrime);
1412
- ao = Math.pow(xke / no, x2o3);
1413
- sinio = Math.sin(inclo);
1414
- po = ao * omeosq;
1415
- con42 = 1.0 - 5.0 * cosio2;
1416
- con41 = -con42 - cosio2 - cosio2;
1417
- ainv = 1.0 / ao;
1418
- posq = po * po;
1419
- rp = ao * (1.0 - ecco);
1420
- method = 'n'; // sgp4fix modern approach to finding sidereal time
1421
-
1422
- /** Ootk -- Continue allowing AFSPC mode for SGP4 Validation */
1423
-
1424
- if (opsmode == 'a') {
1425
- // sgp4fix use old way of finding gst
1426
- // count integer number of days from 0 jan 1970
1427
- ts70 = epoch - 7305.0;
1428
- ds70 = Math.floor(ts70 + 1.0e-8);
1429
- tfrac = ts70 - ds70; // find greenwich location at epoch
1430
-
1431
- c1 = 1.72027916940703639e-2;
1432
- thgr70 = 1.7321343856509374;
1433
- fk5r = 5.07551419432269442e-15;
1434
- c1p2p = c1 + TAU;
1435
- gsto = (thgr70 + c1 * ds70 + c1p2p * tfrac + ts70 * ts70 * fk5r) % TAU;
1436
- /* istanbul ignore next | This is no longer possible*/
1437
-
1438
- if (gsto < 0.0) {
1439
- gsto += TAU;
1440
- }
1441
- } else {
1442
- gsto = Sgp4.gstime(epoch + 2433281.5);
1443
- }
1444
-
1445
- return {
1446
- no: no,
1447
- method: method,
1448
- ainv: ainv,
1449
- ao: ao,
1450
- con41: con41,
1451
- con42: con42,
1452
- cosio: cosio,
1453
- cosio2: cosio2,
1454
- eccsq: eccsq,
1455
- omeosq: omeosq,
1456
- posq: posq,
1457
- rp: rp,
1458
- rteosq: rteosq,
1459
- sinio: sinio,
1460
- gsto: gsto
1461
- };
1462
- }; // initl
1463
-
1464
- /*-----------------------------------------------------------------------------
1465
- *
1466
- * procedure sgp4init
1467
- *
1468
- * this procedure initializes variables for sgp4.
1469
- *
1470
- * author : david vallado 719-573-2600 28 jun 2005
1471
- *
1472
- * inputs :
1473
- * opsmode - mode of operation afspc or improved 'a', 'i'
1474
- * whichconst - which set of constants to use 72, 84
1475
- * satn - satellite number
1476
- * bstar - sgp4 type drag coefficient kg/m2er
1477
- * ecco - eccentricity
1478
- * epoch - epoch time in days from jan 0, 1950. 0 hr
1479
- * argpo - argument of perigee (output if ds)
1480
- * inclo - inclination
1481
- * mo - mean anomaly (output if ds)
1482
- * no - mean motion
1483
- * nodeo - right ascension of ascending node
1484
- *
1485
- * outputs :
1486
- * rec - common values for subsequent calls
1487
- * return code - non-zero on error.
1488
- * 1 - mean elements, ecc >= 1.0 or ecc < -0.001 or a < 0.95 er
1489
- * 2 - mean motion less than 0.0
1490
- * 3 - pert elements, ecc < 0.0 or ecc > 1.0
1491
- * 4 - semi-latus rectum < 0.0
1492
- * 5 - epoch elements are sub-orbital
1493
- * 6 - satellite has decayed
1494
- *
1495
- * locals :
1496
- * cnodm , snodm , cosim , sinim , cosomm , sinomm
1497
- * cc1sq , cc2 , cc3
1498
- * coef , coef1
1499
- * cosio4 -
1500
- * day -
1501
- * dndt -
1502
- * em - eccentricity
1503
- * emsq - eccentricity squared
1504
- * eeta -
1505
- * etasq -
1506
- * gam -
1507
- * argpm - argument of perigee
1508
- * nodem -
1509
- * inclm - inclination
1510
- * mm - mean anomaly
1511
- * nm - mean motion
1512
- * perige - perigee
1513
- * PInvsq -
1514
- * psisq -
1515
- * qzms24 -
1516
- * rtemsq -
1517
- * s1, s2, s3, s4, s5, s6, s7 -
1518
- * sfour -
1519
- * ss1, ss2, ss3, ss4, ss5, ss6, ss7 -
1520
- * sz1, sz2, sz3
1521
- * sz11, sz12, sz13, sz21, sz22, sz23, sz31, sz32, sz33 -
1522
- * tc -
1523
- * temp -
1524
- * temp1, temp2, temp3 -
1525
- * tsi -
1526
- * xPIdot -
1527
- * xhdot1 -
1528
- * z1, z2, z3 -
1529
- * z11, z12, z13, z21, z22, z23, z31, z32, z33 -
1530
- *
1531
- * coupling :
1532
- * getgravconst-
1533
- * initl -
1534
- * dscom -
1535
- * dpper -
1536
- * dsinit -
1537
- * sgp4 -
1538
- *
1539
- * references :
1540
- * hoots, roehrich, norad spacetrack report #3 1980
1541
- * hoots, norad spacetrack report #6 1986
1542
- * hoots, schumacher and glover 2004
1543
- * vallado, crawford, hujsak, kelso 2006
1544
- ----------------------------------------------------------------------------*/
1545
-
1546
-
1547
- Sgp4.sgp4init = function (satrec, options) {
1548
- /* eslint-disable no-param-reassign */
1549
- var _a = options.whichconst,
1550
- whichconst = _a === void 0 ? 'wgs72' : _a,
1551
- _b = options.opsmode,
1552
- opsmode = _b === void 0 ? i : _b,
1553
- _c = options.satn,
1554
- satn = _c === void 0 ? satrec.satnum : _c,
1555
- epoch = options.epoch,
1556
- xbstar = options.xbstar,
1557
- xecco = options.xecco,
1558
- xargpo = options.xargpo,
1559
- xinclo = options.xinclo,
1560
- xndot = options.xndot,
1561
- xnddot = options.xnddot,
1562
- xmo = options.xmo,
1563
- xno = options.xno,
1564
- xnodeo = options.xnodeo;
1565
- /* --------------------- local variables ------------------------ */
1566
-
1567
- /** Ootk -- Declared at the top of the file */
1568
-
1569
- /* ------------------------ initialization --------------------- */
1570
- // sgp4fix divisor for divide by zero check on inclination
1571
- // the old check used 1.0 + Math.cos(PI-1.0e-9), but then compared it to
1572
- // 1.5 e-12, so the threshold was changed to 1.5e-12 for consistency
1573
- // temp4 = 1.5e-12;
1574
- // ----------- set all near earth variables to zero ------------
1575
-
1576
- satrec.isimp = 0;
1577
- satrec.method = 'n';
1578
- satrec.aycof = 0.0;
1579
- satrec.con41 = 0.0;
1580
- satrec.cc1 = 0.0;
1581
- satrec.cc4 = 0.0;
1582
- satrec.cc5 = 0.0;
1583
- satrec.d2 = 0.0;
1584
- satrec.d3 = 0.0;
1585
- satrec.d4 = 0.0;
1586
- satrec.delmo = 0.0;
1587
- satrec.eta = 0.0;
1588
- satrec.argpdot = 0.0;
1589
- satrec.omgcof = 0.0;
1590
- satrec.sinmao = 0.0;
1591
- satrec.t = 0.0;
1592
- satrec.t2cof = 0.0;
1593
- satrec.t3cof = 0.0;
1594
- satrec.t4cof = 0.0;
1595
- satrec.t5cof = 0.0;
1596
- satrec.x1mth2 = 0.0;
1597
- satrec.x7thm1 = 0.0;
1598
- satrec.mdot = 0.0;
1599
- satrec.nodedot = 0.0;
1600
- satrec.xlcof = 0.0;
1601
- satrec.xmcof = 0.0;
1602
- satrec.nodecf = 0.0; // ----------- set all deep space variables to zero ------------
1603
-
1604
- satrec.irez = 0;
1605
- satrec.d2201 = 0.0;
1606
- satrec.d2211 = 0.0;
1607
- satrec.d3210 = 0.0;
1608
- satrec.d3222 = 0.0;
1609
- satrec.d4410 = 0.0;
1610
- satrec.d4422 = 0.0;
1611
- satrec.d5220 = 0.0;
1612
- satrec.d5232 = 0.0;
1613
- satrec.d5421 = 0.0;
1614
- satrec.d5433 = 0.0;
1615
- satrec.dedt = 0.0;
1616
- satrec.del1 = 0.0;
1617
- satrec.del2 = 0.0;
1618
- satrec.del3 = 0.0;
1619
- satrec.didt = 0.0;
1620
- satrec.dmdt = 0.0;
1621
- satrec.dnodt = 0.0;
1622
- satrec.domdt = 0.0;
1623
- satrec.e3 = 0.0;
1624
- satrec.ee2 = 0.0;
1625
- satrec.peo = 0.0;
1626
- satrec.pgho = 0.0;
1627
- satrec.pho = 0.0;
1628
- satrec.PInco = 0.0;
1629
- satrec.plo = 0.0;
1630
- satrec.se2 = 0.0;
1631
- satrec.se3 = 0.0;
1632
- satrec.sgh2 = 0.0;
1633
- satrec.sgh3 = 0.0;
1634
- satrec.sgh4 = 0.0;
1635
- satrec.sh2 = 0.0;
1636
- satrec.sh3 = 0.0;
1637
- satrec.si2 = 0.0;
1638
- satrec.si3 = 0.0;
1639
- satrec.sl2 = 0.0;
1640
- satrec.sl3 = 0.0;
1641
- satrec.sl4 = 0.0;
1642
- satrec.gsto = 0.0;
1643
- satrec.xfact = 0.0;
1644
- satrec.xgh2 = 0.0;
1645
- satrec.xgh3 = 0.0;
1646
- satrec.xgh4 = 0.0;
1647
- satrec.xh2 = 0.0;
1648
- satrec.xh3 = 0.0;
1649
- satrec.xi2 = 0.0;
1650
- satrec.xi3 = 0.0;
1651
- satrec.xl2 = 0.0;
1652
- satrec.xl3 = 0.0;
1653
- satrec.xl4 = 0.0;
1654
- satrec.xlamo = 0.0;
1655
- satrec.zmol = 0.0;
1656
- satrec.zmos = 0.0;
1657
- satrec.atime = 0.0;
1658
- satrec.xli = 0.0;
1659
- satrec.xni = 0.0;
1660
- /* ------------------------ earth constants ----------------------- */
1661
- // sgp4fix identify constants and allow alternate values
1662
- // this is now the only call for the constants
1663
-
1664
- var gravResults = Sgp4.getgravconst(whichconst);
1665
- satrec.tumin = gravResults.tumin;
1666
- satrec.mus = gravResults.mus;
1667
- satrec.radiusearthkm = gravResults.radiusearthkm;
1668
- satrec.xke = gravResults.xke;
1669
- satrec.j2 = gravResults.j2;
1670
- satrec.j3 = gravResults.j3;
1671
- satrec.j4 = gravResults.j4;
1672
- satrec.j3oj2 = gravResults.j3oj2; //-------------------------------------------------------------------------
1673
-
1674
- satrec.error = 0;
1675
- satrec.operationmode = opsmode; // new alpha5 or 9-digit number
1676
-
1677
- /** Ootk -- Using JS code for string manipulation but same effect
1678
- * Ex. A2525 = 102525
1679
- * Ex. Z1234 = 351234
1680
- */
1681
-
1682
- leadingChar = satn.split('')[0].toLowerCase(); // Using uppercase will break the -96 math.
1683
-
1684
- if (isNaN(leadingChar)) {
1685
- satrec.satnum = parseInt(leadingChar.charCodeAt(0) - 96 + 9 + satrec.satnum.slice(1, 5)).toString();
1686
- } else {
1687
- satrec.satnum = satn;
1688
- } // sgp4fix - note the following variables are also passed directly via satrec.
1689
- // it is possible to streamline the sgp4init call by deleting the "x"
1690
- // variables, but the user would need to set the satrec.* values first. we
1691
- // include the additional assignments in case twoline2rv is not used.
1692
-
1693
-
1694
- satrec.bstar = xbstar; // sgp4fix allow additional parameters in the struct
1695
-
1696
- satrec.ndot = xndot;
1697
- satrec.nddot = xnddot;
1698
- satrec.ecco = xecco;
1699
- satrec.argpo = xargpo;
1700
- satrec.inclo = xinclo;
1701
- satrec.mo = xmo; // sgp4fix rename variables to clarify which mean motion is intended
1702
-
1703
- satrec.no = xno;
1704
- satrec.nodeo = xnodeo; // single averaged mean elements
1705
- // satrec.am = satrec.em = satrec.im = satrec.Om = satrec.mm = satrec.nm = 0.0;
1706
- // ------------------------ earth constants -----------------------
1707
- // sgp4fix identify constants and allow alternate values
1708
- // getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 );
1709
-
1710
- ss = 78.0 / satrec.radiusearthkm + 1.0; // sgp4fix use multiply for speed instead of pow
1711
-
1712
- qzms2ttemp = (120.0 - 78.0) / satrec.radiusearthkm;
1713
- qzms2t = qzms2ttemp * qzms2ttemp * qzms2ttemp * qzms2ttemp;
1714
- satrec.init = 'y';
1715
- satrec.t = 0.0; // sgp4fix remove satn as it is not needed in initl
1716
-
1717
- initlOptions = {
1718
- ecco: satrec.ecco,
1719
- epoch: epoch,
1720
- inclo: satrec.inclo,
1721
- no: satrec.no,
1722
- method: satrec.method,
1723
- opsmode: satrec.operationmode,
1724
- xke: satrec.xke,
1725
- j2: satrec.j2
1726
- };
1727
- initlResult = Sgp4.initl(initlOptions);
1728
- var ao = initlResult.ao,
1729
- con42 = initlResult.con42,
1730
- cosio = initlResult.cosio,
1731
- cosio2 = initlResult.cosio2,
1732
- eccsq = initlResult.eccsq,
1733
- omeosq = initlResult.omeosq,
1734
- posq = initlResult.posq,
1735
- rp = initlResult.rp,
1736
- rteosq = initlResult.rteosq,
1737
- sinio = initlResult.sinio;
1738
- satrec.no = initlResult.no;
1739
- satrec.con41 = initlResult.con41;
1740
- satrec.gsto = initlResult.gsto;
1741
- satrec.a = Math.pow(satrec.no * satrec.tumin, -2.0 / 3.0);
1742
- satrec.alta = satrec.a * (1.0 + satrec.ecco) - 1.0;
1743
- satrec.altp = satrec.a * (1.0 - satrec.ecco) - 1.0;
1744
- satrec.error = 0; // sgp4fix remove this check as it is unnecessary
1745
- // the mrt check in sgp4 handles decaying satellite cases even if the starting
1746
- // condition is below the surface of te earth
1747
- // if (rp < 1.0)
1748
- // {
1749
- // printf("// *** satn%d epoch elts sub-orbital ***\n", satn);
1750
- // satrec.error = 5;
1751
- // }
1752
-
1753
- if (omeosq >= 0.0 || satrec.no >= 0.0) {
1754
- satrec.isimp = 0;
1755
-
1756
- if (rp < 220.0 / satrec.radiusearthkm + 1.0) {
1757
- satrec.isimp = 1;
1758
- }
1759
-
1760
- sfour = ss;
1761
- qzms24 = qzms2t;
1762
- perige = (rp - 1.0) * satrec.radiusearthkm; // - for perigees below 156 km, s and qoms2t are altered -
1763
-
1764
- if (perige < 156.0) {
1765
- sfour = perige - 78.0;
1766
-
1767
- if (perige < 98.0) {
1768
- sfour = 20.0;
1769
- } // sgp4fix use multiply for speed instead of pow
1770
-
1771
-
1772
- qzms24temp = (120.0 - sfour) / satrec.radiusearthkm;
1773
- qzms24 = qzms24temp * qzms24temp * qzms24temp * qzms24temp;
1774
- sfour = sfour / satrec.radiusearthkm + 1.0;
1775
- }
1776
-
1777
- PInvsq = 1.0 / posq;
1778
- tsi = 1.0 / (ao - sfour);
1779
- satrec.eta = ao * satrec.ecco * tsi;
1780
- etasq = satrec.eta * satrec.eta;
1781
- eeta = satrec.ecco * satrec.eta;
1782
- psisq = Math.abs(1.0 - etasq);
1783
- coef = qzms24 * Math.pow(tsi, 4.0);
1784
- coef1 = coef / Math.pow(psisq, 3.5);
1785
- cc2 = coef1 * satrec.no * (ao * (1.0 + 1.5 * etasq + eeta * (4.0 + etasq)) + 0.375 * j2 * tsi / psisq * satrec.con41 * (8.0 + 3.0 * etasq * (8.0 + etasq)));
1786
- satrec.cc1 = satrec.bstar * cc2;
1787
- cc3 = 0.0;
1788
-
1789
- if (satrec.ecco > 1.0e-4) {
1790
- cc3 = -2.0 * coef * tsi * j3oj2 * satrec.no * sinio / satrec.ecco;
1791
- }
1792
-
1793
- satrec.x1mth2 = 1.0 - cosio2;
1794
- satrec.cc4 = 2.0 * satrec.no * coef1 * ao * omeosq * (satrec.eta * (2.0 + 0.5 * etasq) + satrec.ecco * (0.5 + 2.0 * etasq) - j2 * tsi / (ao * psisq) * (-3.0 * satrec.con41 * (1.0 - 2.0 * eeta + etasq * (1.5 - 0.5 * eeta)) + 0.75 * satrec.x1mth2 * (2.0 * etasq - eeta * (1.0 + etasq)) * Math.cos(2.0 * satrec.argpo)));
1795
- satrec.cc5 = 2.0 * coef1 * ao * omeosq * (1.0 + 2.75 * (etasq + eeta) + eeta * etasq);
1796
- cosio4 = cosio2 * cosio2;
1797
- temp1 = 1.5 * j2 * PInvsq * satrec.no;
1798
- temp2 = 0.5 * temp1 * j2 * PInvsq;
1799
- temp3 = -0.46875 * j4 * PInvsq * PInvsq * satrec.no;
1800
- satrec.mdot = satrec.no + 0.5 * temp1 * rteosq * satrec.con41 + 0.0625 * temp2 * rteosq * (13.0 - 78.0 * cosio2 + 137.0 * cosio4);
1801
- satrec.argpdot = -0.5 * temp1 * con42 + 0.0625 * temp2 * (7.0 - 114.0 * cosio2 + 395.0 * cosio4) + temp3 * (3.0 - 36.0 * cosio2 + 49.0 * cosio4);
1802
- xhdot1 = -temp1 * cosio;
1803
- satrec.nodedot = xhdot1 + (0.5 * temp2 * (4.0 - 19.0 * cosio2) + 2.0 * temp3 * (3.0 - 7.0 * cosio2)) * cosio;
1804
- xPIdot = satrec.argpdot + satrec.nodedot;
1805
- satrec.omgcof = satrec.bstar * cc3 * Math.cos(satrec.argpo);
1806
- satrec.xmcof = 0.0;
1807
-
1808
- if (satrec.ecco > 1.0e-4) {
1809
- satrec.xmcof = -x2o3 * coef * satrec.bstar / eeta;
1810
- }
1811
-
1812
- satrec.nodecf = 3.5 * omeosq * xhdot1 * satrec.cc1;
1813
- satrec.t2cof = 1.5 * satrec.cc1; // sgp4fix for divide by zero with xinco = 180 deg
1814
-
1815
- if (Math.abs(cosio + 1.0) > 1.5e-12) {
1816
- satrec.xlcof = -0.25 * j3oj2 * sinio * (3.0 + 5.0 * cosio) / (1.0 + cosio);
1817
- } else {
1818
- satrec.xlcof = -0.25 * j3oj2 * sinio * (3.0 + 5.0 * cosio) / temp4;
1819
- }
1820
-
1821
- satrec.aycof = -0.5 * j3oj2 * sinio; // sgp4fix use multiply for speed instead of pow
1822
-
1823
- delmotemp = 1.0 + satrec.eta * Math.cos(satrec.mo);
1824
- satrec.delmo = delmotemp * delmotemp * delmotemp;
1825
- satrec.sinmao = Math.sin(satrec.mo);
1826
- satrec.x7thm1 = 7.0 * cosio2 - 1.0; // --------------- deep space initialization -------------
1827
-
1828
- if (TAU / satrec.no >= 225.0) {
1829
- satrec.method = 'd';
1830
- satrec.isimp = 1;
1831
- tc = 0.0;
1832
- inclm = satrec.inclo;
1833
- dscomOptions = {
1834
- epoch: epoch,
1835
- ep: satrec.ecco,
1836
- argpp: satrec.argpo,
1837
- tc: tc,
1838
- inclp: satrec.inclo,
1839
- nodep: satrec.nodeo,
1840
- np: satrec.no,
1841
- e3: satrec.e3,
1842
- ee2: satrec.ee2,
1843
- peo: satrec.peo,
1844
- pgho: satrec.pgho,
1845
- pho: satrec.pho,
1846
- PInco: satrec.PInco,
1847
- plo: satrec.plo,
1848
- se2: satrec.se2,
1849
- se3: satrec.se3,
1850
- sgh2: satrec.sgh2,
1851
- sgh3: satrec.sgh3,
1852
- sgh4: satrec.sgh4,
1853
- sh2: satrec.sh2,
1854
- sh3: satrec.sh3,
1855
- si2: satrec.si2,
1856
- si3: satrec.si3,
1857
- sl2: satrec.sl2,
1858
- sl3: satrec.sl3,
1859
- sl4: satrec.sl4,
1860
- xgh2: satrec.xgh2,
1861
- xgh3: satrec.xgh3,
1862
- xgh4: satrec.xgh4,
1863
- xh2: satrec.xh2,
1864
- xh3: satrec.xh3,
1865
- xi2: satrec.xi2,
1866
- xi3: satrec.xi3,
1867
- xl2: satrec.xl2,
1868
- xl3: satrec.xl3,
1869
- xl4: satrec.xl4,
1870
- zmol: satrec.zmol,
1871
- zmos: satrec.zmos
1872
- };
1873
- dscomResult = Sgp4.dscom(dscomOptions);
1874
- satrec.e3 = dscomResult.e3;
1875
- satrec.ee2 = dscomResult.ee2;
1876
- satrec.peo = dscomResult.peo;
1877
- satrec.pgho = dscomResult.pgho;
1878
- satrec.pho = dscomResult.pho;
1879
- satrec.PInco = dscomResult.PInco;
1880
- satrec.plo = dscomResult.plo;
1881
- satrec.se2 = dscomResult.se2;
1882
- satrec.se3 = dscomResult.se3;
1883
- satrec.sgh2 = dscomResult.sgh2;
1884
- satrec.sgh3 = dscomResult.sgh3;
1885
- satrec.sgh4 = dscomResult.sgh4;
1886
- satrec.sh2 = dscomResult.sh2;
1887
- satrec.sh3 = dscomResult.sh3;
1888
- satrec.si2 = dscomResult.si2;
1889
- satrec.si3 = dscomResult.si3;
1890
- satrec.sl2 = dscomResult.sl2;
1891
- satrec.sl3 = dscomResult.sl3;
1892
- satrec.sl4 = dscomResult.sl4;
1893
- var sinim_1 = dscomResult.sinim,
1894
- cosim_1 = dscomResult.cosim,
1895
- em_1 = dscomResult.em,
1896
- emsq_1 = dscomResult.emsq,
1897
- s1_1 = dscomResult.s1,
1898
- s2_1 = dscomResult.s2,
1899
- s3_1 = dscomResult.s3,
1900
- s4_1 = dscomResult.s4,
1901
- s5_1 = dscomResult.s5,
1902
- ss1_1 = dscomResult.ss1,
1903
- ss2_1 = dscomResult.ss2,
1904
- ss3_1 = dscomResult.ss3,
1905
- ss4_1 = dscomResult.ss4,
1906
- ss5_1 = dscomResult.ss5,
1907
- sz1_1 = dscomResult.sz1,
1908
- sz3_1 = dscomResult.sz3,
1909
- sz11_1 = dscomResult.sz11,
1910
- sz13_1 = dscomResult.sz13,
1911
- sz21_1 = dscomResult.sz21,
1912
- sz23_1 = dscomResult.sz23,
1913
- sz31_1 = dscomResult.sz31,
1914
- sz33_1 = dscomResult.sz33;
1915
- satrec.xgh2 = dscomResult.xgh2;
1916
- satrec.xgh3 = dscomResult.xgh3;
1917
- satrec.xgh4 = dscomResult.xgh4;
1918
- satrec.xh2 = dscomResult.xh2;
1919
- satrec.xh3 = dscomResult.xh3;
1920
- satrec.xi2 = dscomResult.xi2;
1921
- satrec.xi3 = dscomResult.xi3;
1922
- satrec.xl2 = dscomResult.xl2;
1923
- satrec.xl3 = dscomResult.xl3;
1924
- satrec.xl4 = dscomResult.xl4;
1925
- satrec.zmol = dscomResult.zmol;
1926
- satrec.zmos = dscomResult.zmos;
1927
- nm = dscomResult.nm, z1 = dscomResult.z1, z3 = dscomResult.z3, z11 = dscomResult.z11, z13 = dscomResult.z13, z21 = dscomResult.z21, z23 = dscomResult.z23, z31 = dscomResult.z31, z33 = dscomResult.z33;
1928
- dpperOptions = {
1929
- inclo: inclm,
1930
- init: satrec.init,
1931
- ep: satrec.ecco,
1932
- inclp: satrec.inclo,
1933
- nodep: satrec.nodeo,
1934
- argpp: satrec.argpo,
1935
- mp: satrec.mo,
1936
- opsmode: satrec.operationmode
1937
- };
1938
- dpperResult = Sgp4.dpper(satrec, dpperOptions);
1939
- satrec.ecco = dpperResult.ep;
1940
- satrec.inclo = dpperResult.inclp;
1941
- satrec.nodeo = dpperResult.nodep;
1942
- satrec.argpo = dpperResult.argpp;
1943
- satrec.mo = dpperResult.mp;
1944
- argpm = 0.0;
1945
- nodem = 0.0;
1946
- mm = 0.0;
1947
- dsinitOptions = {
1948
- xke: xke,
1949
- cosim: cosim_1,
1950
- emsq: emsq_1,
1951
- argpo: satrec.argpo,
1952
- s1: s1_1,
1953
- s2: s2_1,
1954
- s3: s3_1,
1955
- s4: s4_1,
1956
- s5: s5_1,
1957
- sinim: sinim_1,
1958
- ss1: ss1_1,
1959
- ss2: ss2_1,
1960
- ss3: ss3_1,
1961
- ss4: ss4_1,
1962
- ss5: ss5_1,
1963
- sz1: sz1_1,
1964
- sz3: sz3_1,
1965
- sz11: sz11_1,
1966
- sz13: sz13_1,
1967
- sz21: sz21_1,
1968
- sz23: sz23_1,
1969
- sz31: sz31_1,
1970
- sz33: sz33_1,
1971
- t: satrec.t,
1972
- tc: tc,
1973
- gsto: satrec.gsto,
1974
- mo: satrec.mo,
1975
- mdot: satrec.mdot,
1976
- no: satrec.no,
1977
- nodeo: satrec.nodeo,
1978
- nodedot: satrec.nodedot,
1979
- xPIdot: xPIdot,
1980
- z1: z1,
1981
- z3: z3,
1982
- z11: z11,
1983
- z13: z13,
1984
- z21: z21,
1985
- z23: z23,
1986
- z31: z31,
1987
- z33: z33,
1988
- ecco: satrec.ecco,
1989
- eccsq: eccsq,
1990
- em: em_1,
1991
- argpm: argpm,
1992
- inclm: inclm,
1993
- mm: mm,
1994
- nm: nm,
1995
- nodem: nodem,
1996
- irez: satrec.irez,
1997
- atime: satrec.atime,
1998
- d2201: satrec.d2201,
1999
- d2211: satrec.d2211,
2000
- d3210: satrec.d3210,
2001
- d3222: satrec.d3222,
2002
- d4410: satrec.d4410,
2003
- d4422: satrec.d4422,
2004
- d5220: satrec.d5220,
2005
- d5232: satrec.d5232,
2006
- d5421: satrec.d5421,
2007
- d5433: satrec.d5433,
2008
- dedt: satrec.dedt,
2009
- didt: satrec.didt,
2010
- dmdt: satrec.dmdt,
2011
- dnodt: satrec.dnodt,
2012
- domdt: satrec.domdt,
2013
- del1: satrec.del1,
2014
- del2: satrec.del2,
2015
- del3: satrec.del3,
2016
- xfact: satrec.xfact,
2017
- xlamo: satrec.xlamo,
2018
- xli: satrec.xli,
2019
- xni: satrec.xni
2020
- };
2021
- dsinitResult = Sgp4.dsinit(dsinitOptions);
2022
- satrec.irez = dsinitResult.irez;
2023
- satrec.atime = dsinitResult.atime;
2024
- satrec.d2201 = dsinitResult.d2201;
2025
- satrec.d2211 = dsinitResult.d2211;
2026
- satrec.d3210 = dsinitResult.d3210;
2027
- satrec.d3222 = dsinitResult.d3222;
2028
- satrec.d4410 = dsinitResult.d4410;
2029
- satrec.d4422 = dsinitResult.d4422;
2030
- satrec.d5220 = dsinitResult.d5220;
2031
- satrec.d5232 = dsinitResult.d5232;
2032
- satrec.d5421 = dsinitResult.d5421;
2033
- satrec.d5433 = dsinitResult.d5433;
2034
- satrec.dedt = dsinitResult.dedt;
2035
- satrec.didt = dsinitResult.didt;
2036
- satrec.dmdt = dsinitResult.dmdt;
2037
- satrec.dnodt = dsinitResult.dnodt;
2038
- satrec.domdt = dsinitResult.domdt;
2039
- satrec.del1 = dsinitResult.del1;
2040
- satrec.del2 = dsinitResult.del2;
2041
- satrec.del3 = dsinitResult.del3;
2042
- satrec.xfact = dsinitResult.xfact;
2043
- satrec.xlamo = dsinitResult.xlamo;
2044
- satrec.xli = dsinitResult.xli;
2045
- satrec.xni = dsinitResult.xni;
2046
- } // ----------- set variables if not deep space -----------
2047
-
2048
-
2049
- if (satrec.isimp !== 1) {
2050
- cc1sq = satrec.cc1 * satrec.cc1;
2051
- satrec.d2 = 4.0 * ao * tsi * cc1sq;
2052
- temp = satrec.d2 * tsi * satrec.cc1 / 3.0;
2053
- satrec.d3 = (17.0 * ao + sfour) * temp;
2054
- satrec.d4 = 0.5 * temp * ao * tsi * (221.0 * ao + 31.0 * sfour) * satrec.cc1;
2055
- satrec.t3cof = satrec.d2 + 2.0 * cc1sq;
2056
- satrec.t4cof = 0.25 * (3.0 * satrec.d3 + satrec.cc1 * (12.0 * satrec.d2 + 10.0 * cc1sq));
2057
- satrec.t5cof = 0.2 * (3.0 * satrec.d4 + 12.0 * satrec.cc1 * satrec.d3 + 6.0 * satrec.d2 * satrec.d2 + 15.0 * cc1sq * (2.0 * satrec.d2 + cc1sq));
2058
- } // if omeosq = 0 ...
2059
-
2060
- /* finally propogate to zero epoch to initialize all others. */
2061
- // sgp4fix take out check to let satellites process until they are actually below earth surface
2062
- // if(satrec.error == 0)
2063
-
2064
- }
2065
-
2066
- Sgp4.propagate(satrec, 0);
2067
- satrec.init = 'n'; //sgp4fix return boolean. satrec.error contains any error codes
2068
- // return satrec; -- no reason to return anything in JS
2069
- }; // sgp4init
2070
-
2071
- /*----------------------------------------------------------------------------
2072
- *
2073
- * procedure sgp4
2074
- *
2075
- * this procedure is the sgp4 prediction model from space command. this is an
2076
- * updated and combined version of sgp4 and sdp4, which were originally
2077
- * published separately in spacetrack report //3. this version follows the
2078
- * methodology from the aiaa paper (2006) describing the history and
2079
- * development of the code.
2080
- *
2081
- * author : david vallado 719-573-2600 28 jun 2005
2082
- *
2083
- * inputs :
2084
- * satrec - initialised structure from sgp4init() call.
2085
- * tsince - time since epoch (minutes)
2086
- *
2087
- * outputs :
2088
- * r - position vector km
2089
- * v - velocity km/sec
2090
- * return code - non-zero on error.
2091
- * 1 - mean elements, ecc >= 1.0 or ecc < -0.001 or a < 0.95 er
2092
- * 2 - mean motion less than 0.0
2093
- * 3 - pert elements, ecc < 0.0 or ecc > 1.0
2094
- * 4 - semi-latus rectum < 0.0
2095
- * 5 - epoch elements are sub-orbital
2096
- * 6 - satellite has decayed
2097
- *
2098
- * locals :
2099
- * am -
2100
- * axnl, aynl -
2101
- * betal -
2102
- * cosim , sinim , cosomm , sinomm , cnod , snod , cos2u ,
2103
- * sin2u , coseo1 , sineo1 , cosi , sini , cosip , sinip ,
2104
- * cosisq , cossu , sinsu , cosu , sinu
2105
- * delm -
2106
- * delomg -
2107
- * dndt -
2108
- * eccm -
2109
- * emsq -
2110
- * ecose -
2111
- * el2 -
2112
- * eo1 -
2113
- * eccp -
2114
- * esine -
2115
- * argpm -
2116
- * argpp -
2117
- * omgadf -
2118
- * pl -
2119
- * r -
2120
- * rtemsq -
2121
- * rdotl -
2122
- * rl -
2123
- * rvdot -
2124
- * rvdotl -
2125
- * su -
2126
- * t2 , t3 , t4 , tc
2127
- * tem5, temp , temp1 , temp2 , tempa , tempe , templ
2128
- * u , ux , uy , uz , vx , vy , vz
2129
- * inclm - inclination
2130
- * mm - mean anomaly
2131
- * nm - mean motion
2132
- * nodem - right asc of ascending node
2133
- * xinc -
2134
- * xincp -
2135
- * xl -
2136
- * xlm -
2137
- * mp -
2138
- * xmdf -
2139
- * xmx -
2140
- * xmy -
2141
- * nodedf -
2142
- * xnode -
2143
- * nodep -
2144
- * np -
2145
- *
2146
- * coupling :
2147
- * getgravconst-
2148
- * dpper
2149
- * dspace
2150
- *
2151
- * references :
2152
- * hoots, roehrich, norad spacetrack report //3 1980
2153
- * hoots, norad spacetrack report //6 1986
2154
- * hoots, schumacher and glover 2004
2155
- * vallado, crawford, hujsak, kelso 2006
2156
- ----------------------------------------------------------------------------*/
2157
-
2158
-
2159
- Sgp4.propagate = function (satrec, tsince) {
2160
- /* ------------------ set mathematical constants --------------- */
2161
- // sgp4fix divisor for divide by zero check on inclination
2162
- // the old check used 1.0 + cos(PI-1.0e-9), but then compared it to
2163
- // 1.5 e-12, so the threshold was changed to 1.5e-12 for consistency
2164
-
2165
- /** Ootk -- Declared at the top of the page */
2166
- // temp4 = 1.5e-12;
2167
- // sgp4fix identify constants and allow alternate values
2168
- // getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 );
2169
- vkmpersec = satrec.radiusearthkm * satrec.xke / 60.0; // --------------------- clear sgp4 error flag -----------------
2170
-
2171
- satrec.t = tsince;
2172
- satrec.error = 0; // ------- update for secular gravity and atmospheric drag -----
2173
-
2174
- xmdf = satrec.mo + satrec.mdot * satrec.t;
2175
- argpdf = satrec.argpo + satrec.argpdot * satrec.t;
2176
- nodedf = satrec.nodeo + satrec.nodedot * satrec.t;
2177
- argpm = argpdf;
2178
- mm = xmdf;
2179
- t2 = satrec.t * satrec.t;
2180
- nodem = nodedf + satrec.nodecf * t2;
2181
- tempa = 1.0 - satrec.cc1 * satrec.t;
2182
- tempe = satrec.bstar * satrec.cc4 * satrec.t;
2183
- templ = satrec.t2cof * t2;
2184
-
2185
- if (satrec.isimp !== 1) {
2186
- delomg = satrec.omgcof * satrec.t; // sgp4fix use mutliply for speed instead of pow
2187
-
2188
- delmtemp = 1.0 + satrec.eta * Math.cos(xmdf);
2189
- delm = satrec.xmcof * (delmtemp * delmtemp * delmtemp - satrec.delmo);
2190
- temp = delomg + delm;
2191
- mm = xmdf + temp;
2192
- argpm = argpdf - temp;
2193
- t3 = t2 * satrec.t;
2194
- t4 = t3 * satrec.t;
2195
- tempa = tempa - satrec.d2 * t2 - satrec.d3 * t3 - satrec.d4 * t4;
2196
- tempe += satrec.bstar * satrec.cc5 * (Math.sin(mm) - satrec.sinmao);
2197
- templ = templ + satrec.t3cof * t3 + t4 * (satrec.t4cof + satrec.t * satrec.t5cof);
2198
- }
2199
-
2200
- nm = satrec.no;
2201
- em = satrec.ecco;
2202
- inclm = satrec.inclo;
2203
-
2204
- if (satrec.method === 'd') {
2205
- tc = satrec.t;
2206
- dspaceOptions = {
2207
- irez: satrec.irez,
2208
- d2201: satrec.d2201,
2209
- d2211: satrec.d2211,
2210
- d3210: satrec.d3210,
2211
- d3222: satrec.d3222,
2212
- d4410: satrec.d4410,
2213
- d4422: satrec.d4422,
2214
- d5220: satrec.d5220,
2215
- d5232: satrec.d5232,
2216
- d5421: satrec.d5421,
2217
- d5433: satrec.d5433,
2218
- dedt: satrec.dedt,
2219
- del1: satrec.del1,
2220
- del2: satrec.del2,
2221
- del3: satrec.del3,
2222
- didt: satrec.didt,
2223
- dmdt: satrec.dmdt,
2224
- dnodt: satrec.dnodt,
2225
- domdt: satrec.domdt,
2226
- argpo: satrec.argpo,
2227
- argpdot: satrec.argpdot,
2228
- t: satrec.t,
2229
- tc: tc,
2230
- gsto: satrec.gsto,
2231
- xfact: satrec.xfact,
2232
- xlamo: satrec.xlamo,
2233
- no: satrec.no,
2234
- atime: satrec.atime,
2235
- em: em,
2236
- argpm: argpm,
2237
- inclm: inclm,
2238
- xli: satrec.xli,
2239
- mm: mm,
2240
- xni: satrec.xni,
2241
- nodem: nodem,
2242
- nm: nm
2243
- };
2244
- dspaceResult = Sgp4.dspace(dspaceOptions);
2245
- em = dspaceResult.em, argpm = dspaceResult.argpm, inclm = dspaceResult.inclm, mm = dspaceResult.mm, nodem = dspaceResult.nodem, nm = dspaceResult.nm;
2246
- } // if methjod = d
2247
-
2248
-
2249
- if (nm <= 0.0) {
2250
- // printf("// error nm %f\n", nm);
2251
- satrec.error = 2; // sgp4fix add return
2252
-
2253
- return {
2254
- position: false,
2255
- velocity: false
2256
- };
2257
- }
2258
-
2259
- am = Math.pow(xke / nm, x2o3) * tempa * tempa;
2260
- nm = xke / Math.pow(am, 1.5);
2261
- em -= tempe; // fix tolerance for error recognition
2262
- // sgp4fix am is fixed from the previous nm check
2263
-
2264
- /* istanbul ignore next | This is no longer possible*/
2265
-
2266
- if (em >= 1.0 || em < -0.001) {
2267
- // || (am < 0.95)
2268
- // printf("// error em %f\n", em);
2269
- satrec.error = 1; // sgp4fix to return if there is an error in eccentricity
2270
-
2271
- return {
2272
- position: false,
2273
- velocity: false
2274
- };
2275
- } // sgp4fix fix tolerance to avoid a divide by zero
2276
-
2277
-
2278
- if (em < 1.0e-6) {
2279
- em = 1.0e-6;
2280
- }
2281
-
2282
- mm += satrec.no * templ;
2283
- xlm = mm + argpm + nodem;
2284
- nodem %= TAU;
2285
- argpm %= TAU;
2286
- xlm %= TAU;
2287
- mm = (xlm - argpm - nodem) % TAU; // sgp4fix recover singly averaged mean elements
2288
-
2289
- satrec.am = am;
2290
- satrec.em = em;
2291
- satrec.im = inclm;
2292
- satrec.Om = nodem;
2293
- satrec.om = argpm;
2294
- satrec.mm = mm;
2295
- satrec.nm = nm; // ----------------- compute extra mean quantities -------------
2296
-
2297
- sinim = Math.sin(inclm);
2298
- cosim = Math.cos(inclm); // -------------------- add lunar-solar periodics --------------
2299
-
2300
- ep = em;
2301
- xincp = inclm;
2302
- argpp = argpm;
2303
- nodep = nodem;
2304
- mp = mm;
2305
- sinip = sinim;
2306
- cosip = cosim;
2307
-
2308
- if (satrec.method === 'd') {
2309
- dpperParameters = {
2310
- inclo: satrec.inclo,
2311
- init: 'n',
2312
- ep: ep,
2313
- inclp: xincp,
2314
- nodep: nodep,
2315
- argpp: argpp,
2316
- mp: mp,
2317
- opsmode: satrec.operationmode
2318
- };
2319
- dpperResult = Sgp4.dpper(satrec, dpperParameters);
2320
- ep = dpperResult.ep, nodep = dpperResult.nodep, argpp = dpperResult.argpp, mp = dpperResult.mp;
2321
- xincp = dpperResult.inclp;
2322
-
2323
- if (xincp < 0.0) {
2324
- xincp = -xincp;
2325
- nodep += PI;
2326
- argpp -= PI;
2327
- }
2328
-
2329
- if (ep < 0.0 || ep > 1.0) {
2330
- // printf("// error ep %f\n", ep);
2331
- satrec.error = 3; // sgp4fix add return
2332
-
2333
- return {
2334
- position: false,
2335
- velocity: false
2336
- };
2337
- }
2338
- } // -------------------- long period periodics ------------------
2339
-
2340
-
2341
- if (satrec.method === 'd') {
2342
- sinip = Math.sin(xincp);
2343
- cosip = Math.cos(xincp);
2344
- satrec.aycof = -0.5 * j3oj2 * sinip; // sgp4fix for divide by zero for xincp = 180 deg
2345
-
2346
- /* istanbul ignore next | This is no longer possible*/
2347
-
2348
- if (Math.abs(cosip + 1.0) > 1.5e-12) {
2349
- satrec.xlcof = -0.25 * j3oj2 * sinip * (3.0 + 5.0 * cosip) / (1.0 + cosip);
2350
- } else {
2351
- satrec.xlcof = -0.25 * j3oj2 * sinip * (3.0 + 5.0 * cosip) / temp4;
2352
- }
2353
- }
2354
-
2355
- axnl = ep * Math.cos(argpp);
2356
- temp = 1.0 / (am * (1.0 - ep * ep));
2357
- aynl = ep * Math.sin(argpp) + temp * satrec.aycof;
2358
- xl = mp + argpp + nodep + temp * satrec.xlcof * axnl; // --------------------- solve kepler's equation ---------------
2359
-
2360
- u = (xl - nodep) % TAU;
2361
- eo1 = u;
2362
- tem5 = 9999.9;
2363
- ktr = 1; // sgp4fix for kepler iteration
2364
- // the following iteration needs better limits on corrections
2365
-
2366
- while (Math.abs(tem5) >= 1.0e-12 && ktr <= 10) {
2367
- sineo1 = Math.sin(eo1);
2368
- coseo1 = Math.cos(eo1);
2369
- tem5 = 1.0 - coseo1 * axnl - sineo1 * aynl;
2370
- tem5 = (u - aynl * coseo1 + axnl * sineo1 - eo1) / tem5;
2371
-
2372
- if (Math.abs(tem5) >= 0.95) {
2373
- if (tem5 > 0.0) {
2374
- tem5 = 0.95;
2375
- } else {
2376
- tem5 = -0.95;
2377
- }
2378
- }
2379
-
2380
- eo1 += tem5;
2381
- ktr += 1;
2382
- } // ------------- short period preliminary quantities -----------
2383
-
2384
-
2385
- ecose = axnl * coseo1 + aynl * sineo1;
2386
- esine = axnl * sineo1 - aynl * coseo1;
2387
- el2 = axnl * axnl + aynl * aynl;
2388
- pl = am * (1.0 - el2);
2389
-
2390
- if (pl < 0.0) {
2391
- // printf("// error pl %f\n", pl);
2392
- satrec.error = 4; // sgp4fix add return
2393
-
2394
- return {
2395
- position: false,
2396
- velocity: false
2397
- };
2398
- }
2399
-
2400
- rl = am * (1.0 - ecose);
2401
- rdotl = Math.sqrt(am) * esine / rl;
2402
- rvdotl = Math.sqrt(pl) / rl;
2403
- betal = Math.sqrt(1.0 - el2);
2404
- temp = esine / (1.0 + betal);
2405
- sinu = am / rl * (sineo1 - aynl - axnl * temp);
2406
- cosu = am / rl * (coseo1 - axnl + aynl * temp);
2407
- su = Math.atan2(sinu, cosu);
2408
- sin2u = (cosu + cosu) * sinu;
2409
- cos2u = 1.0 - 2.0 * sinu * sinu;
2410
- temp = 1.0 / pl;
2411
- temp1 = 0.5 * j2 * temp;
2412
- temp2 = temp1 * temp; // -------------- update for short period periodics ------------
2413
-
2414
- if (satrec.method === 'd') {
2415
- cosisq = cosip * cosip;
2416
- satrec.con41 = 3.0 * cosisq - 1.0;
2417
- satrec.x1mth2 = 1.0 - cosisq;
2418
- satrec.x7thm1 = 7.0 * cosisq - 1.0;
2419
- }
2420
-
2421
- mrt = rl * (1.0 - 1.5 * temp2 * betal * satrec.con41) + 0.5 * temp1 * satrec.x1mth2 * cos2u;
2422
- /** Moved this up to reduce unnecessary computation if you are going to return false anyway */
2423
- // sgp4fix for decaying satellites
2424
-
2425
- if (mrt < 1.0) {
2426
- // printf("// decay condition %11.6f \n",mrt);
2427
- satrec.error = 6;
2428
- return {
2429
- position: false,
2430
- velocity: false
2431
- };
2432
- }
2433
-
2434
- su -= 0.25 * temp2 * satrec.x7thm1 * sin2u;
2435
- xnode = nodep + 1.5 * temp2 * cosip * sin2u;
2436
- xinc = xincp + 1.5 * temp2 * cosip * sinip * cos2u;
2437
- mvt = rdotl - nm * temp1 * satrec.x1mth2 * sin2u / xke;
2438
- rvdot = rvdotl + nm * temp1 * (satrec.x1mth2 * cos2u + 1.5 * satrec.con41) / xke; // --------------------- orientation vectors -------------------
2439
-
2440
- sinsu = Math.sin(su);
2441
- cossu = Math.cos(su);
2442
- snod = Math.sin(xnode);
2443
- cnod = Math.cos(xnode);
2444
- sini = Math.sin(xinc);
2445
- cosi = Math.cos(xinc);
2446
- xmx = -snod * cosi;
2447
- xmy = cnod * cosi;
2448
- ux = xmx * sinsu + cnod * cossu;
2449
- uy = xmy * sinsu + snod * cossu;
2450
- uz = sini * sinsu;
2451
- vx = xmx * cossu - cnod * sinsu;
2452
- vy = xmy * cossu - snod * sinsu;
2453
- vz = sini * cossu; // --------- position and velocity (in km and km/sec) ----------
2454
-
2455
- r = {
2456
- x: mrt * ux * satrec.radiusearthkm,
2457
- y: mrt * uy * satrec.radiusearthkm,
2458
- z: mrt * uz * satrec.radiusearthkm
2459
- };
2460
- v = {
2461
- x: (mvt * ux + rvdot * vx) * vkmpersec,
2462
- y: (mvt * uy + rvdot * vy) * vkmpersec,
2463
- z: (mvt * uz + rvdot * vz) * vkmpersec
2464
- };
2465
- return {
2466
- position: r,
2467
- velocity: v
2468
- };
2469
- };
2470
- /* -----------------------------------------------------------------------------
2471
- *
2472
- * function getgravconst
2473
- *
2474
- * this function gets constants for the propagator. note that mu is identified to
2475
- * facilitiate comparisons with newer models. the common useage is wgs72.
2476
- *
2477
- * author : david vallado 719-573-2600 21 jul 2006
2478
- *
2479
- * inputs :
2480
- * whichconst - which set of constants to use wgs72old, wgs72, wgs84
2481
- *
2482
- * outputs :
2483
- * tumin - minutes in one time unit
2484
- * mu - earth gravitational parameter
2485
- * radiusearthkm - radius of the earth in km
2486
- * xke - reciprocal of tumin
2487
- * j2, j3, j4 - un-normalized zonal harmonic values
2488
- * j3oj2 - j3 divided by j2
2489
- *
2490
- * locals :
2491
- *
2492
- * coupling :
2493
- * none
2494
- *
2495
- * references :
2496
- * norad spacetrack report #3
2497
- * vallado, crawford, hujsak, kelso 2006
2498
- --------------------------------------------------------------------------- */
2499
-
2500
-
2501
- Sgp4.getgravconst = function (whichconst) {
2502
- switch (whichconst) {
2503
- // -- wgs-72 low precision str#3 constants --
2504
- case 'wgs72old':
2505
- mus = 398600.79964; // in km3 / s2
2506
-
2507
- radiusearthkm = 6378.135; // km
2508
-
2509
- xke = 0.0743669161; // reciprocal of tumin
2510
-
2511
- tumin = 1.0 / xke;
2512
- j2 = 0.001082616;
2513
- j3 = -0.00000253881;
2514
- j4 = -0.00000165597;
2515
- j3oj2 = j3 / j2;
2516
- break;
2517
- // ------------ wgs-72 constants ------------
2518
-
2519
- case 'wgs72':
2520
- mus = 398600.8; // in km3 / s2
2521
-
2522
- radiusearthkm = 6378.135; // km
2523
-
2524
- xke = 60.0 / Math.sqrt(radiusearthkm * radiusearthkm * radiusearthkm / mus);
2525
- tumin = 1.0 / xke;
2526
- j2 = 0.001082616;
2527
- j3 = -0.00000253881;
2528
- j4 = -0.00000165597;
2529
- j3oj2 = j3 / j2;
2530
- break;
2531
-
2532
- case 'wgs84':
2533
- // ------------ wgs-84 constants ------------
2534
- mus = 398600.5; // in km3 / s2
2535
-
2536
- radiusearthkm = 6378.137; // km
2537
-
2538
- xke = 60.0 / Math.sqrt(radiusearthkm * radiusearthkm * radiusearthkm / mus);
2539
- tumin = 1.0 / xke;
2540
- j2 = 0.00108262998905;
2541
- j3 = -0.00000253215306;
2542
- j4 = -0.00000161098761;
2543
- j3oj2 = j3 / j2;
2544
- break;
2545
-
2546
- default:
2547
- throw new Error("unknown gravity option " + whichconst);
2548
- }
2549
-
2550
- return {
2551
- tumin: tumin,
2552
- mus: mus,
2553
- radiusearthkm: radiusearthkm,
2554
- xke: xke,
2555
- j2: j2,
2556
- j3: j3,
2557
- j4: j4,
2558
- j3oj2: j3oj2
2559
- };
2560
- }; // getgravconst
2561
-
2562
- /* -----------------------------------------------------------------------------
2563
- *
2564
- * function twoline2rv
2565
- *
2566
- * this function converts the two line element set character string data to
2567
- * variables and initializes the sgp4 variables. several intermediate varaibles
2568
- * and quantities are determined. note that the result is a structure so multiple
2569
- * satellites can be processed simultaneously without having to reinitialize. the
2570
- * verification mode is an important option that permits quick checks of any
2571
- * changes to the underlying technical theory. this option works using a
2572
- * modified tle file in which the start, stop, and delta time values are
2573
- * included at the end of the second line of data. this only works with the
2574
- * verification mode. the catalog mode simply propagates from -1440 to 1440 min
2575
- * from epoch and is useful when performing entire catalog runs.
2576
- *
2577
- * author : david vallado 719-573-2600 1 mar 2001
2578
- *
2579
- * inputs :
2580
- * longstr1 - first line of the tle
2581
- * longstr2 - second line of the tle
2582
- * typerun - type of run verification 'v', catalog 'c',
2583
- * manual 'm'
2584
- * typeinput - type of manual input mfe 'm', epoch 'e', dayofyr 'd'
2585
- * opsmode - mode of operation afspc or improved 'a', 'i'
2586
- * whichconst - which set of constants to use 72, 84
2587
- *
2588
- * outputs :
2589
- * satrec - structure containing all the sgp4 satellite information
2590
- *
2591
- * coupling :
2592
- * getgravconst-
2593
- * days2mdhms - conversion of days to month, day, hour, minute, second
2594
- * jday - convert day month year hour minute second into julian date
2595
- * sgp4init - initialize the sgp4 variables
2596
- *
2597
- * references :
2598
- * norad spacetrack report #3
2599
- * vallado, crawford, hujsak, kelso 2006
2600
- --------------------------------------------------------------------------- */
2601
-
2602
-
2603
- Sgp4.createSatrec = function (tleLine1, tleLine2, whichconst, opsmode) {
2604
- if (whichconst === void 0) {
2605
- whichconst = 'wgs72';
2606
- }
2607
-
2608
- if (opsmode === void 0) {
2609
- opsmode = 'i';
2610
- } // xpdotp = 1440.0 / (2.0 * PI); // 229.1831180523293;
2611
-
2612
-
2613
- year = 0;
2614
- satrec = {}; // sgp4fix no longer needed
2615
- // getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 );
2616
-
2617
- satrec.error = 0;
2618
- satrec.satnum = tleLine1.substring(2, 7);
2619
- satrec.epochyr = parseInt(tleLine1.substring(18, 20));
2620
- satrec.epochdays = parseFloat(tleLine1.substring(20, 32));
2621
- satrec.ndot = parseFloat(tleLine1.substring(33, 43));
2622
- satrec.nddot = parseFloat(tleLine1.substring(44, 45) + "." + tleLine1.substring(45, 50) + "E" + tleLine1.substring(50, 52));
2623
- satrec.bstar = parseFloat(tleLine1.substring(53, 54) + "." + tleLine1.substring(54, 59) + "E" + tleLine1.substring(59, 61)); // satrec.satnum = tleLine2.substring(2, 7);
2624
-
2625
- satrec.inclo = parseFloat(tleLine2.substring(8, 16));
2626
- satrec.nodeo = parseFloat(tleLine2.substring(17, 25));
2627
- satrec.ecco = parseFloat("." + tleLine2.substring(26, 33));
2628
- satrec.argpo = parseFloat(tleLine2.substring(34, 42));
2629
- satrec.mo = parseFloat(tleLine2.substring(43, 51));
2630
- satrec.no = parseFloat(tleLine2.substring(52, 63)); // ---- find no, ndot, nddot ----
2631
-
2632
- satrec.no /= xpdotp; // rad/min
2633
-
2634
- /** Ootk -- nexp and ibexp are calculated above using template literals */
2635
- // satrec.nddot = satrec.nddot * Math.pow(10.0, nexp);
2636
- // satrec.bstar = satrec.bstar * Math.pow(10.0, ibexp);
2637
- // ---- convert to sgp4 units ----
2638
- // satrec.a = (satrec.no * tumin) ** (-2.0 / 3.0);
2639
-
2640
- /** Ootk -- Not sure why the following two lines are added. 1st and 2nd derivatives aren't even used anymore */
2641
- // satrec.ndot /= xpdotp * 1440.0; // ? * minperday
2642
- // satrec.nddot /= xpdotp * 1440.0 * 1440;
2643
- // ---- find standard orbital elements ----
2644
-
2645
- satrec.inclo *= DEG2RAD;
2646
- satrec.nodeo *= DEG2RAD;
2647
- satrec.argpo *= DEG2RAD;
2648
- satrec.mo *= DEG2RAD; // sgp4fix not needed here
2649
- // satrec.alta = satrec.a * (1.0 + satrec.ecco) - 1.0;
2650
- // satrec.altp = satrec.a * (1.0 - satrec.ecco) - 1.0;
2651
- // ----------------------------------------------------------------
2652
- // find sgp4epoch time of element set
2653
- // remember that sgp4 uses units of days from 0 jan 1950 (sgp4epoch)
2654
- // and minutes from the epoch (time)
2655
- // ----------------------------------------------------------------
2656
- // ---------------- temp fix for years from 1957-2056 -------------------
2657
- // --------- correct fix will occur when year is 4-digit in tle ---------
2658
-
2659
- if (satrec.epochyr < 57) {
2660
- year = satrec.epochyr + 2000;
2661
- } else {
2662
- year = satrec.epochyr + 1900;
2663
- }
2664
-
2665
- var _a = Sgp4.days2mdhms(year, satrec.epochdays),
2666
- mon = _a.mon,
2667
- day = _a.day,
2668
- hr = _a.hr,
2669
- minute = _a.minute,
2670
- sec = _a.sec;
2671
-
2672
- var jdayRes = Sgp4.jday(year, mon, day, hr, minute, sec);
2673
- satrec.jdsatepoch = jdayRes.jd + jdayRes.jdFrac; // ---------------- initialize the orbit at sgp4epoch -------------------
2674
-
2675
- Sgp4.sgp4init(satrec, {
2676
- whichconst: whichconst,
2677
- opsmode: opsmode,
2678
- satn: satrec.satnum,
2679
- epoch: satrec.jdsatepoch - 2433281.5,
2680
- xbstar: satrec.bstar,
2681
- xecco: satrec.ecco,
2682
- xargpo: satrec.argpo,
2683
- xinclo: satrec.inclo,
2684
- xndot: satrec.ndot,
2685
- xnddot: satrec.nddot,
2686
- xmo: satrec.mo,
2687
- xno: satrec.no,
2688
- xnodeo: satrec.nodeo
2689
- });
2690
- return satrec;
2691
- }; // twoline2rv
2692
-
2693
- /* -----------------------------------------------------------------------------
2694
- *
2695
- * function gstime
2696
- *
2697
- * this function finds the greenwich sidereal time.
2698
- *
2699
- * author : david vallado 719-573-2600 1 mar 2001
2700
- *
2701
- * inputs description range / units
2702
- * jdut1 - julian date in ut1 days from 4713 bc
2703
- *
2704
- * outputs :
2705
- * gstime - greenwich sidereal time 0 to 2PI rad
2706
- *
2707
- * locals :
2708
- * temp - temporary variable for doubles rad
2709
- * tut1 - julian centuries from the
2710
- * jan 1, 2000 12 h epoch (ut1)
2711
- *
2712
- * coupling :
2713
- * none
2714
- *
2715
- * references :
2716
- * vallado 2004, 191, eq 3-45
2717
- * --------------------------------------------------------------------------- */
2718
-
2719
-
2720
- Sgp4.gstime = function (jdut1) {
2721
- tut1 = (jdut1 - 2451545.0) / 36525.0;
2722
- var temp = -6.2e-6 * tut1 * tut1 * tut1 + 0.093104 * tut1 * tut1 + (876600.0 * 3600 + 8640184.812866) * tut1 + 67310.54841; // sec
2723
-
2724
- temp = temp * DEG2RAD / 240.0 % TAU; // 360/86400 = 1/240, to deg, to rad
2725
- // ------------------------ check quadrants ---------------------
2726
-
2727
- if (temp < 0.0) {
2728
- temp += TAU;
2729
- }
2730
-
2731
- return temp;
2732
- };
2733
-
2734
- Sgp4.sgn = function (x) {
2735
- if (x < 0.0) {
2736
- return -1.0;
2737
- } else {
2738
- return 1.0;
2739
- }
2740
- }; // sgn
2741
-
2742
- /* -----------------------------------------------------------------------------
2743
- *
2744
- * function mag
2745
- *
2746
- * this procedure finds the magnitude of a vector.
2747
- *
2748
- * author : david vallado 719-573-2600 1 mar 2001
2749
- *
2750
- * inputs description range / units
2751
- * vec - vector
2752
- *
2753
- * outputs :
2754
- * mag - answer
2755
- *
2756
- * locals :
2757
- * none.
2758
- *
2759
- * coupling :
2760
- * none.
2761
- * --------------------------------------------------------------------------- */
2762
-
2763
-
2764
- Sgp4.mag = function (x) {
2765
- return Math.sqrt(x[0] * x[0] + x[1] * x[1] + x[2] * x[2]);
2766
- }; // mag
2767
-
2768
- /* -----------------------------------------------------------------------------
2769
- *
2770
- * procedure cross_SGP4
2771
- *
2772
- * this procedure crosses two vectors.
2773
- *
2774
- * author : david vallado 719-573-2600 1 mar 2001
2775
- *
2776
- * inputs description range / units
2777
- * vec1 - vector number 1
2778
- * vec2 - vector number 2
2779
- *
2780
- * outputs :
2781
- * outvec - vector result of a x b
2782
- *
2783
- * locals :
2784
- * none.
2785
- *
2786
- * coupling :
2787
- * mag magnitude of a vector
2788
- ---------------------------------------------------------------------------- */
2789
-
2790
-
2791
- Sgp4.cross = function (vec1, vec2) {
2792
- var outvec = [0, 0, 0];
2793
- outvec[0] = vec1[1] * vec2[2] - vec1[2] * vec2[1];
2794
- outvec[1] = vec1[2] * vec2[0] - vec1[0] * vec2[2];
2795
- outvec[2] = vec1[0] * vec2[1] - vec1[1] * vec2[0];
2796
- return outvec;
2797
- }; // end cross
2798
-
2799
- /* -----------------------------------------------------------------------------
2800
- *
2801
- * function dot_SGP4
2802
- *
2803
- * this function finds the dot product of two vectors.
2804
- *
2805
- * author : david vallado 719-573-2600 1 mar 2001
2806
- *
2807
- * inputs description range / units
2808
- * vec1 - vector number 1
2809
- * vec2 - vector number 2
2810
- *
2811
- * outputs :
2812
- * dot - result
2813
- *
2814
- * locals :
2815
- * none.
2816
- *
2817
- * coupling :
2818
- * none.
2819
- * --------------------------------------------------------------------------- */
2820
-
2821
-
2822
- Sgp4.dot = function (x, y) {
2823
- return x[0] * y[0] + x[1] * y[1] + x[2] * y[2];
2824
- }; // dot
2825
-
2826
- /* -----------------------------------------------------------------------------
2827
- *
2828
- * procedure angle_SGP4
2829
- *
2830
- * this procedure calculates the angle between two vectors. the output is
2831
- * set to 999999.1 to indicate an undefined value. be sure to check for
2832
- * this at the output phase.
2833
- *
2834
- * author : david vallado 719-573-2600 1 mar 2001
2835
- *
2836
- * inputs description range / units
2837
- * vec1 - vector number 1
2838
- * vec2 - vector number 2
2839
- *
2840
- * outputs :
2841
- * theta - angle between the two vectors -pi to pi
2842
- *
2843
- * locals :
2844
- * temp - temporary real variable
2845
- *
2846
- * coupling :
2847
- * dot dot product of two vectors
2848
- * --------------------------------------------------------------------------- */
2849
-
2850
-
2851
- Sgp4.angle = function (vec1, vec2) {
2852
- var small = 0.00000001;
2853
- var unknown = 999999.1;
2854
- /** Ootk -- original 'undefined' is protected in JS */
2855
-
2856
- var magv1 = Sgp4.mag(vec1);
2857
- var magv2 = Sgp4.mag(vec2);
2858
-
2859
- if (magv1 * magv2 > small * small) {
2860
- temp = Sgp4.dot(vec1, vec2) / (magv1 * magv2);
2861
- if (Math.abs(temp) > 1.0) temp = Sgp4.sgn(temp) * 1.0;
2862
- return Math.acos(temp);
2863
- } else return unknown;
2864
- }; // angle
2865
-
2866
- /* -----------------------------------------------------------------------------
2867
- *
2868
- * function asinh_SGP4
2869
- *
2870
- * this function evaluates the inverse hyperbolic sine function.
2871
- *
2872
- * author : david vallado 719-573-2600 1 mar 2001
2873
- *
2874
- * inputs description range / units
2875
- * xval - angle value any real
2876
- *
2877
- * outputs :
2878
- * arcsinh - result any real
2879
- *
2880
- * locals :
2881
- * none.
2882
- *
2883
- * coupling :
2884
- * none.
2885
- * --------------------------------------------------------------------------- */
2886
-
2887
-
2888
- Sgp4.asinh = function (xval) {
2889
- return Math.log(xval + Math.sqrt(xval * xval + 1.0));
2890
- }; // asinh
2891
-
2892
- /* -----------------------------------------------------------------------------
2893
- *
2894
- * function newtonnu_SGP4
2895
- *
2896
- * this function solves keplers equation when the true anomaly is known.
2897
- * the mean and eccentric, parabolic, or hyperbolic anomaly is also found.
2898
- * the parabolic limit at 168ø is arbitrary. the hyperbolic anomaly is also
2899
- * limited. the hyperbolic sine is used because it's not double valued.
2900
- *
2901
- * author : david vallado 719-573-2600 27 may 2002
2902
- *
2903
- * revisions
2904
- * vallado - fix small 24 sep 2002
2905
- *
2906
- * inputs description range / units
2907
- * ecc - eccentricity 0.0 to
2908
- * nu - true anomaly -2pi to 2pi rad
2909
- *
2910
- * outputs :
2911
- * e0 - eccentric anomaly 0.0 to 2pi rad 153.02 ø
2912
- * m - mean anomaly 0.0 to 2pi rad 151.7425 ø
2913
- *
2914
- * locals :
2915
- * e1 - eccentric anomaly, next value rad
2916
- * sine - sine of e
2917
- * cose - cosine of e
2918
- * ktr - index
2919
- *
2920
- * coupling :
2921
- * asinh - arc hyperbolic sine
2922
- *
2923
- * references :
2924
- * vallado 2013, 77, alg 5
2925
- * --------------------------------------------------------------------------- */
2926
-
2927
-
2928
- Sgp4.newtonnu = function (ecc, nu) {
2929
- // --------------------- implementation ---------------------
2930
- var e0 = 999999.9;
2931
- var m = 999999.9;
2932
- var small = 0.00000001; // --------------------------- circular ------------------------
2933
-
2934
- if (Math.abs(ecc) < small) {
2935
- m = nu;
2936
- e0 = nu;
2937
- } // ---------------------- elliptical -----------------------
2938
- else if (ecc < 1.0 - small) {
2939
- var sine = Math.sqrt(1.0 - ecc * ecc) * Math.sin(nu) / (1.0 + ecc * Math.cos(nu));
2940
- var cose = (ecc + Math.cos(nu)) / (1.0 + ecc * Math.cos(nu));
2941
- e0 = Math.atan2(sine, cose);
2942
- m = e0 - ecc * Math.sin(e0);
2943
- } // -------------------- hyperbolic --------------------
2944
- else if (ecc > 1.0 + small) {
2945
- if (ecc > 1.0 && Math.abs(nu) + 0.00001 < PI - Math.acos(1.0 / ecc)) {
2946
- var sine = Math.sqrt(ecc * ecc - 1.0) * Math.sin(nu) / (1.0 + ecc * Math.cos(nu));
2947
- e0 = Sgp4.asinh(sine);
2948
- m = ecc * Sgp4.sinh(e0) - e0;
2949
- }
2950
- } // ----------------- parabolic ---------------------
2951
- else if (Math.abs(nu) < 168.0 * PI / 180.0) {
2952
- e0 = Math.tan(nu * 0.5);
2953
- m = e0 + e0 * e0 * e0 / 3.0;
2954
- }
2955
-
2956
- if (ecc < 1.0) {
2957
- m = m % (2.0 * PI);
2958
- if (m < 0.0) m = m + 2.0 * PI;
2959
- e0 = e0 % (2.0 * PI);
2960
- }
2961
-
2962
- return {
2963
- e0: e0,
2964
- m: m
2965
- };
2966
- }; // newtonnu
2967
-
2968
-
2969
- Sgp4.sinh = function (x) {
2970
- return (Math.exp(x) - Math.exp(-x)) / 2;
2971
- };
2972
- /* -----------------------------------------------------------------------------
2973
- *
2974
- * function rv2coe_SGP4
2975
- *
2976
- * this function finds the classical orbital elements given the geocentric
2977
- * equatorial position and velocity vectors.
2978
- *
2979
- * author : david vallado 719-573-2600 21 jun 2002
2980
- *
2981
- * revisions
2982
- * vallado - fix special cases 5 sep 2002
2983
- * vallado - delete extra check in inclination code 16 oct 2002
2984
- * vallado - add constant file use 29 jun 2003
2985
- * vallado - add mu 2 apr 2007
2986
- *
2987
- * inputs description range / units
2988
- * r - ijk position vector km
2989
- * v - ijk velocity vector km / s
2990
- * mu - gravitational parameter km3 / s2
2991
- *
2992
- * outputs :
2993
- * p - semilatus rectum km
2994
- * a - semimajor axis km
2995
- * ecc - eccentricity
2996
- * incl - inclination 0.0 to pi rad
2997
- * omega - right ascension of ascending node 0.0 to 2pi rad
2998
- * argp - argument of perigee 0.0 to 2pi rad
2999
- * nu - true anomaly 0.0 to 2pi rad
3000
- * m - mean anomaly 0.0 to 2pi rad
3001
- * arglat - argument of latitude (ci) 0.0 to 2pi rad
3002
- * truelon - true longitude (ce) 0.0 to 2pi rad
3003
- * lonper - longitude of periapsis (ee) 0.0 to 2pi rad
3004
- *
3005
- * locals :
3006
- * hbar - angular momentum h vector km2 / s
3007
- * ebar - eccentricity e vector
3008
- * nbar - line of nodes n vector
3009
- * c1 - v**2 - u/r
3010
- * rdotv - r dot v
3011
- * hk - hk unit vector
3012
- * sme - specfic mechanical energy km2 / s2
3013
- * i - index
3014
- * e - eccentric, parabolic,
3015
- * hyperbolic anomaly rad
3016
- * temp - temporary variable
3017
- * typeorbit - type of orbit ee, ei, ce, ci
3018
- *
3019
- * coupling :
3020
- * mag - magnitude of a vector
3021
- * cross - cross product of two vectors
3022
- * angle - find the angle between two vectors
3023
- * newtonnu - find the mean anomaly
3024
- *
3025
- * references :
3026
- * vallado 2013, 113, alg 9, ex 2-5
3027
- * --------------------------------------------------------------------------- */
3028
-
3029
-
3030
- Sgp4.rv2coe = function (r, v, mus) {
3031
- var nbar = [0, 0, 0];
3032
- var ebar = [0, 0, 0];
3033
- var p;
3034
- var a;
3035
- var ecc;
3036
- var incl;
3037
- var omega;
3038
- var argp;
3039
- var nu;
3040
- var m;
3041
- var arglat;
3042
- var truelon;
3043
- var lonper;
3044
- var rdotv;
3045
- var magn;
3046
- var hk;
3047
- var sme;
3048
- var i; // switch this to an integer msvs seems to have probelms with this and strncpy_s
3049
- //char typeorbit[2];
3050
-
3051
- var typeorbit; // here
3052
- // typeorbit = 1 = 'ei'
3053
- // typeorbit = 2 = 'ce'
3054
- // typeorbit = 3 = 'ci'
3055
- // typeorbit = 4 = 'ee'
3056
-
3057
- var halfpi = 0.5 * PI;
3058
- var small = 0.00000001;
3059
- var unknown = 999999.1;
3060
- /** Ootk -- original undefined is illegal in JS */
3061
-
3062
- var infinite = 999999.9; // ------------------------- implementation -----------------
3063
-
3064
- var magr = Sgp4.mag(r);
3065
- var magv = Sgp4.mag(v); // ------------------ find h n and e vectors ----------------
3066
-
3067
- var hbar = Sgp4.cross(r, v);
3068
- var magh = Sgp4.mag(hbar);
3069
-
3070
- if (magh > small) {
3071
- nbar[0] = -hbar[1];
3072
- nbar[1] = hbar[0];
3073
- nbar[2] = 0.0;
3074
- magn = Sgp4.mag(nbar);
3075
- c1 = magv * magv - mus / magr;
3076
- rdotv = Sgp4.dot(r, v);
3077
-
3078
- for (i = 0; i <= 2; i++) {
3079
- ebar[i] = (c1 * r[i] - rdotv * v[i]) / mus;
3080
- }
3081
-
3082
- ecc = Sgp4.mag(ebar); // ------------ find a e and semi-latus rectum ----------
3083
-
3084
- sme = magv * magv * 0.5 - mus / magr;
3085
- if (Math.abs(sme) > small) a = -mus / (2.0 * sme);else a = infinite;
3086
- p = magh * magh / mus; // ----------------- find inclination -------------------
3087
-
3088
- hk = hbar[2] / magh;
3089
- incl = Math.acos(hk); // -------- determine type of orbit for later use --------
3090
- // ------ elliptical, parabolic, hyperbolic inclined -------
3091
-
3092
- typeorbit = 1;
3093
-
3094
- if (ecc < small) {
3095
- // ---------------- circular equatorial ---------------
3096
- if (incl < small || Math.abs(incl - PI) < small) {
3097
- typeorbit = 2;
3098
- } else {
3099
- // -------------- circular inclined ---------------
3100
- typeorbit = 3;
3101
- }
3102
- } else {
3103
- // - elliptical, parabolic, hyperbolic equatorial --
3104
- if (incl < small || Math.abs(incl - PI) < small) {
3105
- typeorbit = 4;
3106
- }
3107
- } // ---------- find right ascension of the ascending node ------------
3108
-
3109
-
3110
- if (magn > small) {
3111
- temp = nbar[0] / magn;
3112
- if (Math.abs(temp) > 1.0) temp = Sgp4.sgn(temp);
3113
- omega = Math.acos(temp);
3114
- if (nbar[1] < 0.0) omega = TAU - omega;
3115
- } else omega = unknown; // ---------------- find argument of perigee ---------------
3116
-
3117
-
3118
- if (typeorbit == 1) {
3119
- argp = Sgp4.angle(nbar, ebar);
3120
- if (ebar[2] < 0.0) argp = TAU - argp;
3121
- } else argp = unknown; // ------------ find true anomaly at epoch -------------
3122
-
3123
-
3124
- if (typeorbit == 1 || typeorbit == 4) {
3125
- nu = Sgp4.angle(ebar, r);
3126
- if (rdotv < 0.0) nu = TAU - nu;
3127
- } else nu = unknown; // ---- find argument of latitude - circular inclined -----
3128
-
3129
-
3130
- if (typeorbit == 3) {
3131
- arglat = Sgp4.angle(nbar, r);
3132
- if (r[2] < 0.0) arglat = TAU - arglat;
3133
- m = arglat;
3134
- } else arglat = unknown;
3135
-
3136
- if (ecc > small && typeorbit == 4) {
3137
- temp = ebar[0] / ecc;
3138
- if (Math.abs(temp) > 1.0) temp = Sgp4.sgn(temp);
3139
- lonper = Math.acos(temp);
3140
- if (ebar[1] < 0.0) lonper = TAU - lonper;
3141
- if (incl > halfpi) lonper = TAU - lonper;
3142
- } else lonper = unknown; // -------- find true longitude - circular equatorial ------
3143
-
3144
-
3145
- if (magr > small && typeorbit == 2) {
3146
- temp = r[0] / magr;
3147
- if (Math.abs(temp) > 1.0) temp = Sgp4.sgn(temp);
3148
- truelon = Math.acos(temp);
3149
- if (r[1] < 0.0) truelon = TAU - truelon;
3150
- if (incl > halfpi) truelon = TAU - truelon;
3151
- m = truelon;
3152
- } else truelon = unknown; // ------------ find mean anomaly for all orbits -----------
3153
-
3154
-
3155
- if (typeorbit == 1 || typeorbit == 4) m = Sgp4.newtonnu(ecc, nu).m;
3156
- } else {
3157
- p = unknown;
3158
- a = unknown;
3159
- ecc = unknown;
3160
- incl = unknown;
3161
- omega = unknown;
3162
- argp = unknown;
3163
- nu = unknown;
3164
- m = unknown;
3165
- arglat = unknown;
3166
- truelon = unknown;
3167
- lonper = unknown;
3168
- }
3169
-
3170
- return {
3171
- p: p,
3172
- a: a,
3173
- ecc: ecc,
3174
- incl: incl,
3175
- omega: omega,
3176
- argp: argp,
3177
- nu: nu,
3178
- m: m,
3179
- arglat: arglat,
3180
- truelon: truelon,
3181
- lonper: lonper
3182
- };
3183
- }; // rv2coe
3184
-
3185
- /* -----------------------------------------------------------------------------
3186
- *
3187
- * procedure jday
3188
- *
3189
- * this procedure finds the julian date given the year, month, day, and time.
3190
- * the julian date is defined by each elapsed day since noon, jan 1, 4713 bc.
3191
- *
3192
- * algorithm : calculate the answer in one step for efficiency
3193
- *
3194
- * author : david vallado 719-573-2600 1 mar 2001
3195
- *
3196
- * inputs description range / units
3197
- * year - year 1900 .. 2100
3198
- * mon - month 1 .. 12
3199
- * day - day 1 .. 28,29,30,31
3200
- * hr - universal time hour 0 .. 23
3201
- * min - universal time min 0 .. 59
3202
- * sec - universal time sec 0.0 .. 59.999
3203
- *
3204
- * outputs :
3205
- * jd - julian date days from 4713 bc
3206
- * jdfrac - julian date fraction into day days from 4713 bc
3207
- *
3208
- * locals :
3209
- * none.
3210
- *
3211
- * coupling :
3212
- * none.
3213
- *
3214
- * references :
3215
- * vallado 2013, 183, alg 14, ex 3-4
3216
- *
3217
- * --------------------------------------------------------------------------- */
3218
-
3219
-
3220
- Sgp4.jday = function (year, mon, day, hr, minute, sec) {
3221
- var jd = 367.0 * year - Math.floor(7 * (year + Math.floor((mon + 9) / 12.0)) * 0.25) + Math.floor(275 * mon / 9.0) + day + 1721013.5; // use - 678987.0 to go to mjd directly
3222
-
3223
- var jdFrac = (sec + minute * 60.0 + hr * 3600.0) / 86400.0; // check that the day and fractional day are correct
3224
-
3225
- if (Math.abs(jdFrac) > 1.0) {
3226
- var dtt = Math.floor(jdFrac);
3227
- jd = jd + dtt;
3228
- jdFrac = jdFrac - dtt;
3229
- } // - 0.5*sgn(100.0*year + mon - 190002.5) + 0.5;
3230
-
3231
-
3232
- return {
3233
- jd: jd,
3234
- jdFrac: jdFrac
3235
- };
3236
- }; // jday
3237
-
3238
- /* -----------------------------------------------------------------------------
3239
- *
3240
- * procedure days2mdhms
3241
- *
3242
- * this procedure converts the day of the year, days, to the equivalent month
3243
- * day, hour, minute and second.
3244
- *
3245
- * algorithm : set up array for the number of days per month
3246
- * find leap year - use 1900 because 2000 is a leap year
3247
- * loop through a temp value while the value is < the days
3248
- * perform int conversions to the correct day and month
3249
- * convert remainder into h m s using type conversions
3250
- *
3251
- * author : david vallado 719-573-2600 1 mar 2001
3252
- *
3253
- * inputs description range / units
3254
- * year - year 1900 .. 2100
3255
- * days - julian day of the year 0.0 .. 366.0
3256
- *
3257
- * outputs :
3258
- * mon - month 1 .. 12
3259
- * day - day 1 .. 28,29,30,31
3260
- * hr - hour 0 .. 23
3261
- * min - minute 0 .. 59
3262
- * sec - second 0.0 .. 59.999
3263
- *
3264
- * locals :
3265
- * dayofyr - day of year
3266
- * temp - temporary extended values
3267
- * inttemp - temporary int value
3268
- * i - index
3269
- * lmonth[13] - int array containing the number of days per month
3270
- *
3271
- * coupling :
3272
- * none.
3273
- * --------------------------------------------------------------------------- */
3274
-
3275
-
3276
- Sgp4.days2mdhms = function (year, days) {
3277
- lmonth = [31, year % 4 === 0 ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
3278
- dayofyr = Math.floor(days); // ----------------- find month and day of month ----------------
3279
-
3280
- /** Ootk -- Incorporated in the above declaration */
3281
- // if ((year % 4) == 0)
3282
- // lmonth[2] = 29;
3283
-
3284
- i = 1;
3285
- inttemp = 0;
3286
-
3287
- while (dayofyr > inttemp + lmonth[i - 1] && i < 12) {
3288
- inttemp += lmonth[i - 1];
3289
- i += 1;
3290
- }
3291
-
3292
- mon = i;
3293
- day = dayofyr - inttemp; // ----------------- find hours minutes and seconds -------------
3294
-
3295
- temp = (days - dayofyr) * 24.0;
3296
- hr = Math.floor(temp);
3297
- temp = (temp - hr) * 60.0;
3298
- minute = Math.floor(temp);
3299
- sec = (temp - minute) * 60.0;
3300
- return {
3301
- mon: mon,
3302
- day: day,
3303
- hr: hr,
3304
- minute: minute,
3305
- sec: sec
3306
- };
3307
- }; // days2mdhms
3308
-
3309
- /* -----------------------------------------------------------------------------
3310
- *
3311
- * procedure invjday
3312
- *
3313
- * this procedure finds the year, month, day, hour, minute and second
3314
- * given the julian date. tu can be ut1, tdt, tdb, etc.
3315
- *
3316
- * algorithm : set up starting values
3317
- * find leap year - use 1900 because 2000 is a leap year
3318
- * find the elapsed days through the year in a loop
3319
- * call routine to find each individual value
3320
- *
3321
- * author : david vallado 719-573-2600 1 mar 2001
3322
- *
3323
- * inputs description range / units
3324
- * jd - julian date days from 4713 bc
3325
- * jdfrac - julian date fraction into day days from 4713 bc
3326
- *
3327
- * outputs :
3328
- * year - year 1900 .. 2100
3329
- * mon - month 1 .. 12
3330
- * day - day 1 .. 28,29,30,31
3331
- * hr - hour 0 .. 23
3332
- * min - minute 0 .. 59
3333
- * sec - second 0.0 .. 59.999
3334
- *
3335
- * locals :
3336
- * days - day of year plus fractional
3337
- * portion of a day days
3338
- * tu - julian centuries from 0 h
3339
- * jan 0, 1900
3340
- * temp - temporary double values
3341
- * leapyrs - number of leap years from 1900
3342
- *
3343
- * coupling :
3344
- * days2mdhms - finds month, day, hour, minute and second given days and year
3345
- *
3346
- * references :
3347
- * vallado 2013, 203, alg 22, ex 3-13
3348
- * --------------------------------------------------------------------------- */
3349
-
3350
-
3351
- Sgp4.invjday = function (jd, jdfrac) {
3352
- var leapyrs;
3353
- var days; // check jdfrac for multiple days
3354
-
3355
- if (Math.abs(jdfrac) >= 1.0) {
3356
- jd = jd + Math.floor(jdfrac);
3357
- jdfrac = jdfrac - Math.floor(jdfrac);
3358
- } // check for fraction of a day included in the jd
3359
-
3360
-
3361
- var dt = jd - Math.floor(jd) - 0.5;
3362
-
3363
- if (Math.abs(dt) > 0.00000001) {
3364
- jd = jd - dt;
3365
- jdfrac = jdfrac + dt;
3366
- }
3367
- /* --------------- find year and days of the year --------------- */
3368
-
3369
-
3370
- var temp = jd - 2415019.5;
3371
- var tu = temp / 365.25;
3372
- year = 1900 + Math.floor(tu);
3373
- leapyrs = Math.floor((year - 1901) * 0.25);
3374
- days = Math.floor(temp - ((year - 1900) * 365.0 + leapyrs));
3375
- /* ------------ check for case of beginning of a year ----------- */
3376
-
3377
- if (days + jdfrac < 1.0) {
3378
- year = year - 1;
3379
- leapyrs = Math.floor((year - 1901) * 0.25);
3380
- days = Math.floor(temp - ((year - 1900) * 365.0 + leapyrs));
3381
- }
3382
- /* ----------------- find remaining data ------------------------- */
3383
-
3384
-
3385
- var _a = Sgp4.days2mdhms(year, days + jdfrac),
3386
- mon = _a.mon,
3387
- day = _a.day,
3388
- hr = _a.hr,
3389
- minute = _a.minute,
3390
- sec = _a.sec;
3391
-
3392
- return {
3393
- year: year,
3394
- mon: mon,
3395
- day: day,
3396
- hr: hr,
3397
- minute: minute,
3398
- sec: sec
3399
- };
3400
- }; // invjday
3401
-
3402
-
3403
- return Sgp4;
3404
- }();
3405
-
3406
-
3407
-
3408
- /***/ })
3409
-
3410
- /******/ });
3411
- /************************************************************************/
3412
- /******/ // The module cache
3413
- /******/ var __webpack_module_cache__ = {};
3414
- /******/
3415
- /******/ // The require function
3416
- /******/ function __webpack_require__(moduleId) {
3417
- /******/ // Check if module is in cache
3418
- /******/ if(__webpack_module_cache__[moduleId]) {
3419
- /******/ return __webpack_module_cache__[moduleId].exports;
3420
- /******/ }
3421
- /******/ // Create a new module (and put it into the cache)
3422
- /******/ var module = __webpack_module_cache__[moduleId] = {
3423
- /******/ // no module.id needed
3424
- /******/ // no module.loaded needed
3425
- /******/ exports: {}
3426
- /******/ };
3427
- /******/
3428
- /******/ // Execute the module function
3429
- /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
3430
- /******/
3431
- /******/ // Return the exports of the module
3432
- /******/ return module.exports;
3433
- /******/ }
3434
- /******/
3435
- /************************************************************************/
3436
- /******/ /* webpack/runtime/define property getters */
3437
- /******/ (() => {
3438
- /******/ // define getter functions for harmony exports
3439
- /******/ __webpack_require__.d = (exports, definition) => {
3440
- /******/ for(var key in definition) {
3441
- /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
3442
- /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
3443
- /******/ }
3444
- /******/ }
3445
- /******/ };
3446
- /******/ })();
3447
- /******/
3448
- /******/ /* webpack/runtime/hasOwnProperty shorthand */
3449
- /******/ (() => {
3450
- /******/ __webpack_require__.o = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop)
3451
- /******/ })();
3452
- /******/
3453
- /******/ /* webpack/runtime/make namespace object */
3454
- /******/ (() => {
3455
- /******/ // define __esModule on exports
3456
- /******/ __webpack_require__.r = (exports) => {
3457
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
3458
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3459
- /******/ }
3460
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
3461
- /******/ };
3462
- /******/ })();
3463
- /******/
3464
- /************************************************************************/
3465
- /******/ // module exports must be returned from runtime so entry inlining is disabled
3466
- /******/ // startup
3467
- /******/ // Load entry module and return exports
3468
- /******/ return __webpack_require__(333);
3469
- /******/ })()
3470
- ;
3471
- });