jspredict-dc
Version:
Satellite propagation and visibility utilities built on satellite.js.
1 lines • 251 kB
Source Map (JSON)
{"version":3,"file":"jspredict-dc.esm.mjs","sources":["../src/runtime.js","../node_modules/satellite.js/dist/satellite.es.js","../src/utils.js","../src/constants.js","../src/core.js","../src/index.js?commonjs-entry","../src/index.js"],"sourcesContent":["// 这里保存的是库级别的可变运行时状态,只用于控制迭代次数和调试日志。\r\nmodule.exports = {\r\n printIntervalInfo: false,\r\n maxIterations: 99999,\r\n};\r\n","var pi = Math.PI;\nvar twoPi = pi * 2;\nvar deg2rad = pi / 180.0;\nvar rad2deg = 180 / pi;\nvar minutesPerDay = 1440.0;\nvar mu = 398600.8; // in km3 / s2\nvar earthRadius = 6378.135; // in km\nvar xke = 60.0 / Math.sqrt(earthRadius * earthRadius * earthRadius / mu);\nvar vkmpersec = earthRadius * xke / 60.0;\nvar tumin = 1.0 / xke;\nvar j2 = 0.001082616;\nvar j3 = -0.00000253881;\nvar j4 = -0.00000165597;\nvar j3oj2 = j3 / j2;\nvar x2o3 = 2.0 / 3.0;\nvar xpdotp = 1440.0 / (2.0 * pi); // 229.1831180523293;\n\nvar constants = /*#__PURE__*/Object.freeze({\n __proto__: null,\n deg2rad: deg2rad,\n earthRadius: earthRadius,\n j2: j2,\n j3: j3,\n j3oj2: j3oj2,\n j4: j4,\n minutesPerDay: minutesPerDay,\n mu: mu,\n pi: pi,\n rad2deg: rad2deg,\n tumin: tumin,\n twoPi: twoPi,\n vkmpersec: vkmpersec,\n x2o3: x2o3,\n xke: xke,\n xpdotp: xpdotp\n});\n\n/* -----------------------------------------------------------------------------\n *\n * procedure days2mdhms\n *\n * this procedure converts the day of the year, days, to the equivalent month\n * day, hour, minute and second.\n *\n * algorithm : set up array for the number of days per month\n * find leap year - use 1900 because 2000 is a leap year\n * loop through a temp value while the value is < the days\n * perform int conversions to the correct day and month\n * convert remainder into h m s using type conversions\n *\n * author : david vallado 719-573-2600 1 mar 2001\n *\n * inputs description range / units\n * year - year 1900 .. 2100\n * days - julian day of the year 0.0 .. 366.0\n *\n * outputs :\n * mon - month 1 .. 12\n * day - day 1 .. 28,29,30,31\n * hr - hour 0 .. 23\n * min - minute 0 .. 59\n * sec - second 0.0 .. 59.999\n *\n * locals :\n * dayofyr - day of year\n * temp - temporary extended values\n * inttemp - temporary int value\n * i - index\n * lmonth[12] - int array containing the number of days per month\n *\n * coupling :\n * none.\n * --------------------------------------------------------------------------- */\nfunction days2mdhms(year, days) {\n var lmonth = [31, year % 4 === 0 ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\n var dayofyr = Math.floor(days);\n // ----------------- find month and day of month ----------------\n var i = 1;\n var inttemp = 0;\n // i starts from 1 so no null check is needed\n while (dayofyr > inttemp + lmonth[i - 1] && i < 12) {\n inttemp += lmonth[i - 1];\n i += 1;\n }\n var mon = i;\n var day = dayofyr - inttemp;\n // ----------------- find hours minutes and seconds -------------\n var temp = (days - dayofyr) * 24.0;\n var hr = Math.floor(temp);\n temp = (temp - hr) * 60.0;\n var minute = Math.floor(temp);\n var sec = (temp - minute) * 60.0;\n return {\n mon: mon,\n day: day,\n hr: hr,\n minute: minute,\n sec: sec\n };\n}\n/* -----------------------------------------------------------------------------\n *\n * procedure jday\n *\n * this procedure finds the julian date given the year, month, day, and time.\n * the julian date is defined by each elapsed day since noon, jan 1, 4713 bc.\n *\n * algorithm : calculate the answer in one step for efficiency\n *\n * author : david vallado 719-573-2600 1 mar 2001\n *\n * inputs description range / units\n * year - year 1900 .. 2100\n * mon - month 1 .. 12\n * day - day 1 .. 28,29,30,31\n * hr - universal time hour 0 .. 23\n * min - universal time min 0 .. 59\n * sec - universal time sec 0.0 .. 59.999\n *\n * outputs :\n * jd - julian date days from 4713 bc\n *\n * locals :\n * none.\n *\n * coupling :\n * none.\n *\n * references :\n * vallado 2007, 189, alg 14, ex 3-14\n *\n * --------------------------------------------------------------------------- */\nfunction jdayInternal(year, mon, day, hr, minute, sec) {\n var msec = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 0;\n 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\n // # - 0.5*sgn(100.0*year + mon - 190002.5) + 0.5;\n ;\n}\nfunction jday(yearOrDate, mon, day, hr, minute, sec) {\n var msec = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 0;\n if (yearOrDate instanceof Date) {\n var date = yearOrDate;\n return jdayInternal(date.getUTCFullYear(), date.getUTCMonth() + 1,\n // Note, this function requires months in range 1-12.\n date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds(), date.getUTCMilliseconds());\n }\n return jdayInternal(yearOrDate, mon, day, hr, minute, sec, msec);\n}\nfunction invjday(jd, asArray) {\n // --------------- find year and days of the year -\n var temp = jd - 2415019.5;\n var tu = temp / 365.25;\n var year = 1900 + Math.floor(tu);\n var leapyrs = Math.floor((year - 1901) * 0.25);\n // optional nudge by 8.64x10-7 sec to get even outputs\n var days = temp - ((year - 1900) * 365.0 + leapyrs) + 0.00000000001;\n // ------------ check for case of beginning of a year -----------\n if (days < 1.0) {\n year -= 1;\n leapyrs = Math.floor((year - 1901) * 0.25);\n days = temp - ((year - 1900) * 365.0 + leapyrs);\n }\n // ----------------- find remaing data -------------------------\n var mdhms = days2mdhms(year, days);\n var mon = mdhms.mon,\n day = mdhms.day,\n hr = mdhms.hr,\n minute = mdhms.minute;\n var sec = mdhms.sec - 0.00000086400;\n if (asArray) {\n return [year, mon, day, hr, minute, Math.floor(sec)];\n }\n return new Date(Date.UTC(year, mon - 1, day, hr, minute, Math.floor(sec)));\n}\n\n/* -----------------------------------------------------------------------------\n *\n * procedure dpper\n *\n * this procedure provides deep space long period periodic contributions\n * to the mean elements. by design, these periodics are zero at epoch.\n * this used to be dscom which included initialization, but it's really a\n * recurring function.\n *\n * author : david vallado 719-573-2600 28 jun 2005\n *\n * inputs :\n * e3 -\n * ee2 -\n * peo -\n * pgho -\n * pho -\n * pinco -\n * plo -\n * se2 , se3 , sgh2, sgh3, sgh4, sh2, sh3, si2, si3, sl2, sl3, sl4 -\n * t -\n * xh2, xh3, xi2, xi3, xl2, xl3, xl4 -\n * zmol -\n * zmos -\n * ep - eccentricity 0.0 - 1.0\n * inclo - inclination - needed for lyddane modification\n * nodep - right ascension of ascending node\n * argpp - argument of perigee\n * mp - mean anomaly\n *\n * outputs :\n * ep - eccentricity 0.0 - 1.0\n * inclp - inclination\n * nodep - right ascension of ascending node\n * argpp - argument of perigee\n * mp - mean anomaly\n *\n * locals :\n * alfdp -\n * betdp -\n * cosip , sinip , cosop , sinop ,\n * dalf -\n * dbet -\n * dls -\n * f2, f3 -\n * pe -\n * pgh -\n * ph -\n * pinc -\n * pl -\n * sel , ses , sghl , sghs , shl , shs , sil , sinzf , sis ,\n * sll , sls\n * xls -\n * xnoh -\n * zf -\n * zm -\n *\n * coupling :\n * none.\n *\n * references :\n * hoots, roehrich, norad spacetrack report #3 1980\n * hoots, norad spacetrack report #6 1986\n * hoots, schumacher and glover 2004\n * vallado, crawford, hujsak, kelso 2006\n ----------------------------------------------------------------------------*/\nfunction dpper(satrec, options) {\n var e3 = satrec.e3,\n ee2 = satrec.ee2,\n peo = satrec.peo,\n pgho = satrec.pgho,\n pho = satrec.pho,\n pinco = satrec.pinco,\n plo = satrec.plo,\n se2 = satrec.se2,\n se3 = satrec.se3,\n sgh2 = satrec.sgh2,\n sgh3 = satrec.sgh3,\n sgh4 = satrec.sgh4,\n sh2 = satrec.sh2,\n sh3 = satrec.sh3,\n si2 = satrec.si2,\n si3 = satrec.si3,\n sl2 = satrec.sl2,\n sl3 = satrec.sl3,\n sl4 = satrec.sl4,\n t = satrec.t,\n xgh2 = satrec.xgh2,\n xgh3 = satrec.xgh3,\n xgh4 = satrec.xgh4,\n xh2 = satrec.xh2,\n xh3 = satrec.xh3,\n xi2 = satrec.xi2,\n xi3 = satrec.xi3,\n xl2 = satrec.xl2,\n xl3 = satrec.xl3,\n xl4 = satrec.xl4,\n zmol = satrec.zmol,\n zmos = satrec.zmos;\n var init = options.init,\n opsmode = options.opsmode;\n var ep = options.ep,\n inclp = options.inclp,\n nodep = options.nodep,\n argpp = options.argpp,\n mp = options.mp;\n // Copy satellite attributes into local variables for convenience\n // and symmetry in writing formulae.\n var alfdp;\n var betdp;\n var cosip;\n var sinip;\n var cosop;\n var sinop;\n var dalf;\n var dbet;\n var dls;\n var f2;\n var f3;\n var pe;\n var pgh;\n var ph;\n var pinc;\n var pl;\n var sinzf;\n var xls;\n var xnoh;\n var zf;\n var zm;\n // ---------------------- constants -----------------------------\n var zns = 1.19459e-5;\n var zes = 0.01675;\n var znl = 1.5835218e-4;\n var zel = 0.05490;\n // --------------- calculate time varying periodics -----------\n zm = zmos + zns * t;\n // be sure that the initial call has time set to zero\n if (init === 'y') {\n zm = zmos;\n }\n zf = zm + 2.0 * zes * Math.sin(zm);\n sinzf = Math.sin(zf);\n f2 = 0.5 * sinzf * sinzf - 0.25;\n f3 = -0.5 * sinzf * Math.cos(zf);\n var ses = se2 * f2 + se3 * f3;\n var sis = si2 * f2 + si3 * f3;\n var sls = sl2 * f2 + sl3 * f3 + sl4 * sinzf;\n var sghs = sgh2 * f2 + sgh3 * f3 + sgh4 * sinzf;\n var shs = sh2 * f2 + sh3 * f3;\n zm = zmol + znl * t;\n if (init === 'y') {\n zm = zmol;\n }\n zf = zm + 2.0 * zel * Math.sin(zm);\n sinzf = Math.sin(zf);\n f2 = 0.5 * sinzf * sinzf - 0.25;\n f3 = -0.5 * sinzf * Math.cos(zf);\n var sel = ee2 * f2 + e3 * f3;\n var sil = xi2 * f2 + xi3 * f3;\n var sll = xl2 * f2 + xl3 * f3 + xl4 * sinzf;\n var sghl = xgh2 * f2 + xgh3 * f3 + xgh4 * sinzf;\n var shll = xh2 * f2 + xh3 * f3;\n pe = ses + sel;\n pinc = sis + sil;\n pl = sls + sll;\n pgh = sghs + sghl;\n ph = shs + shll;\n if (init === 'n') {\n pe -= peo;\n pinc -= pinco;\n pl -= plo;\n pgh -= pgho;\n ph -= pho;\n inclp += pinc;\n ep += pe;\n sinip = Math.sin(inclp);\n cosip = Math.cos(inclp);\n /* ----------------- apply periodics directly ------------ */\n // sgp4fix for lyddane choice\n // strn3 used original inclination - this is technically feasible\n // gsfc used perturbed inclination - also technically feasible\n // probably best to readjust the 0.2 limit value and limit discontinuity\n // 0.2 rad = 11.45916 deg\n // use next line for original strn3 approach and original inclination\n // if (inclo >= 0.2)\n // use next line for gsfc version and perturbed inclination\n if (inclp >= 0.2) {\n ph /= sinip;\n pgh -= cosip * ph;\n argpp += pgh;\n nodep += ph;\n mp += pl;\n } else {\n // ---- apply periodics with lyddane modification ----\n sinop = Math.sin(nodep);\n cosop = Math.cos(nodep);\n alfdp = sinip * sinop;\n betdp = sinip * cosop;\n dalf = ph * cosop + pinc * cosip * sinop;\n dbet = -ph * sinop + pinc * cosip * cosop;\n alfdp += dalf;\n betdp += dbet;\n nodep %= twoPi;\n // sgp4fix for afspc written intrinsic functions\n // nodep used without a trigonometric function ahead\n if (nodep < 0.0 && opsmode === 'a') {\n nodep += twoPi;\n }\n xls = mp + argpp + cosip * nodep;\n dls = pl + pgh - pinc * nodep * sinip;\n xls += dls;\n xnoh = nodep;\n nodep = Math.atan2(alfdp, betdp);\n // sgp4fix for afspc written intrinsic functions\n // nodep used without a trigonometric function ahead\n if (nodep < 0.0 && opsmode === 'a') {\n nodep += twoPi;\n }\n if (Math.abs(xnoh - nodep) > pi) {\n if (nodep < xnoh) {\n nodep += twoPi;\n } else {\n nodep -= twoPi;\n }\n }\n mp += pl;\n argpp = xls - mp - cosip * nodep;\n }\n }\n return {\n ep: ep,\n inclp: inclp,\n nodep: nodep,\n argpp: argpp,\n mp: mp\n };\n}\n\n/*-----------------------------------------------------------------------------\n *\n * procedure dscom\n *\n * this procedure provides deep space common items used by both the secular\n * and periodics subroutines. input is provided as shown. this routine\n * used to be called dpper, but the functions inside weren't well organized.\n *\n * author : david vallado 719-573-2600 28 jun 2005\n *\n * inputs :\n * epoch -\n * ep - eccentricity\n * argpp - argument of perigee\n * tc -\n * inclp - inclination\n * nodep - right ascension of ascending node\n * np - mean motion\n *\n * outputs :\n * sinim , cosim , sinomm , cosomm , snodm , cnodm\n * day -\n * e3 -\n * ee2 -\n * em - eccentricity\n * emsq - eccentricity squared\n * gam -\n * peo -\n * pgho -\n * pho -\n * pinco -\n * plo -\n * rtemsq -\n * se2, se3 -\n * sgh2, sgh3, sgh4 -\n * sh2, sh3, si2, si3, sl2, sl3, sl4 -\n * s1, s2, s3, s4, s5, s6, s7 -\n * ss1, ss2, ss3, ss4, ss5, ss6, ss7, sz1, sz2, sz3 -\n * sz11, sz12, sz13, sz21, sz22, sz23, sz31, sz32, sz33 -\n * xgh2, xgh3, xgh4, xh2, xh3, xi2, xi3, xl2, xl3, xl4 -\n * nm - mean motion\n * z1, z2, z3, z11, z12, z13, z21, z22, z23, z31, z32, z33 -\n * zmol -\n * zmos -\n *\n * locals :\n * a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 -\n * betasq -\n * cc -\n * ctem, stem -\n * x1, x2, x3, x4, x5, x6, x7, x8 -\n * xnodce -\n * xnoi -\n * zcosg , zsing , zcosgl , zsingl , zcosh , zsinh , zcoshl , zsinhl ,\n * zcosi , zsini , zcosil , zsinil ,\n * zx -\n * zy -\n *\n * coupling :\n * none.\n *\n * references :\n * hoots, roehrich, norad spacetrack report #3 1980\n * hoots, norad spacetrack report #6 1986\n * hoots, schumacher and glover 2004\n * vallado, crawford, hujsak, kelso 2006\n ----------------------------------------------------------------------------*/\nfunction dscom(options) {\n var epoch = options.epoch,\n ep = options.ep,\n argpp = options.argpp,\n tc = options.tc,\n inclp = options.inclp,\n nodep = options.nodep,\n np = options.np;\n var a1;\n var a2;\n var a3;\n var a4;\n var a5;\n var a6;\n var a7;\n var a8;\n var a9;\n var a10;\n var cc;\n var x1;\n var x2;\n var x3;\n var x4;\n var x5;\n var x6;\n var x7;\n var x8;\n var zcosg;\n var zsing;\n var zcosh;\n var zsinh;\n var zcosi;\n var zsini;\n var ss1;\n var ss2;\n var ss3;\n var ss4;\n var ss5;\n var ss6;\n var ss7;\n var sz1;\n var sz2;\n var sz3;\n var sz11;\n var sz12;\n var sz13;\n var sz21;\n var sz22;\n var sz23;\n var sz31;\n var sz32;\n var sz33;\n var s1;\n var s2;\n var s3;\n var s4;\n var s5;\n var s6;\n var s7;\n var z1;\n var z2;\n var z3;\n var z11;\n var z12;\n var z13;\n var z21;\n var z22;\n var z23;\n var z31;\n var z32;\n var z33;\n // -------------------------- constants -------------------------\n var zes = 0.01675;\n var zel = 0.05490;\n var c1ss = 2.9864797e-6;\n var c1l = 4.7968065e-7;\n var zsinis = 0.39785416;\n var zcosis = 0.91744867;\n var zcosgs = 0.1945905;\n var zsings = -0.98088458;\n // --------------------- local variables ------------------------\n var nm = np;\n var em = ep;\n var snodm = Math.sin(nodep);\n var cnodm = Math.cos(nodep);\n var sinomm = Math.sin(argpp);\n var cosomm = Math.cos(argpp);\n var sinim = Math.sin(inclp);\n var cosim = Math.cos(inclp);\n var emsq = em * em;\n var betasq = 1.0 - emsq;\n var rtemsq = Math.sqrt(betasq);\n // ----------------- initialize lunar solar terms ---------------\n var peo = 0.0;\n var pinco = 0.0;\n var plo = 0.0;\n var pgho = 0.0;\n var pho = 0.0;\n var day = epoch + 18261.5 + tc / 1440.0;\n var xnodce = (4.5236020 - 9.2422029e-4 * day) % twoPi;\n var stem = Math.sin(xnodce);\n var ctem = Math.cos(xnodce);\n var zcosil = 0.91375164 - 0.03568096 * ctem;\n var zsinil = Math.sqrt(1.0 - zcosil * zcosil);\n var zsinhl = 0.089683511 * stem / zsinil;\n var zcoshl = Math.sqrt(1.0 - zsinhl * zsinhl);\n var gam = 5.8351514 + 0.0019443680 * day;\n var zx = 0.39785416 * stem / zsinil;\n var zy = zcoshl * ctem + 0.91744867 * zsinhl * stem;\n zx = Math.atan2(zx, zy);\n zx += gam - xnodce;\n var zcosgl = Math.cos(zx);\n var zsingl = Math.sin(zx);\n // ------------------------- do solar terms ---------------------\n zcosg = zcosgs;\n zsing = zsings;\n zcosi = zcosis;\n zsini = zsinis;\n zcosh = cnodm;\n zsinh = snodm;\n cc = c1ss;\n var xnoi = 1.0 / nm;\n var lsflg = 0;\n while (lsflg < 2) {\n lsflg += 1;\n a1 = zcosg * zcosh + zsing * zcosi * zsinh;\n a3 = -zsing * zcosh + zcosg * zcosi * zsinh;\n a7 = -zcosg * zsinh + zsing * zcosi * zcosh;\n a8 = zsing * zsini;\n a9 = zsing * zsinh + zcosg * zcosi * zcosh;\n a10 = zcosg * zsini;\n a2 = cosim * a7 + sinim * a8;\n a4 = cosim * a9 + sinim * a10;\n a5 = -sinim * a7 + cosim * a8;\n a6 = -sinim * a9 + cosim * a10;\n x1 = a1 * cosomm + a2 * sinomm;\n x2 = a3 * cosomm + a4 * sinomm;\n x3 = -a1 * sinomm + a2 * cosomm;\n x4 = -a3 * sinomm + a4 * cosomm;\n x5 = a5 * sinomm;\n x6 = a6 * sinomm;\n x7 = a5 * cosomm;\n x8 = a6 * cosomm;\n z31 = 12.0 * x1 * x1 - 3.0 * x3 * x3;\n z32 = 24.0 * x1 * x2 - 6.0 * x3 * x4;\n z33 = 12.0 * x2 * x2 - 3.0 * x4 * x4;\n z1 = 3.0 * (a1 * a1 + a2 * a2) + z31 * emsq;\n z2 = 6.0 * (a1 * a3 + a2 * a4) + z32 * emsq;\n z3 = 3.0 * (a3 * a3 + a4 * a4) + z33 * emsq;\n z11 = -6.0 * a1 * a5 + emsq * (-24.0 * x1 * x7 - 6.0 * x3 * x5);\n z12 = -6.0 * (a1 * a6 + a3 * a5) + emsq * (-24.0 * (x2 * x7 + x1 * x8) + -6.0 * (x3 * x6 + x4 * x5));\n z13 = -6.0 * a3 * a6 + emsq * (-24.0 * x2 * x8 - 6.0 * x4 * x6);\n z21 = 6.0 * a2 * a5 + emsq * (24.0 * x1 * x5 - 6.0 * x3 * x7);\n z22 = 6.0 * (a4 * a5 + a2 * a6) + emsq * (24.0 * (x2 * x5 + x1 * x6) - 6.0 * (x4 * x7 + x3 * x8));\n z23 = 6.0 * a4 * a6 + emsq * (24.0 * x2 * x6 - 6.0 * x4 * x8);\n z1 = z1 + z1 + betasq * z31;\n z2 = z2 + z2 + betasq * z32;\n z3 = z3 + z3 + betasq * z33;\n s3 = cc * xnoi;\n s2 = -0.5 * s3 / rtemsq;\n s4 = s3 * rtemsq;\n s1 = -15.0 * em * s4;\n s5 = x1 * x3 + x2 * x4;\n s6 = x2 * x3 + x1 * x4;\n s7 = x2 * x4 - x1 * x3;\n // ----------------------- do lunar terms -------------------\n if (lsflg === 1) {\n ss1 = s1;\n ss2 = s2;\n ss3 = s3;\n ss4 = s4;\n ss5 = s5;\n ss6 = s6;\n ss7 = s7;\n sz1 = z1;\n sz2 = z2;\n sz3 = z3;\n sz11 = z11;\n sz12 = z12;\n sz13 = z13;\n sz21 = z21;\n sz22 = z22;\n sz23 = z23;\n sz31 = z31;\n sz32 = z32;\n sz33 = z33;\n zcosg = zcosgl;\n zsing = zsingl;\n zcosi = zcosil;\n zsini = zsinil;\n zcosh = zcoshl * cnodm + zsinhl * snodm;\n zsinh = snodm * zcoshl - cnodm * zsinhl;\n cc = c1l;\n }\n }\n var zmol = (4.7199672 + (0.22997150 * day - gam)) % twoPi;\n var zmos = (6.2565837 + 0.017201977 * day) % twoPi;\n // ------------------------ do solar terms ----------------------\n var se2 = 2.0 * ss1 * ss6;\n var se3 = 2.0 * ss1 * ss7;\n var si2 = 2.0 * ss2 * sz12;\n var si3 = 2.0 * ss2 * (sz13 - sz11);\n var sl2 = -2.0 * ss3 * sz2;\n var sl3 = -2.0 * ss3 * (sz3 - sz1);\n var sl4 = -2.0 * ss3 * (-21.0 - 9.0 * emsq) * zes;\n var sgh2 = 2.0 * ss4 * sz32;\n var sgh3 = 2.0 * ss4 * (sz33 - sz31);\n var sgh4 = -18.0 * ss4 * zes;\n var sh2 = -2.0 * ss2 * sz22;\n var sh3 = -2.0 * ss2 * (sz23 - sz21);\n // ------------------------ do lunar terms ----------------------\n var ee2 = 2.0 * s1 * s6;\n var e3 = 2.0 * s1 * s7;\n var xi2 = 2.0 * s2 * z12;\n var xi3 = 2.0 * s2 * (z13 - z11);\n var xl2 = -2.0 * s3 * z2;\n var xl3 = -2.0 * s3 * (z3 - z1);\n var xl4 = -2.0 * s3 * (-21.0 - 9.0 * emsq) * zel;\n var xgh2 = 2.0 * s4 * z32;\n var xgh3 = 2.0 * s4 * (z33 - z31);\n var xgh4 = -18.0 * s4 * zel;\n var xh2 = -2.0 * s2 * z22;\n var xh3 = -2.0 * s2 * (z23 - z21);\n return {\n snodm: snodm,\n cnodm: cnodm,\n sinim: sinim,\n cosim: cosim,\n sinomm: sinomm,\n cosomm: cosomm,\n day: day,\n e3: e3,\n ee2: ee2,\n em: em,\n emsq: emsq,\n gam: gam,\n peo: peo,\n pgho: pgho,\n pho: pho,\n pinco: pinco,\n plo: plo,\n rtemsq: rtemsq,\n se2: se2,\n se3: se3,\n sgh2: sgh2,\n sgh3: sgh3,\n sgh4: sgh4,\n sh2: sh2,\n sh3: sh3,\n si2: si2,\n si3: si3,\n sl2: sl2,\n sl3: sl3,\n sl4: sl4,\n s1: s1,\n s2: s2,\n s3: s3,\n s4: s4,\n s5: s5,\n s6: s6,\n s7: s7,\n ss1: ss1,\n ss2: ss2,\n ss3: ss3,\n ss4: ss4,\n ss5: ss5,\n ss6: ss6,\n ss7: ss7,\n sz1: sz1,\n sz2: sz2,\n sz3: sz3,\n sz11: sz11,\n sz12: sz12,\n sz13: sz13,\n sz21: sz21,\n sz22: sz22,\n sz23: sz23,\n sz31: sz31,\n sz32: sz32,\n sz33: sz33,\n xgh2: xgh2,\n xgh3: xgh3,\n xgh4: xgh4,\n xh2: xh2,\n xh3: xh3,\n xi2: xi2,\n xi3: xi3,\n xl2: xl2,\n xl3: xl3,\n xl4: xl4,\n nm: nm,\n z1: z1,\n z2: z2,\n z3: z3,\n z11: z11,\n z12: z12,\n z13: z13,\n z21: z21,\n z22: z22,\n z23: z23,\n z31: z31,\n z32: z32,\n z33: z33,\n zmol: zmol,\n zmos: zmos\n };\n}\n\n/*-----------------------------------------------------------------------------\n *\n * procedure dsinit\n *\n * this procedure provides deep space contributions to mean motion dot due\n * to geopotential resonance with half day and one day orbits.\n *\n * author : david vallado 719-573-2600 28 jun 2005\n *\n * inputs :\n * cosim, sinim-\n * emsq - eccentricity squared\n * argpo - argument of perigee\n * s1, s2, s3, s4, s5 -\n * ss1, ss2, ss3, ss4, ss5 -\n * sz1, sz3, sz11, sz13, sz21, sz23, sz31, sz33 -\n * t - time\n * tc -\n * gsto - greenwich sidereal time rad\n * mo - mean anomaly\n * mdot - mean anomaly dot (rate)\n * no - mean motion\n * nodeo - right ascension of ascending node\n * nodedot - right ascension of ascending node dot (rate)\n * xpidot -\n * z1, z3, z11, z13, z21, z23, z31, z33 -\n * eccm - eccentricity\n * argpm - argument of perigee\n * inclm - inclination\n * mm - mean anomaly\n * xn - mean motion\n * nodem - right ascension of ascending node\n *\n * outputs :\n * em - eccentricity\n * argpm - argument of perigee\n * inclm - inclination\n * mm - mean anomaly\n * nm - mean motion\n * nodem - right ascension of ascending node\n * irez - flag for resonance 0-none, 1-one day, 2-half day\n * atime -\n * d2201, d2211, d3210, d3222, d4410, d4422, d5220, d5232, d5421, d5433 -\n * dedt -\n * didt -\n * dmdt -\n * dndt -\n * dnodt -\n * domdt -\n * del1, del2, del3 -\n * ses , sghl , sghs , sgs , shl , shs , sis , sls\n * theta -\n * xfact -\n * xlamo -\n * xli -\n * xni\n *\n * locals :\n * ainv2 -\n * aonv -\n * cosisq -\n * eoc -\n * f220, f221, f311, f321, f322, f330, f441, f442, f522, f523, f542, f543 -\n * g200, g201, g211, g300, g310, g322, g410, g422, g520, g521, g532, g533 -\n * sini2 -\n * temp -\n * temp1 -\n * theta -\n * xno2 -\n *\n * coupling :\n * getgravconst\n *\n * references :\n * hoots, roehrich, norad spacetrack report #3 1980\n * hoots, norad spacetrack report #6 1986\n * hoots, schumacher and glover 2004\n * vallado, crawford, hujsak, kelso 2006\n ----------------------------------------------------------------------------*/\nfunction dsinit(options) {\n var cosim = options.cosim,\n argpo = options.argpo,\n s1 = options.s1,\n s2 = options.s2,\n s3 = options.s3,\n s4 = options.s4,\n s5 = options.s5,\n sinim = options.sinim,\n ss1 = options.ss1,\n ss2 = options.ss2,\n ss3 = options.ss3,\n ss4 = options.ss4,\n ss5 = options.ss5,\n sz1 = options.sz1,\n sz3 = options.sz3,\n sz11 = options.sz11,\n sz13 = options.sz13,\n sz21 = options.sz21,\n sz23 = options.sz23,\n sz31 = options.sz31,\n sz33 = options.sz33,\n t = options.t,\n tc = options.tc,\n gsto = options.gsto,\n mo = options.mo,\n mdot = options.mdot,\n no = options.no,\n nodeo = options.nodeo,\n nodedot = options.nodedot,\n xpidot = options.xpidot,\n z1 = options.z1,\n z3 = options.z3,\n z11 = options.z11,\n z13 = options.z13,\n z21 = options.z21,\n z23 = options.z23,\n z31 = options.z31,\n z33 = options.z33,\n ecco = options.ecco,\n eccsq = options.eccsq;\n var emsq = options.emsq,\n em = options.em,\n argpm = options.argpm,\n inclm = options.inclm,\n mm = options.mm,\n nm = options.nm,\n nodem = options.nodem,\n irez = options.irez,\n atime = options.atime,\n d2201 = options.d2201,\n d2211 = options.d2211,\n d3210 = options.d3210,\n d3222 = options.d3222,\n d4410 = options.d4410,\n d4422 = options.d4422,\n d5220 = options.d5220,\n d5232 = options.d5232,\n d5421 = options.d5421,\n d5433 = options.d5433,\n dedt = options.dedt,\n didt = options.didt,\n dmdt = options.dmdt,\n dnodt = options.dnodt,\n domdt = options.domdt,\n del1 = options.del1,\n del2 = options.del2,\n del3 = options.del3,\n xfact = options.xfact,\n xlamo = options.xlamo,\n xli = options.xli,\n xni = options.xni;\n var f220;\n var f221;\n var f311;\n var f321;\n var f322;\n var f330;\n var f441;\n var f442;\n var f522;\n var f523;\n var f542;\n var f543;\n var g200;\n var g201;\n var g211;\n var g300;\n var g310;\n var g322;\n var g410;\n var g422;\n var g520;\n var g521;\n var g532;\n var g533;\n var sini2;\n var temp;\n var temp1;\n var xno2;\n var ainv2;\n var aonv;\n var cosisq;\n var eoc;\n var q22 = 1.7891679e-6;\n var q31 = 2.1460748e-6;\n var q33 = 2.2123015e-7;\n var root22 = 1.7891679e-6;\n var root44 = 7.3636953e-9;\n var root54 = 2.1765803e-9;\n // eslint-disable-next-line no-loss-of-precision\n var rptim = 4.37526908801129966e-3; // equates to 7.29211514668855e-5 rad/sec\n var root32 = 3.7393792e-7;\n var root52 = 1.1428639e-7;\n var znl = 1.5835218e-4;\n var zns = 1.19459e-5;\n // -------------------- deep space initialization ------------\n irez = 0;\n if (nm < 0.0052359877 && nm > 0.0034906585) {\n irez = 1;\n }\n if (nm >= 8.26e-3 && nm <= 9.24e-3 && em >= 0.5) {\n irez = 2;\n }\n // ------------------------ do solar terms -------------------\n var ses = ss1 * zns * ss5;\n var sis = ss2 * zns * (sz11 + sz13);\n var sls = -zns * ss3 * (sz1 + sz3 - 14.0 - 6.0 * emsq);\n var sghs = ss4 * zns * (sz31 + sz33 - 6.0);\n var shs = -zns * ss2 * (sz21 + sz23);\n // sgp4fix for 180 deg incl\n if (inclm < 5.2359877e-2 || inclm > pi - 5.2359877e-2) {\n shs = 0.0;\n }\n if (sinim !== 0.0) {\n shs /= sinim;\n }\n var sgs = sghs - cosim * shs;\n // ------------------------- do lunar terms ------------------\n dedt = ses + s1 * znl * s5;\n didt = sis + s2 * znl * (z11 + z13);\n dmdt = sls - znl * s3 * (z1 + z3 - 14.0 - 6.0 * emsq);\n var sghl = s4 * znl * (z31 + z33 - 6.0);\n var shll = -znl * s2 * (z21 + z23);\n // sgp4fix for 180 deg incl\n if (inclm < 5.2359877e-2 || inclm > pi - 5.2359877e-2) {\n shll = 0.0;\n }\n domdt = sgs + sghl;\n dnodt = shs;\n if (sinim !== 0.0) {\n domdt -= cosim / sinim * shll;\n dnodt += shll / sinim;\n }\n // ----------- calculate deep space resonance effects --------\n var dndt = 0.0;\n var theta = (gsto + tc * rptim) % twoPi;\n em += dedt * t;\n inclm += didt * t;\n argpm += domdt * t;\n nodem += dnodt * t;\n mm += dmdt * t;\n // sgp4fix for negative inclinations\n // the following if statement should be commented out\n // if (inclm < 0.0)\n // {\n // inclm = -inclm;\n // argpm = argpm - pi;\n // nodem = nodem + pi;\n // }\n // -------------- initialize the resonance terms -------------\n if (irez !== 0) {\n aonv = Math.pow(nm / xke, x2o3);\n // ---------- geopotential resonance for 12 hour orbits ------\n if (irez === 2) {\n cosisq = cosim * cosim;\n var emo = em;\n em = ecco;\n var emsqo = emsq;\n emsq = eccsq;\n eoc = em * emsq;\n g201 = -0.306 - (em - 0.64) * 0.440;\n if (em <= 0.65) {\n g211 = 3.616 - 13.2470 * em + 16.2900 * emsq;\n g310 = -19.302 + 117.3900 * em - 228.4190 * emsq + 156.5910 * eoc;\n g322 = -18.9068 + 109.7927 * em - 214.6334 * emsq + 146.5816 * eoc;\n g410 = -41.122 + 242.6940 * em - 471.0940 * emsq + 313.9530 * eoc;\n g422 = -146.407 + 841.8800 * em - 1629.014 * emsq + 1083.4350 * eoc;\n g520 = -532.114 + 3017.977 * em - 5740.032 * emsq + 3708.2760 * eoc;\n } else {\n g211 = -72.099 + 331.819 * em - 508.738 * emsq + 266.724 * eoc;\n g310 = -346.844 + 1582.851 * em - 2415.925 * emsq + 1246.113 * eoc;\n g322 = -342.585 + 1554.908 * em - 2366.899 * emsq + 1215.972 * eoc;\n g410 = -1052.797 + 4758.686 * em - 7193.992 * emsq + 3651.957 * eoc;\n g422 = -3581.690 + 16178.110 * em - 24462.770 * emsq + 12422.520 * eoc;\n if (em > 0.715) {\n g520 = -5149.66 + 29936.92 * em - 54087.36 * emsq + 31324.56 * eoc;\n } else {\n g520 = 1464.74 - 4664.75 * em + 3763.64 * emsq;\n }\n }\n if (em < 0.7) {\n g533 = -919.22770 + 4988.6100 * em - 9064.7700 * emsq + 5542.21 * eoc;\n g521 = -822.71072 + 4568.6173 * em - 8491.4146 * emsq + 5337.524 * eoc;\n g532 = -853.66600 + 4690.2500 * em - 8624.7700 * emsq + 5341.4 * eoc;\n } else {\n g533 = -37995.780 + 161616.52 * em - 229838.20 * emsq + 109377.94 * eoc;\n g521 = -51752.104 + 218913.95 * em - 309468.16 * emsq + 146349.42 * eoc;\n g532 = -40023.880 + 170470.89 * em - 242699.48 * emsq + 115605.82 * eoc;\n }\n sini2 = sinim * sinim;\n f220 = 0.75 * (1.0 + 2.0 * cosim + cosisq);\n f221 = 1.5 * sini2;\n f321 = 1.875 * sinim * (1.0 - 2.0 * cosim - 3.0 * cosisq);\n f322 = -1.875 * sinim * (1.0 + 2.0 * cosim - 3.0 * cosisq);\n f441 = 35.0 * sini2 * f220;\n f442 = 39.3750 * sini2 * sini2;\n f522 = 9.84375 * sinim * (sini2 * (1.0 - 2.0 * cosim - 5.0 * cosisq) + 0.33333333 * (-2.0 + 4.0 * cosim + 6.0 * cosisq));\n f523 = sinim * (4.92187512 * sini2 * (-2.0 - 4.0 * cosim + 10.0 * cosisq) + 6.56250012 * (1.0 + 2.0 * cosim - 3.0 * cosisq));\n f542 = 29.53125 * sinim * (2.0 - 8.0 * cosim + cosisq * (-12.0 + 8.0 * cosim + 10.0 * cosisq));\n f543 = 29.53125 * sinim * (-2.0 - 8.0 * cosim + cosisq * (12.0 + 8.0 * cosim - 10.0 * cosisq));\n xno2 = nm * nm;\n ainv2 = aonv * aonv;\n temp1 = 3.0 * xno2 * ainv2;\n temp = temp1 * root22;\n d2201 = temp * f220 * g201;\n d2211 = temp * f221 * g211;\n temp1 *= aonv;\n temp = temp1 * root32;\n d3210 = temp * f321 * g310;\n d3222 = temp * f322 * g322;\n temp1 *= aonv;\n temp = 2.0 * temp1 * root44;\n d4410 = temp * f441 * g410;\n d4422 = temp * f442 * g422;\n temp1 *= aonv;\n temp = temp1 * root52;\n d5220 = temp * f522 * g520;\n d5232 = temp * f523 * g532;\n temp = 2.0 * temp1 * root54;\n d5421 = temp * f542 * g521;\n d5433 = temp * f543 * g533;\n xlamo = (mo + nodeo + nodeo - (theta + theta)) % twoPi;\n xfact = mdot + dmdt + 2.0 * (nodedot + dnodt - rptim) - no;\n em = emo;\n emsq = emsqo;\n }\n // ---------------- synchronous resonance terms --------------\n if (irez === 1) {\n g200 = 1.0 + emsq * (-2.5 + 0.8125 * emsq);\n g310 = 1.0 + 2.0 * emsq;\n g300 = 1.0 + emsq * (-6.0 + 6.60937 * emsq);\n f220 = 0.75 * (1.0 + cosim) * (1.0 + cosim);\n f311 = 0.9375 * sinim * sinim * (1.0 + 3.0 * cosim) - 0.75 * (1.0 + cosim);\n f330 = 1.0 + cosim;\n f330 *= 1.875 * f330 * f330;\n del1 = 3.0 * nm * nm * aonv * aonv;\n del2 = 2.0 * del1 * f220 * g200 * q22;\n del3 = 3.0 * del1 * f330 * g300 * q33 * aonv;\n del1 = del1 * f311 * g310 * q31 * aonv;\n xlamo = (mo + nodeo + argpo - theta) % twoPi;\n xfact = mdot + xpidot + dmdt + domdt + dnodt - (no + rptim);\n }\n // ------------ for sgp4, initialize the integrator ----------\n xli = xlamo;\n xni = no;\n atime = 0.0;\n nm = no + dndt;\n }\n return {\n em: em,\n argpm: argpm,\n inclm: inclm,\n mm: mm,\n nm: nm,\n nodem: nodem,\n irez: irez,\n atime: atime,\n d2201: d2201,\n d2211: d2211,\n d3210: d3210,\n d3222: d3222,\n d4410: d4410,\n d4422: d4422,\n d5220: d5220,\n d5232: d5232,\n d5421: d5421,\n d5433: d5433,\n dedt: dedt,\n didt: didt,\n dmdt: dmdt,\n dndt: dndt,\n dnodt: dnodt,\n domdt: domdt,\n del1: del1,\n del2: del2,\n del3: del3,\n xfact: xfact,\n xlamo: xlamo,\n xli: xli,\n xni: xni\n };\n}\n\n/* -----------------------------------------------------------------------------\n *\n * function gstime\n *\n * this function finds the greenwich sidereal time.\n *\n * author : david vallado 719-573-2600 1 mar 2001\n *\n * inputs description range / units\n * jdut1 - julian date in ut1 days from 4713 bc\n *\n * outputs :\n * gstime - greenwich sidereal time 0 to 2pi rad\n *\n * locals :\n * temp - temporary variable for doubles rad\n * tut1 - julian centuries from the\n * jan 1, 2000 12 h epoch (ut1)\n *\n * coupling :\n * none\n *\n * references :\n * vallado 2004, 191, eq 3-45\n * --------------------------------------------------------------------------- */\nfunction gstimeInternal(jdut1) {\n var tut1 = (jdut1 - 2451545.0) / 36525.0;\n var temp = -6.2e-6 * tut1 * tut1 * tut1 + 0.093104 * tut1 * tut1 + (876600.0 * 3600 + 8640184.812866) * tut1 + 67310.54841; // # sec\n temp = temp * deg2rad / 240.0 % twoPi; // 360/86400 = 1/240, to deg, to rad\n // ------------------------ check quadrants ---------------------\n if (temp < 0.0) {\n temp += twoPi;\n }\n return temp;\n}\nfunction gstime(first, month, day, hour, minute, second, millisecond) {\n if (first instanceof Date) {\n return gstimeInternal(jday(first));\n } else if (month !== undefined) {\n return gstimeInternal(jday(first, month, day, hour, minute, second, millisecond));\n } else {\n return gstimeInternal(first);\n }\n}\n\n/*-----------------------------------------------------------------------------\n *\n * procedure initl\n *\n * this procedure initializes the sgp4 propagator. all the initialization is\n * consolidated here instead of having multiple loops inside other routines.\n *\n * author : david vallado 719-573-2600 28 jun 2005\n *\n * inputs :\n * ecco - eccentricity 0.0 - 1.0\n * epoch - epoch time in days from jan 0, 1950. 0 hr\n * inclo - inclination of satellite\n * no - mean motion of satellite\n * satn - satellite number\n *\n * outputs :\n * ainv - 1.0 / a\n * ao - semi major axis\n * con41 -\n * con42 - 1.0 - 5.0 cos(i)\n * cosio - cosine of inclination\n * cosio2 - cosio squared\n * eccsq - eccentricity squared\n * method - flag for deep space 'd', 'n'\n * omeosq - 1.0 - ecco * ecco\n * posq - semi-parameter squared\n * rp - radius of perigee\n * rteosq - square root of (1.0 - ecco*ecco)\n * sinio - sine of inclination\n * gsto - gst at time of observation rad\n * no - mean motion of satellite\n *\n * locals :\n * ak -\n * d1 -\n * del -\n * adel -\n * po -\n *\n * coupling :\n * getgravconst\n * gstime - find greenwich sidereal time from the julian date\n *\n * references :\n * hoots, roehrich, norad spacetrack report #3 1980\n * hoots, norad spacetrack report #6 1986\n * hoots, schumacher and glover 2004\n * vallado, crawford, hujsak, kelso 2006\n ----------------------------------------------------------------------------*/\nfunction initl(options) {\n var ecco = options.ecco,\n epoch = options.epoch,\n inclo = options.inclo,\n opsmode = options.opsmode;\n var no = options.no;\n // sgp4fix use old way of finding gst\n // ----------------------- earth constants ---------------------\n // sgp4fix identify constants and allow alternate values\n // ------------- calculate auxillary epoch quantities ----------\n var eccsq = ecco * ecco;\n var omeosq = 1.0 - eccsq;\n var rteosq = Math.sqrt(omeosq);\n var cosio = Math.cos(inclo);\n var cosio2 = cosio * cosio;\n // ------------------ un-kozai the mean motion -----------------\n var ak = Math.pow(xke / no, x2o3);\n var d1 = 0.75 * j2 * (3.0 * cosio2 - 1.0) / (rteosq * omeosq);\n var delPrime = d1 / (ak * ak);\n var adel = ak * (1.0 - delPrime * delPrime - delPrime * (1.0 / 3.0 + 134.0 * delPrime * delPrime / 81.0));\n delPrime = d1 / (adel * adel);\n no /= 1.0 + delPrime;\n var ao = Math.pow(xke / no, x2o3);\n var sinio = Math.sin(inclo);\n var po = ao * omeosq;\n var con42 = 1.0 - 5.0 * cosio2;\n var con41 = -con42 - cosio2 - cosio2;\n var ainv = 1.0 / ao;\n var posq = po * po;\n var rp = ao * (1.0 - ecco);\n var method = 'n';\n // sgp4fix modern approach to finding sidereal time\n var gsto;\n if (opsmode === 'a') {\n // sgp4fix use old way of finding gst\n // count integer number of days from 0 jan 1970\n var ts70 = epoch - 7305.0;\n var ds70 = Math.floor(ts70 + 1.0e-8);\n var tfrac = ts70 - ds70;\n // find greenwich location at epoch\n var c1 = 1.72027916940703639e-2; // eslint-disable-line no-loss-of-precision\n var thgr70 = 1.7321343856509374; // eslint-disable-line no-loss-of-precision\n var fk5r = 5.07551419432269442e-15; // eslint-disable-line no-loss-of-precision\n var c1p2p = c1 + twoPi;\n gsto = (thgr70 + c1 * ds70 + c1p2p * tfrac + ts70 * ts70 * fk5r) % twoPi;\n if (gsto < 0.0) {\n gsto += twoPi;\n }\n } else {\n gsto = gstime(epoch + 2433281.5);\n }\n return {\n no: no,\n method: method,\n ainv: ainv,\n ao: ao,\n con41: con41,\n con42: con42,\n cosio: cosio,\n cosio2: cosio2,\n eccsq: eccsq,\n omeosq: omeosq,\n posq: posq,\n rp: rp,\n rteosq: rteosq,\n sinio: sinio,\n gsto: gsto\n };\n}\n\n/*-----------------------------------------------------------------------------\n *\n * procedure dspace\n *\n * this procedure provides deep space contributions to mean elements for\n * perturbing third body. these effects have been averaged over one\n * revolution of the sun and moon. for earth resonance effects, the\n * effects have been averaged over no revolutions of the satellite.\n * (mean motion)\n *\n * author : david vallado 719-573-2600 28 jun 2005\n *\n * inputs :\n * d2201, d2211, d3210, d3222, d4410, d4422, d5220, d5232, d5421, d5433 -\n * dedt -\n * del1, del2, del3 -\n * didt -\n * dmdt -\n * dnodt -\n * domdt -\n * irez - flag for resonance 0-none, 1-one day, 2-half day\n * argpo - argument of perigee\n * argpdot - argument of perigee dot (rate)\n * t - time\n * tc -\n * gsto - gst\n * xfact -\n * xlamo -\n * no - mean motion\n * atime -\n * em - eccentricity\n * ft -\n * argpm - argument of perigee\n * inclm - inclination\n * xli -\n * mm - mean anomaly\n * xni - mean motion\n * nodem - right ascension of ascending node\n *\n * outputs :\n * atime -\n * em - eccentricity\n * argpm - argument of perigee\n * inclm - inclination\n * xli -\n * mm - mean anomaly\n * xni -\n * nodem - right ascension of ascending node\n * dndt -\n * nm - mean motion\n *\n * locals :\n * delt -\n * ft -\n * theta -\n * x2li -\n * x2omi -\n * xl -\n * xldot -\n * xnddt -\n * xndt -\n * xomi -\n *\n * coupling :\n * none -\n *\n * references :\n * hoots, roehrich, norad spacetrack report #3 1980\n * hoots, norad spacetrack report #6 1986\n * hoots, schumacher and glover 2004\n * vallado, crawford, hujsak, kelso 2006\n ----------------------------------------------------------------------------*/\nfunction dspace(options) {\n var irez = options.irez,\n d2201 = options.d2201,\n d2211 = options.d2211,\n d3210 = options.d3210,\n d3222 = options.d3222,\n d4410 = options.d4410,\n d4422 = options.d4422,\n d5220 = options.d5220,\n d5232 = options.d5232,\n d5421 = options.d5421,\n d5433 = options.d5433,\n dedt = options.dedt,\n del1 = options.del1,\n del2 = options.del2,\n del3 = options.del3,\n didt = options.didt,\n dmdt = options.dmdt,\n dnodt = options.dnodt,\n domdt = options.domdt,\n argpo = options.argpo,\n argpdot = options.argpdot,\n t = options.t,\n tc = options.tc,\n gsto = options.gsto,\n xfact = options.xfact,\n xlamo = options.xlamo,\n no = options.no;\n var atime = options.atime,\n em = options.em,\n argpm = options.argpm,\n inclm = options.inclm,\n xli = options.xli,\n mm = options.mm,\n xni = options.xni,\n nodem = options.nodem,\n nm = options.nm;\n var fasx2 = 0.13130908;\n var fasx4 = 2.8843198;\n var fasx6 = 0.37448087;\n var g22 = 5.7686396;\n var g32 = 0.95240898;\n var g44 = 1.8014998;\n var g52 = 1.0508330;\n var g54 = 4.4108898;\n // eslint-disable-next-line no-loss-of-precision\n var rptim = 4.37526908801129966e-3; // equates to 7.29211514668855e-5 rad/sec\n var stepp = 720.0;\n var stepn = -720.0;\n var step2 = 259200.0;\n var delt;\n var x2li;\n var x2omi;\n var xl;\n var xldot;\n var xnddt;\n var xndt;\n var xomi;\n var dndt = 0.0;\n var ft = 0.0;\n // ----------- calculate deep space resonance effects -----------\n var theta = (gsto + tc * rptim) % twoPi;\n em += dedt * t;\n inclm += didt * t;\n argpm += domdt * t;\n nodem += dnodt * t;\n mm += dmdt * t;\n // sgp4fix for negative inclinations\n // the following if statement should be commented out\n // if (inclm < 0.0)\n // {\n // inclm = -inclm;\n // argpm = argpm - pi;\n // nodem = nodem + pi;\n // }\n /* - update resonances : numerical (euler-maclaurin) integration - */\n /* ------------------------- epoch restart ---------------------- */\n // sgp4fix for propagator problems\n // the following integration works for negative time steps and periods\n // the specific changes are unknown because the original code was so convoluted\n // sgp4fix take out atime = 0.0 and fix for faster operation\n if (irez !== 0) {\n // sgp4fix streamline check\n if (atime === 0.0 || t * atime <= 0.0 || Math.abs(t) < Math.abs(atime)) {\n atime = 0.0;\n xni = no;\n xli = xlamo;\n }\n // sgp4fix move check outside loop\n if (t > 0.0) {\n delt = stepp;\n } else {\n delt = stepn;\n }\n var iretn = 381; // added for do loop\n while (iretn === 381) {\n // ------------------- dot terms calculated -------------\n // ----------- near - synchronous resonance terms -------\n if (irez !== 2) {\n xndt = del1 * Math.sin(xli - fasx2) + del2 * Math.sin(2.0 * (xli - fasx4)) + del3 * Math.sin(3.0 * (xli - fasx6));\n xldot = xni + xfact;\n xnddt = del1 * Math.cos(xli - fasx2) + 2.0 * del2 * Math.cos(2.0 * (xli - fasx4)) + 3.0 * del3 * Math.cos(3.0 * (xli - fasx6));\n xnddt *= xldot;\n } else {\n // --------- near - half-day resonance terms --------\n xomi = argpo + argpdot * atime;\n x2omi = xomi + xomi;\n x2li = xli + xli;\n 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);\n xldot = xni + xfact;\n 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));\n xnddt *= xldot;\n }\n // ----------------------- integrator -------------------\n // sgp4fix move end checks to end of routine\n if (Math.abs(t - atime) >= stepp) {\n iretn = 381;\n } else {\n ft = t - atime;\n iretn = 0;\n }\n if (iretn === 381) {\n xli += xldot * delt + xndt * step2;\n xni += xndt * delt + xnddt * step2;\n atime += delt;\n }\n }\n nm = xni + xndt * ft + xnddt * ft * ft * 0.5;\n xl = xli + xldot * ft + xndt * ft * ft * 0.5;\n if (irez !== 1) {\n mm = xl - 2.0 * nodem + 2.0 * theta;\n dndt = nm - no;\n } else {\n mm = xl - nodem - argpm + theta;\n dndt = nm - no;\n }\n nm = no + dndt;\n }\n return {\n atime: atime,\n em: em,\n argpm: argpm,\n inclm: inclm,\n xli: xli,\n mm: mm,\n xni: xni,\n nodem: nodem,\n dndt: dndt,\n nm: nm\n };\n}\n\nvar SatRecError;\n(function (SatRecError) {\n /**\n * No error, propagation for the last supplied date is successful\n */\n SatRecError[SatRecError[\"None\"] = 0] = \"None\";\n /**\n * Mean eccentricity is out of range 0 ≤ e < 1\n */\n SatRecError[SatRecError[\"MeanEccentricityOutOfRange\"] = 1] = \"MeanEccentricityOutOfRange\";\n /**\n * Mean motion has fallen below zero.\n */\n SatRecError[SatRecError[\"MeanMotionBelowZero\"] = 2] = \"MeanMotionBelowZero\";\n /**\n * Perturbed eccentricity is out of range 0 ≤ e < 1\n */\n SatRecError[SatRecError[\"PerturbedEccentricityOutOfRange\"] = 3] = \"PerturbedEccentricityOutOfRange\";\n /**\n * Length of the orbit’s semi-latus rectum has fallen below zero.\n */\n SatRecError[SatRecError[\"SemiLatusRectumBelowZero\"] = 4] = \"SemiLatusRectumBelowZero\";\n // 5 is not used\n /**\n * Orbit has decayed: the computed position is underground.\n */\n SatRecError[SatRecError[\"Decayed\"] = 6] = \"Decayed\";\n})(SatRecError || (SatRecError = {}));\n\n/*----------------------------------------------------------------------------\n *\n * procedur