-
Notifications
You must be signed in to change notification settings - Fork 1
/
satellite.js
3084 lines (2859 loc) · 95.3 KB
/
satellite.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*!
* satellite-js v4.0.0
* (c) 2013 Shashwat Kandadai and UCSC
* https://github.com/shashwatak/satellite-js
* License: MIT
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = global || self, global.satellite = factory());
}(this, (function () { 'use strict';
var pi = Math.PI;
var twoPi = pi * 2;
var deg2rad = pi / 180.0;
var rad2deg = 180 / pi;
var minutesPerDay = 1440.0;
var mu = 398600.5; // in km3 / s2
var earthRadius = 6378.137; // in km
var xke = 60.0 / Math.sqrt(earthRadius * earthRadius * earthRadius / mu);
var vkmpersec = earthRadius * xke / 60.0;
var tumin = 1.0 / xke;
var j2 = 0.00108262998905;
var j3 = -0.00000253215306;
var j4 = -0.00000161098761;
var j3oj2 = j3 / j2;
var x2o3 = 2.0 / 3.0;
var constants = /*#__PURE__*/Object.freeze({
__proto__: null,
pi: pi,
twoPi: twoPi,
deg2rad: deg2rad,
rad2deg: rad2deg,
minutesPerDay: minutesPerDay,
mu: mu,
earthRadius: earthRadius,
xke: xke,
vkmpersec: vkmpersec,
tumin: tumin,
j2: j2,
j3: j3,
j4: j4,
j3oj2: j3oj2,
x2o3: x2o3
});
/* -----------------------------------------------------------------------------
*
* procedure days2mdhms
*
* this procedure converts the day of the year, days, to the equivalent month
* day, hour, minute and second.
*
* algorithm : set up array for the number of days per month
* find leap year - use 1900 because 2000 is a leap year
* loop through a temp value while the value is < the days
* perform int conversions to the correct day and month
* convert remainder into h m s using type conversions
*
* author : david vallado 719-573-2600 1 mar 2001
*
* inputs description range / units
* year - year 1900 .. 2100
* days - julian day of the year 0.0 .. 366.0
*
* outputs :
* mon - month 1 .. 12
* day - day 1 .. 28,29,30,31
* hr - hour 0 .. 23
* min - minute 0 .. 59
* sec - second 0.0 .. 59.999
*
* locals :
* dayofyr - day of year
* temp - temporary extended values
* inttemp - temporary int value
* i - index
* lmonth[12] - int array containing the number of days per month
*
* coupling :
* none.
* --------------------------------------------------------------------------- */
function days2mdhms(year, days) {
var lmonth = [31, year % 4 === 0 ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
var dayofyr = Math.floor(days); // ----------------- find month and day of month ----------------
var i = 1;
var inttemp = 0;
while (dayofyr > inttemp + lmonth[i - 1] && i < 12) {
inttemp += lmonth[i - 1];
i += 1;
}
var mon = i;
var day = dayofyr - inttemp; // ----------------- find hours minutes and seconds -------------
var temp = (days - dayofyr) * 24.0;
var hr = Math.floor(temp);
temp = (temp - hr) * 60.0;
var minute = Math.floor(temp);
var sec = (temp - minute) * 60.0;
return {
mon: mon,
day: day,
hr: hr,
minute: minute,
sec: sec
};
}
/* -----------------------------------------------------------------------------
*
* procedure jday
*
* this procedure finds the julian date given the year, month, day, and time.
* the julian date is defined by each elapsed day since noon, jan 1, 4713 bc.
*
* algorithm : calculate the answer in one step for efficiency
*
* author : david vallado 719-573-2600 1 mar 2001
*
* inputs description range / units
* year - year 1900 .. 2100
* mon - month 1 .. 12
* day - day 1 .. 28,29,30,31
* hr - universal time hour 0 .. 23
* min - universal time min 0 .. 59
* sec - universal time sec 0.0 .. 59.999
*
* outputs :
* jd - julian date days from 4713 bc
*
* locals :
* none.
*
* coupling :
* none.
*
* references :
* vallado 2007, 189, alg 14, ex 3-14
*
* --------------------------------------------------------------------------- */
function jdayInternal(year, mon, day, hr, minute, sec) {
var msec = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 0;
return 367.0 * year - Math.floor(7 * (year + Math.floor((mon + 9) / 12.0)) * 0.25) + Math.floor(275 * mon / 9.0) + day + 1721013.5 + ((msec / 60000 + sec / 60.0 + minute) / 60.0 + hr) / 24.0 // ut in days
// # - 0.5*sgn(100.0*year + mon - 190002.5) + 0.5;
;
}
function jday(year, mon, day, hr, minute, sec, msec) {
if (year instanceof Date) {
var date = year;
return jdayInternal(date.getUTCFullYear(), date.getUTCMonth() + 1, // Note, this function requires months in range 1-12.
date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds(), date.getUTCMilliseconds());
}
return jdayInternal(year, mon, day, hr, minute, sec, msec);
}
/* -----------------------------------------------------------------------------
*
* procedure invjday
*
* this procedure finds the year, month, day, hour, minute and second
* given the julian date. tu can be ut1, tdt, tdb, etc.
*
* algorithm : set up starting values
* find leap year - use 1900 because 2000 is a leap year
* find the elapsed days through the year in a loop
* call routine to find each individual value
*
* author : david vallado 719-573-2600 1 mar 2001
*
* inputs description range / units
* jd - julian date days from 4713 bc
*
* outputs :
* year - year 1900 .. 2100
* mon - month 1 .. 12
* day - day 1 .. 28,29,30,31
* hr - hour 0 .. 23
* min - minute 0 .. 59
* sec - second 0.0 .. 59.999
*
* locals :
* days - day of year plus fractional
* portion of a day days
* tu - julian centuries from 0 h
* jan 0, 1900
* temp - temporary double values
* leapyrs - number of leap years from 1900
*
* coupling :
* days2mdhms - finds month, day, hour, minute and second given days and year
*
* references :
* vallado 2007, 208, alg 22, ex 3-13
* --------------------------------------------------------------------------- */
function invjday(jd, asArray) {
// --------------- find year and days of the year -
var temp = jd - 2415019.5;
var tu = temp / 365.25;
var year = 1900 + Math.floor(tu);
var leapyrs = Math.floor((year - 1901) * 0.25); // optional nudge by 8.64x10-7 sec to get even outputs
var days = temp - ((year - 1900) * 365.0 + leapyrs) + 0.00000000001; // ------------ check for case of beginning of a year -----------
if (days < 1.0) {
year -= 1;
leapyrs = Math.floor((year - 1901) * 0.25);
days = temp - ((year - 1900) * 365.0 + leapyrs);
} // ----------------- find remaing data -------------------------
var mdhms = days2mdhms(year, days);
var mon = mdhms.mon,
day = mdhms.day,
hr = mdhms.hr,
minute = mdhms.minute;
var sec = mdhms.sec - 0.00000086400;
if (asArray) {
return [year, mon, day, hr, minute, Math.floor(sec)];
}
return new Date(Date.UTC(year, mon - 1, day, hr, minute, Math.floor(sec)));
}
/* -----------------------------------------------------------------------------
*
* procedure dpper
*
* this procedure provides deep space long period periodic contributions
* to the mean elements. by design, these periodics are zero at epoch.
* this used to be dscom which included initialization, but it's really a
* recurring function.
*
* author : david vallado 719-573-2600 28 jun 2005
*
* inputs :
* e3 -
* ee2 -
* peo -
* pgho -
* pho -
* pinco -
* plo -
* se2 , se3 , sgh2, sgh3, sgh4, sh2, sh3, si2, si3, sl2, sl3, sl4 -
* t -
* xh2, xh3, xi2, xi3, xl2, xl3, xl4 -
* zmol -
* zmos -
* ep - eccentricity 0.0 - 1.0
* inclo - inclination - needed for lyddane modification
* nodep - right ascension of ascending node
* argpp - argument of perigee
* mp - mean anomaly
*
* outputs :
* ep - eccentricity 0.0 - 1.0
* inclp - inclination
* nodep - right ascension of ascending node
* argpp - argument of perigee
* mp - mean anomaly
*
* locals :
* alfdp -
* betdp -
* cosip , sinip , cosop , sinop ,
* dalf -
* dbet -
* dls -
* f2, f3 -
* pe -
* pgh -
* ph -
* pinc -
* pl -
* sel , ses , sghl , sghs , shl , shs , sil , sinzf , sis ,
* sll , sls
* xls -
* xnoh -
* zf -
* zm -
*
* coupling :
* none.
*
* references :
* hoots, roehrich, norad spacetrack report #3 1980
* hoots, norad spacetrack report #6 1986
* hoots, schumacher and glover 2004
* vallado, crawford, hujsak, kelso 2006
----------------------------------------------------------------------------*/
function dpper(satrec, options) {
var e3 = satrec.e3,
ee2 = satrec.ee2,
peo = satrec.peo,
pgho = satrec.pgho,
pho = satrec.pho,
pinco = satrec.pinco,
plo = satrec.plo,
se2 = satrec.se2,
se3 = satrec.se3,
sgh2 = satrec.sgh2,
sgh3 = satrec.sgh3,
sgh4 = satrec.sgh4,
sh2 = satrec.sh2,
sh3 = satrec.sh3,
si2 = satrec.si2,
si3 = satrec.si3,
sl2 = satrec.sl2,
sl3 = satrec.sl3,
sl4 = satrec.sl4,
t = satrec.t,
xgh2 = satrec.xgh2,
xgh3 = satrec.xgh3,
xgh4 = satrec.xgh4,
xh2 = satrec.xh2,
xh3 = satrec.xh3,
xi2 = satrec.xi2,
xi3 = satrec.xi3,
xl2 = satrec.xl2,
xl3 = satrec.xl3,
xl4 = satrec.xl4,
zmol = satrec.zmol,
zmos = satrec.zmos;
var init = options.init,
opsmode = options.opsmode;
var ep = options.ep,
inclp = options.inclp,
nodep = options.nodep,
argpp = options.argpp,
mp = options.mp; // Copy satellite attributes into local variables for convenience
// and symmetry in writing formulae.
var alfdp;
var betdp;
var cosip;
var sinip;
var cosop;
var sinop;
var dalf;
var dbet;
var dls;
var f2;
var f3;
var pe;
var pgh;
var ph;
var pinc;
var pl;
var sinzf;
var xls;
var xnoh;
var zf;
var zm; // ---------------------- constants -----------------------------
var zns = 1.19459e-5;
var zes = 0.01675;
var znl = 1.5835218e-4;
var zel = 0.05490; // --------------- calculate time varying periodics -----------
zm = zmos + zns * t; // be sure that the initial call has time set to zero
if (init === 'y') {
zm = zmos;
}
zf = zm + 2.0 * zes * Math.sin(zm);
sinzf = Math.sin(zf);
f2 = 0.5 * sinzf * sinzf - 0.25;
f3 = -0.5 * sinzf * Math.cos(zf);
var ses = se2 * f2 + se3 * f3;
var sis = si2 * f2 + si3 * f3;
var sls = sl2 * f2 + sl3 * f3 + sl4 * sinzf;
var sghs = sgh2 * f2 + sgh3 * f3 + sgh4 * sinzf;
var shs = sh2 * f2 + sh3 * f3;
zm = zmol + znl * t;
if (init === 'y') {
zm = zmol;
}
zf = zm + 2.0 * zel * Math.sin(zm);
sinzf = Math.sin(zf);
f2 = 0.5 * sinzf * sinzf - 0.25;
f3 = -0.5 * sinzf * Math.cos(zf);
var sel = ee2 * f2 + e3 * f3;
var sil = xi2 * f2 + xi3 * f3;
var sll = xl2 * f2 + xl3 * f3 + xl4 * sinzf;
var sghl = xgh2 * f2 + xgh3 * f3 + xgh4 * sinzf;
var shll = xh2 * f2 + xh3 * f3;
pe = ses + sel;
pinc = sis + sil;
pl = sls + sll;
pgh = sghs + sghl;
ph = shs + shll;
if (init === 'n') {
pe -= peo;
pinc -= pinco;
pl -= plo;
pgh -= pgho;
ph -= pho;
inclp += pinc;
ep += pe;
sinip = Math.sin(inclp);
cosip = Math.cos(inclp);
/* ----------------- apply periodics directly ------------ */
// sgp4fix for lyddane choice
// strn3 used original inclination - this is technically feasible
// gsfc used perturbed inclination - also technically feasible
// probably best to readjust the 0.2 limit value and limit discontinuity
// 0.2 rad = 11.45916 deg
// use next line for original strn3 approach and original inclination
// if (inclo >= 0.2)
// use next line for gsfc version and perturbed inclination
if (inclp >= 0.2) {
ph /= sinip;
pgh -= cosip * ph;
argpp += pgh;
nodep += ph;
mp += pl;
} else {
// ---- apply periodics with lyddane modification ----
sinop = Math.sin(nodep);
cosop = Math.cos(nodep);
alfdp = sinip * sinop;
betdp = sinip * cosop;
dalf = ph * cosop + pinc * cosip * sinop;
dbet = -ph * sinop + pinc * cosip * cosop;
alfdp += dalf;
betdp += dbet;
nodep %= twoPi; // sgp4fix for afspc written intrinsic functions
// nodep used without a trigonometric function ahead
if (nodep < 0.0 && opsmode === 'a') {
nodep += twoPi;
}
xls = mp + argpp + cosip * nodep;
dls = pl + pgh - pinc * nodep * sinip;
xls += dls;
xnoh = nodep;
nodep = Math.atan2(alfdp, betdp); // sgp4fix for afspc written intrinsic functions
// nodep used without a trigonometric function ahead
if (nodep < 0.0 && opsmode === 'a') {
nodep += twoPi;
}
if (Math.abs(xnoh - nodep) > pi) {
if (nodep < xnoh) {
nodep += twoPi;
} else {
nodep -= twoPi;
}
}
mp += pl;
argpp = xls - mp - cosip * nodep;
}
}
return {
ep: ep,
inclp: inclp,
nodep: nodep,
argpp: argpp,
mp: mp
};
}
/*-----------------------------------------------------------------------------
*
* procedure dscom
*
* this procedure provides deep space common items used by both the secular
* and periodics subroutines. input is provided as shown. this routine
* used to be called dpper, but the functions inside weren't well organized.
*
* author : david vallado 719-573-2600 28 jun 2005
*
* inputs :
* epoch -
* ep - eccentricity
* argpp - argument of perigee
* tc -
* inclp - inclination
* nodep - right ascension of ascending node
* np - mean motion
*
* outputs :
* sinim , cosim , sinomm , cosomm , snodm , cnodm
* day -
* e3 -
* ee2 -
* em - eccentricity
* emsq - eccentricity squared
* gam -
* peo -
* pgho -
* pho -
* pinco -
* plo -
* rtemsq -
* se2, se3 -
* sgh2, sgh3, sgh4 -
* sh2, sh3, si2, si3, sl2, sl3, sl4 -
* s1, s2, s3, s4, s5, s6, s7 -
* ss1, ss2, ss3, ss4, ss5, ss6, ss7, sz1, sz2, sz3 -
* sz11, sz12, sz13, sz21, sz22, sz23, sz31, sz32, sz33 -
* xgh2, xgh3, xgh4, xh2, xh3, xi2, xi3, xl2, xl3, xl4 -
* nm - mean motion
* z1, z2, z3, z11, z12, z13, z21, z22, z23, z31, z32, z33 -
* zmol -
* zmos -
*
* locals :
* a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 -
* betasq -
* cc -
* ctem, stem -
* x1, x2, x3, x4, x5, x6, x7, x8 -
* xnodce -
* xnoi -
* zcosg , zsing , zcosgl , zsingl , zcosh , zsinh , zcoshl , zsinhl ,
* zcosi , zsini , zcosil , zsinil ,
* zx -
* zy -
*
* coupling :
* none.
*
* references :
* hoots, roehrich, norad spacetrack report #3 1980
* hoots, norad spacetrack report #6 1986
* hoots, schumacher and glover 2004
* vallado, crawford, hujsak, kelso 2006
----------------------------------------------------------------------------*/
function dscom(options) {
var epoch = options.epoch,
ep = options.ep,
argpp = options.argpp,
tc = options.tc,
inclp = options.inclp,
nodep = options.nodep,
np = options.np;
var a1;
var a2;
var a3;
var a4;
var a5;
var a6;
var a7;
var a8;
var a9;
var a10;
var cc;
var x1;
var x2;
var x3;
var x4;
var x5;
var x6;
var x7;
var x8;
var zcosg;
var zsing;
var zcosh;
var zsinh;
var zcosi;
var zsini;
var ss1;
var ss2;
var ss3;
var ss4;
var ss5;
var ss6;
var ss7;
var sz1;
var sz2;
var sz3;
var sz11;
var sz12;
var sz13;
var sz21;
var sz22;
var sz23;
var sz31;
var sz32;
var sz33;
var s1;
var s2;
var s3;
var s4;
var s5;
var s6;
var s7;
var z1;
var z2;
var z3;
var z11;
var z12;
var z13;
var z21;
var z22;
var z23;
var z31;
var z32;
var z33; // -------------------------- constants -------------------------
var zes = 0.01675;
var zel = 0.05490;
var c1ss = 2.9864797e-6;
var c1l = 4.7968065e-7;
var zsinis = 0.39785416;
var zcosis = 0.91744867;
var zcosgs = 0.1945905;
var zsings = -0.98088458; // --------------------- local variables ------------------------
var nm = np;
var em = ep;
var snodm = Math.sin(nodep);
var cnodm = Math.cos(nodep);
var sinomm = Math.sin(argpp);
var cosomm = Math.cos(argpp);
var sinim = Math.sin(inclp);
var cosim = Math.cos(inclp);
var emsq = em * em;
var betasq = 1.0 - emsq;
var rtemsq = Math.sqrt(betasq); // ----------------- initialize lunar solar terms ---------------
var peo = 0.0;
var pinco = 0.0;
var plo = 0.0;
var pgho = 0.0;
var pho = 0.0;
var day = epoch + 18261.5 + tc / 1440.0;
var xnodce = (4.5236020 - 9.2422029e-4 * day) % twoPi;
var stem = Math.sin(xnodce);
var ctem = Math.cos(xnodce);
var zcosil = 0.91375164 - 0.03568096 * ctem;
var zsinil = Math.sqrt(1.0 - zcosil * zcosil);
var zsinhl = 0.089683511 * stem / zsinil;
var zcoshl = Math.sqrt(1.0 - zsinhl * zsinhl);
var gam = 5.8351514 + 0.0019443680 * day;
var zx = 0.39785416 * stem / zsinil;
var zy = zcoshl * ctem + 0.91744867 * zsinhl * stem;
zx = Math.atan2(zx, zy);
zx += gam - xnodce;
var zcosgl = Math.cos(zx);
var zsingl = Math.sin(zx); // ------------------------- do solar terms ---------------------
zcosg = zcosgs;
zsing = zsings;
zcosi = zcosis;
zsini = zsinis;
zcosh = cnodm;
zsinh = snodm;
cc = c1ss;
var xnoi = 1.0 / nm;
var lsflg = 0;
while (lsflg < 2) {
lsflg += 1;
a1 = zcosg * zcosh + zsing * zcosi * zsinh;
a3 = -zsing * zcosh + zcosg * zcosi * zsinh;
a7 = -zcosg * zsinh + zsing * zcosi * zcosh;
a8 = zsing * zsini;
a9 = zsing * zsinh + zcosg * zcosi * zcosh;
a10 = zcosg * zsini;
a2 = cosim * a7 + sinim * a8;
a4 = cosim * a9 + sinim * a10;
a5 = -sinim * a7 + cosim * a8;
a6 = -sinim * a9 + cosim * a10;
x1 = a1 * cosomm + a2 * sinomm;
x2 = a3 * cosomm + a4 * sinomm;
x3 = -a1 * sinomm + a2 * cosomm;
x4 = -a3 * sinomm + a4 * cosomm;
x5 = a5 * sinomm;
x6 = a6 * sinomm;
x7 = a5 * cosomm;
x8 = a6 * cosomm;
z31 = 12.0 * x1 * x1 - 3.0 * x3 * x3;
z32 = 24.0 * x1 * x2 - 6.0 * x3 * x4;
z33 = 12.0 * x2 * x2 - 3.0 * x4 * x4;
z1 = 3.0 * (a1 * a1 + a2 * a2) + z31 * emsq;
z2 = 6.0 * (a1 * a3 + a2 * a4) + z32 * emsq;
z3 = 3.0 * (a3 * a3 + a4 * a4) + z33 * emsq;
z11 = -6.0 * a1 * a5 + emsq * (-24.0 * x1 * x7 - 6.0 * x3 * x5);
z12 = -6.0 * (a1 * a6 + a3 * a5) + emsq * (-24.0 * (x2 * x7 + x1 * x8) + -6.0 * (x3 * x6 + x4 * x5));
z13 = -6.0 * a3 * a6 + emsq * (-24.0 * x2 * x8 - 6.0 * x4 * x6);
z21 = 6.0 * a2 * a5 + emsq * (24.0 * x1 * x5 - 6.0 * x3 * x7);
z22 = 6.0 * (a4 * a5 + a2 * a6) + emsq * (24.0 * (x2 * x5 + x1 * x6) - 6.0 * (x4 * x7 + x3 * x8));
z23 = 6.0 * a4 * a6 + emsq * (24.0 * x2 * x6 - 6.0 * x4 * x8);
z1 = z1 + z1 + betasq * z31;
z2 = z2 + z2 + betasq * z32;
z3 = z3 + z3 + betasq * z33;
s3 = cc * xnoi;
s2 = -0.5 * s3 / rtemsq;
s4 = s3 * rtemsq;
s1 = -15.0 * em * s4;
s5 = x1 * x3 + x2 * x4;
s6 = x2 * x3 + x1 * x4;
s7 = x2 * x4 - x1 * x3; // ----------------------- do lunar terms -------------------
if (lsflg === 1) {
ss1 = s1;
ss2 = s2;
ss3 = s3;
ss4 = s4;
ss5 = s5;
ss6 = s6;
ss7 = s7;
sz1 = z1;
sz2 = z2;
sz3 = z3;
sz11 = z11;
sz12 = z12;
sz13 = z13;
sz21 = z21;
sz22 = z22;
sz23 = z23;
sz31 = z31;
sz32 = z32;
sz33 = z33;
zcosg = zcosgl;
zsing = zsingl;
zcosi = zcosil;
zsini = zsinil;
zcosh = zcoshl * cnodm + zsinhl * snodm;
zsinh = snodm * zcoshl - cnodm * zsinhl;
cc = c1l;
}
}
var zmol = (4.7199672 + (0.22997150 * day - gam)) % twoPi;
var zmos = (6.2565837 + 0.017201977 * day) % twoPi; // ------------------------ do solar terms ----------------------
var se2 = 2.0 * ss1 * ss6;
var se3 = 2.0 * ss1 * ss7;
var si2 = 2.0 * ss2 * sz12;
var si3 = 2.0 * ss2 * (sz13 - sz11);
var sl2 = -2.0 * ss3 * sz2;
var sl3 = -2.0 * ss3 * (sz3 - sz1);
var sl4 = -2.0 * ss3 * (-21.0 - 9.0 * emsq) * zes;
var sgh2 = 2.0 * ss4 * sz32;
var sgh3 = 2.0 * ss4 * (sz33 - sz31);
var sgh4 = -18.0 * ss4 * zes;
var sh2 = -2.0 * ss2 * sz22;
var sh3 = -2.0 * ss2 * (sz23 - sz21); // ------------------------ do lunar terms ----------------------
var ee2 = 2.0 * s1 * s6;
var e3 = 2.0 * s1 * s7;
var xi2 = 2.0 * s2 * z12;
var xi3 = 2.0 * s2 * (z13 - z11);
var xl2 = -2.0 * s3 * z2;
var xl3 = -2.0 * s3 * (z3 - z1);
var xl4 = -2.0 * s3 * (-21.0 - 9.0 * emsq) * zel;
var xgh2 = 2.0 * s4 * z32;
var xgh3 = 2.0 * s4 * (z33 - z31);
var xgh4 = -18.0 * s4 * zel;
var xh2 = -2.0 * s2 * z22;
var xh3 = -2.0 * s2 * (z23 - z21);
return {
snodm: snodm,
cnodm: cnodm,
sinim: sinim,
cosim: cosim,
sinomm: sinomm,
cosomm: cosomm,
day: day,
e3: e3,
ee2: ee2,
em: em,
emsq: emsq,
gam: gam,
peo: peo,
pgho: pgho,
pho: pho,
pinco: pinco,
plo: plo,
rtemsq: rtemsq,
se2: se2,
se3: se3,
sgh2: sgh2,
sgh3: sgh3,
sgh4: sgh4,
sh2: sh2,
sh3: sh3,
si2: si2,
si3: si3,
sl2: sl2,
sl3: sl3,
sl4: sl4,
s1: s1,
s2: s2,
s3: s3,
s4: s4,
s5: s5,
s6: s6,
s7: s7,
ss1: ss1,
ss2: ss2,
ss3: ss3,
ss4: ss4,
ss5: ss5,
ss6: ss6,
ss7: ss7,
sz1: sz1,
sz2: sz2,
sz3: sz3,
sz11: sz11,
sz12: sz12,
sz13: sz13,
sz21: sz21,
sz22: sz22,
sz23: sz23,
sz31: sz31,
sz32: sz32,
sz33: sz33,
xgh2: xgh2,
xgh3: xgh3,
xgh4: xgh4,
xh2: xh2,
xh3: xh3,
xi2: xi2,
xi3: xi3,
xl2: xl2,
xl3: xl3,
xl4: xl4,
nm: nm,
z1: z1,
z2: z2,
z3: z3,
z11: z11,
z12: z12,
z13: z13,
z21: z21,
z22: z22,
z23: z23,
z31: z31,
z32: z32,
z33: z33,
zmol: zmol,
zmos: zmos
};
}
/*-----------------------------------------------------------------------------
*
* procedure dsinit
*
* this procedure provides deep space contributions to mean motion dot due
* to geopotential resonance with half day and one day orbits.
*
* author : david vallado 719-573-2600 28 jun 2005
*
* inputs :
* cosim, sinim-
* emsq - eccentricity squared
* argpo - argument of perigee
* s1, s2, s3, s4, s5 -
* ss1, ss2, ss3, ss4, ss5 -
* sz1, sz3, sz11, sz13, sz21, sz23, sz31, sz33 -
* t - time
* tc -
* gsto - greenwich sidereal time rad
* mo - mean anomaly
* mdot - mean anomaly dot (rate)
* no - mean motion
* nodeo - right ascension of ascending node
* nodedot - right ascension of ascending node dot (rate)
* xpidot -
* z1, z3, z11, z13, z21, z23, z31, z33 -
* eccm - eccentricity
* argpm - argument of perigee
* inclm - inclination
* mm - mean anomaly
* xn - mean motion
* nodem - right ascension of ascending node
*
* outputs :
* em - eccentricity
* argpm - argument of perigee
* inclm - inclination
* mm - mean anomaly
* nm - mean motion
* nodem - right ascension of ascending node
* irez - flag for resonance 0-none, 1-one day, 2-half day
* atime -
* d2201, d2211, d3210, d3222, d4410, d4422, d5220, d5232, d5421, d5433 -
* dedt -
* didt -
* dmdt -
* dndt -
* dnodt -
* domdt -
* del1, del2, del3 -
* ses , sghl , sghs , sgs , shl , shs , sis , sls
* theta -
* xfact -
* xlamo -
* xli -
* xni
*
* locals :
* ainv2 -
* aonv -
* cosisq -
* eoc -
* 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 -
* temp -
* temp1 -
* theta -
* xno2 -
*
* coupling :
* getgravconst
*
* references :
* hoots, roehrich, norad spacetrack report #3 1980
* hoots, norad spacetrack report #6 1986
* hoots, schumacher and glover 2004
* vallado, crawford, hujsak, kelso 2006
----------------------------------------------------------------------------*/
function dsinit(options) {
var cosim = options.cosim,
argpo = options.argpo,
s1 = options.s1,
s2 = options.s2,
s3 = options.s3,
s4 = options.s4,
s5 = options.s5,
sinim = options.sinim,
ss1 = options.ss1,
ss2 = options.ss2,
ss3 = options.ss3,
ss4 = options.ss4,
ss5 = options.ss5,
sz1 = options.sz1,
sz3 = options.sz3,
sz11 = options.sz11,
sz13 = options.sz13,
sz21 = options.sz21,
sz23 = options.sz23,
sz31 = options.sz31,
sz33 = options.sz33,
t = options.t,
tc = options.tc,
gsto = options.gsto,
mo = options.mo,
mdot = options.mdot,
no = options.no,
nodeo = options.nodeo,
nodedot = options.nodedot,
xpidot = options.xpidot,
z1 = options.z1,
z3 = options.z3,
z11 = options.z11,
z13 = options.z13,
z21 = options.z21,
z23 = options.z23,
z31 = options.z31,
z33 = options.z33,
ecco = options.ecco,
eccsq = options.eccsq;
var emsq = options.emsq,
em = options.em,
argpm = options.argpm,
inclm = options.inclm,
mm = options.mm,
nm = options.nm,
nodem = options.nodem,
irez = options.irez,
atime = options.atime,
d2201 = options.d2201,
d2211 = options.d2211,
d3210 = options.d3210,
d3222 = options.d3222,
d4410 = options.d4410,
d4422 = options.d4422,
d5220 = options.d5220,
d5232 = options.d5232,
d5421 = options.d5421,
d5433 = options.d5433,
dedt = options.dedt,