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