ootk 4.0.9 → 5.0.0

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