ootk 3.0.0 → 4.0.0-1

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 (357) hide show
  1. package/CHANGELOG.md +235 -10
  2. package/README.md +27 -40
  3. package/dist/coordinate/Hill.d.ts +49 -0
  4. package/dist/coordinate/Hill.js +222 -0
  5. package/dist/coordinate/Hill.js.map +1 -0
  6. package/dist/coordinate/index.d.ts +1 -0
  7. package/dist/coordinate/index.js +2 -0
  8. package/dist/coordinate/index.js.map +1 -0
  9. package/dist/covariance/CovarianceSample.d.ts +43 -0
  10. package/dist/covariance/CovarianceSample.js +147 -0
  11. package/dist/covariance/CovarianceSample.js.map +1 -0
  12. package/dist/covariance/StateCovariance.d.ts +42 -0
  13. package/dist/covariance/StateCovariance.js +65 -0
  14. package/dist/covariance/StateCovariance.js.map +1 -0
  15. package/dist/force/AtmosphericDrag.d.ts +31 -0
  16. package/dist/force/AtmosphericDrag.js +73 -0
  17. package/dist/force/AtmosphericDrag.js.map +1 -0
  18. package/dist/force/EarthGravity.d.ts +27 -0
  19. package/dist/force/EarthGravity.js +117 -0
  20. package/dist/force/EarthGravity.js.map +1 -0
  21. package/{lib/ootk.d.ts → dist/force/Force.d.ts} +12 -11
  22. package/dist/force/Force.js +31 -0
  23. package/dist/force/Force.js.map +1 -0
  24. package/dist/force/ForceModel.d.ts +37 -0
  25. package/dist/force/ForceModel.js +75 -0
  26. package/dist/force/ForceModel.js.map +1 -0
  27. package/dist/force/Gravity.d.ts +38 -0
  28. package/dist/force/Gravity.js +47 -0
  29. package/dist/force/Gravity.js.map +1 -0
  30. package/dist/{ootk.d.ts → force/SolarRadiationPressure.d.ts} +12 -11
  31. package/dist/force/SolarRadiationPressure.js +44 -0
  32. package/dist/force/SolarRadiationPressure.js.map +1 -0
  33. package/dist/force/ThirdBodyGravity.d.ts +26 -0
  34. package/dist/force/ThirdBodyGravity.js +57 -0
  35. package/dist/force/ThirdBodyGravity.js.map +1 -0
  36. package/dist/force/Thrust.d.ts +34 -0
  37. package/dist/force/Thrust.js +58 -0
  38. package/dist/force/Thrust.js.map +1 -0
  39. package/dist/interfaces/RfSensorParams.d.ts +28 -0
  40. package/dist/interfaces/RfSensorParams.js +24 -0
  41. package/dist/interfaces/RfSensorParams.js.map +1 -0
  42. package/dist/interfaces/index.d.ts +1 -0
  43. package/dist/interfaces/index.js +2 -0
  44. package/dist/interfaces/index.js.map +1 -0
  45. package/dist/interpolator/ChebyshevCoefficients.d.ts +50 -0
  46. package/dist/interpolator/ChebyshevCoefficients.js +94 -0
  47. package/dist/interpolator/ChebyshevCoefficients.js.map +1 -0
  48. package/dist/interpolator/ChebyshevInterpolator.d.ts +38 -0
  49. package/dist/interpolator/ChebyshevInterpolator.js +71 -0
  50. package/dist/interpolator/ChebyshevInterpolator.js.map +1 -0
  51. package/dist/interpolator/CubicSpline.d.ts +35 -0
  52. package/dist/interpolator/CubicSpline.js +69 -0
  53. package/dist/interpolator/CubicSpline.js.map +1 -0
  54. package/dist/interpolator/CubicSplineInterpolator.d.ts +36 -0
  55. package/dist/interpolator/CubicSplineInterpolator.js +80 -0
  56. package/dist/interpolator/CubicSplineInterpolator.js.map +1 -0
  57. package/dist/interpolator/FieldInterpolator.d.ts +28 -0
  58. package/dist/interpolator/FieldInterpolator.js +34 -0
  59. package/dist/interpolator/FieldInterpolator.js.map +1 -0
  60. package/dist/interpolator/Interpolator.d.ts +22 -0
  61. package/dist/interpolator/Interpolator.js +47 -0
  62. package/dist/interpolator/Interpolator.js.map +1 -0
  63. package/dist/interpolator/LagrangeInterpolator.d.ts +40 -0
  64. package/dist/interpolator/LagrangeInterpolator.js +159 -0
  65. package/dist/interpolator/LagrangeInterpolator.js.map +1 -0
  66. package/dist/interpolator/StateInterpolator.d.ts +27 -0
  67. package/dist/interpolator/StateInterpolator.js +35 -0
  68. package/dist/interpolator/StateInterpolator.js.map +1 -0
  69. package/dist/interpolator/VerletBlendInterpolator.d.ts +43 -0
  70. package/dist/interpolator/VerletBlendInterpolator.js +118 -0
  71. package/dist/interpolator/VerletBlendInterpolator.js.map +1 -0
  72. package/{lib/ootk.js → dist/main.d.ts} +13 -10
  73. package/dist/{objects/space-object.d.ts → main.js} +17 -23
  74. package/dist/main.js.map +1 -0
  75. package/dist/maneuver/TwoBurnOrbitTransfer.d.ts +41 -0
  76. package/dist/maneuver/TwoBurnOrbitTransfer.js +65 -0
  77. package/dist/maneuver/TwoBurnOrbitTransfer.js.map +1 -0
  78. package/dist/maneuver/Waypoint.d.ts +91 -0
  79. package/dist/maneuver/Waypoint.js +179 -0
  80. package/dist/maneuver/Waypoint.js.map +1 -0
  81. package/{lib/objects/detailed-sat.d.ts → dist/objects/DetailedSatellite.d.ts} +40 -36
  82. package/dist/objects/DetailedSatellite.js +136 -0
  83. package/dist/objects/DetailedSatellite.js.map +1 -0
  84. package/dist/objects/DetailedSensor.d.ts +42 -0
  85. package/dist/objects/DetailedSensor.js +65 -0
  86. package/dist/objects/DetailedSensor.js.map +1 -0
  87. package/dist/objects/LandObject.d.ts +33 -0
  88. package/dist/objects/LandObject.js +34 -0
  89. package/dist/objects/LandObject.js.map +1 -0
  90. package/dist/objects/Marker.d.ts +20 -0
  91. package/dist/objects/Marker.js +24 -0
  92. package/dist/objects/Marker.js.map +1 -0
  93. package/dist/objects/RfSensor.d.ts +41 -0
  94. package/dist/objects/RfSensor.js +67 -0
  95. package/dist/objects/RfSensor.js.map +1 -0
  96. package/dist/objects/index.d.ts +5 -4
  97. package/dist/objects/index.js +6 -0
  98. package/dist/objects/index.js.map +1 -0
  99. package/dist/observation/Observation.d.ts +89 -0
  100. package/dist/observation/Observation.js +102 -0
  101. package/dist/observation/Observation.js.map +1 -0
  102. package/dist/observation/ObservationOptical.d.ts +48 -0
  103. package/dist/observation/ObservationOptical.js +105 -0
  104. package/dist/observation/ObservationOptical.js.map +1 -0
  105. package/dist/observation/ObservationRadar.d.ts +46 -0
  106. package/dist/observation/ObservationRadar.js +96 -0
  107. package/dist/observation/ObservationRadar.js.map +1 -0
  108. package/dist/observation/ObservationUtils.d.ts +20 -0
  109. package/dist/observation/ObservationUtils.js +32 -0
  110. package/dist/observation/ObservationUtils.js.map +1 -0
  111. package/dist/observation/PropagatorPairs.d.ts +32 -0
  112. package/dist/observation/PropagatorPairs.js +43 -0
  113. package/dist/observation/PropagatorPairs.js.map +1 -0
  114. package/dist/operations/BoxMuller.d.ts +46 -0
  115. package/dist/operations/BoxMuller.js +77 -0
  116. package/dist/operations/BoxMuller.js.map +1 -0
  117. package/dist/operations/EulerAngles.d.ts +105 -0
  118. package/dist/operations/EulerAngles.js +161 -0
  119. package/dist/operations/EulerAngles.js.map +1 -0
  120. package/dist/operations/Quaternion.d.ts +56 -0
  121. package/dist/operations/Quaternion.js +167 -0
  122. package/dist/operations/Quaternion.js.map +1 -0
  123. package/dist/operations/RandomGaussianSource.d.ts +24 -0
  124. package/dist/operations/RandomGaussianSource.js +43 -0
  125. package/dist/operations/RandomGaussianSource.js.map +1 -0
  126. package/dist/operations/index.d.ts +4 -0
  127. package/dist/operations/index.js +5 -0
  128. package/dist/operations/index.js.map +1 -0
  129. package/dist/optimize/ChebyshevCompressor.d.ts +32 -0
  130. package/dist/optimize/ChebyshevCompressor.js +83 -0
  131. package/dist/optimize/ChebyshevCompressor.js.map +1 -0
  132. package/dist/optimize/DownhillSimplex.d.ts +64 -0
  133. package/dist/optimize/DownhillSimplex.js +182 -0
  134. package/dist/optimize/DownhillSimplex.js.map +1 -0
  135. package/dist/optimize/GoldenSection.d.ts +39 -0
  136. package/dist/optimize/GoldenSection.js +55 -0
  137. package/dist/optimize/GoldenSection.js.map +1 -0
  138. package/dist/optimize/PolynomialRegression.d.ts +49 -0
  139. package/dist/optimize/PolynomialRegression.js +83 -0
  140. package/dist/optimize/PolynomialRegression.js.map +1 -0
  141. package/dist/optimize/PolynomicalRegressionResult.d.ts +31 -0
  142. package/dist/optimize/PolynomicalRegressionResult.js +38 -0
  143. package/dist/optimize/PolynomicalRegressionResult.js.map +1 -0
  144. package/dist/optimize/SimpleLinearRegression.d.ts +44 -0
  145. package/dist/optimize/SimpleLinearRegression.js +112 -0
  146. package/dist/optimize/SimpleLinearRegression.js.map +1 -0
  147. package/dist/optimize/SimplexEntry.d.ts +32 -0
  148. package/dist/optimize/SimplexEntry.js +42 -0
  149. package/dist/optimize/SimplexEntry.js.map +1 -0
  150. package/dist/orbit_determination/BatchLeastSquaresOD.d.ts +65 -0
  151. package/dist/orbit_determination/BatchLeastSquaresOD.js +143 -0
  152. package/dist/orbit_determination/BatchLeastSquaresOD.js.map +1 -0
  153. package/dist/orbit_determination/BatchLeastSquaresResult.d.ts +31 -0
  154. package/{lib/objects/space-object.d.ts → dist/orbit_determination/BatchLeastSquaresResult.js} +21 -23
  155. package/dist/orbit_determination/BatchLeastSquaresResult.js.map +1 -0
  156. package/dist/orbit_determination/GibbsIOD.d.ts +38 -0
  157. package/dist/orbit_determination/GibbsIOD.js +76 -0
  158. package/dist/orbit_determination/GibbsIOD.js.map +1 -0
  159. package/dist/orbit_determination/GoodingIOD.d.ts +51 -0
  160. package/dist/orbit_determination/GoodingIOD.js +247 -0
  161. package/dist/orbit_determination/GoodingIOD.js.map +1 -0
  162. package/dist/orbit_determination/HerrickGibbsIOD.d.ts +33 -0
  163. package/dist/orbit_determination/HerrickGibbsIOD.js +50 -0
  164. package/dist/orbit_determination/HerrickGibbsIOD.js.map +1 -0
  165. package/dist/orbit_determination/LambertIOD.d.ts +59 -0
  166. package/dist/orbit_determination/LambertIOD.js +213 -0
  167. package/dist/orbit_determination/LambertIOD.js.map +1 -0
  168. package/dist/orbit_determination/ModifiedGoodingIOD.d.ts +40 -0
  169. package/dist/orbit_determination/ModifiedGoodingIOD.js +83 -0
  170. package/dist/orbit_determination/ModifiedGoodingIOD.js.map +1 -0
  171. package/dist/propagator/DormandPrince54Propagator.d.ts +28 -0
  172. package/dist/propagator/DormandPrince54Propagator.js +64 -0
  173. package/dist/propagator/DormandPrince54Propagator.js.map +1 -0
  174. package/dist/propagator/KeplerPropagator.d.ts +35 -0
  175. package/dist/propagator/KeplerPropagator.js +84 -0
  176. package/dist/propagator/KeplerPropagator.js.map +1 -0
  177. package/dist/propagator/Propagator.d.ts +34 -0
  178. package/dist/propagator/Propagator.js +162 -0
  179. package/dist/propagator/Propagator.js.map +1 -0
  180. package/dist/propagator/RkCheckpoint.d.ts +22 -0
  181. package/dist/propagator/RkCheckpoint.js +27 -0
  182. package/dist/propagator/RkCheckpoint.js.map +1 -0
  183. package/dist/propagator/RkResult.d.ts +23 -0
  184. package/dist/propagator/RkResult.js +30 -0
  185. package/dist/propagator/RkResult.js.map +1 -0
  186. package/dist/propagator/RungeKutta4Propagator.d.ts +50 -0
  187. package/dist/propagator/RungeKutta4Propagator.js +141 -0
  188. package/dist/propagator/RungeKutta4Propagator.js.map +1 -0
  189. package/dist/propagator/RungeKutta89Propagator.d.ts +28 -0
  190. package/dist/propagator/RungeKutta89Propagator.js +126 -0
  191. package/dist/propagator/RungeKutta89Propagator.js.map +1 -0
  192. package/dist/propagator/RungeKuttaAdaptive.d.ts +54 -0
  193. package/dist/propagator/RungeKuttaAdaptive.js +159 -0
  194. package/dist/propagator/RungeKuttaAdaptive.js.map +1 -0
  195. package/dist/propagator/Sgp4Propagator.d.ts +34 -0
  196. package/dist/propagator/Sgp4Propagator.js +56 -0
  197. package/dist/propagator/Sgp4Propagator.js.map +1 -0
  198. package/dist/smoothing/ExponentialSmoothing.d.ts +23 -0
  199. package/dist/smoothing/ExponentialSmoothing.js +81 -0
  200. package/dist/smoothing/ExponentialSmoothing.js.map +1 -0
  201. package/dist/transforms/index.d.ts +1 -0
  202. package/dist/transforms/index.js +2 -0
  203. package/dist/transforms/index.js.map +1 -0
  204. package/dist/transforms/transforms.d.ts +56 -92
  205. package/dist/transforms/transforms.js +94 -0
  206. package/dist/transforms/transforms.js.map +1 -0
  207. package/dist/types/types.d.ts +105 -584
  208. package/dist/types/types.js +23 -0
  209. package/dist/types/types.js.map +1 -0
  210. package/dist/utils/index.d.ts +1 -0
  211. package/dist/utils/index.js +2 -0
  212. package/dist/utils/index.js.map +1 -0
  213. package/dist/utils/jacobian.d.ts +11 -0
  214. package/dist/utils/jacobian.js +29 -0
  215. package/dist/utils/jacobian.js.map +1 -0
  216. package/package.json +34 -42
  217. package/src/coordinate/Hill.ts +326 -0
  218. package/src/coordinate/index.ts +1 -0
  219. package/src/covariance/CovarianceSample.ts +194 -0
  220. package/src/covariance/StateCovariance.ts +69 -0
  221. package/src/force/AtmosphericDrag.ts +101 -0
  222. package/src/force/EarthGravity.ts +157 -0
  223. package/src/force/Force.ts +33 -0
  224. package/src/force/ForceModel.ts +91 -0
  225. package/src/force/Gravity.ts +53 -0
  226. package/src/force/SolarRadiationPressure.ts +42 -0
  227. package/src/force/ThirdBodyGravity.ts +62 -0
  228. package/src/force/Thrust.ts +83 -0
  229. package/src/interfaces/RfSensorParams.ts +30 -0
  230. package/src/interfaces/index.ts +1 -0
  231. package/src/interpolator/ChebyshevCoefficients.ts +109 -0
  232. package/src/interpolator/ChebyshevInterpolator.ts +87 -0
  233. package/src/interpolator/CubicSpline.ts +72 -0
  234. package/src/interpolator/CubicSplineInterpolator.ts +90 -0
  235. package/src/interpolator/FieldInterpolator.ts +37 -0
  236. package/src/interpolator/Interpolator.ts +56 -0
  237. package/src/interpolator/LagrangeInterpolator.ts +192 -0
  238. package/src/interpolator/StateInterpolator.ts +39 -0
  239. package/src/interpolator/VerletBlendInterpolator.ts +146 -0
  240. package/src/main.ts +32 -0
  241. package/src/maneuver/TwoBurnOrbitTransfer.ts +79 -0
  242. package/src/maneuver/Waypoint.ts +267 -0
  243. package/src/objects/DetailedSatellite.ts +159 -0
  244. package/src/objects/DetailedSensor.ts +68 -0
  245. package/src/objects/LandObject.ts +46 -0
  246. package/src/objects/Marker.ts +25 -0
  247. package/src/objects/RfSensor.ts +78 -0
  248. package/src/objects/index.ts +5 -0
  249. package/src/observation/Observation.ts +125 -0
  250. package/src/observation/ObservationOptical.ts +146 -0
  251. package/src/observation/ObservationRadar.ts +131 -0
  252. package/src/observation/ObservationUtils.ts +40 -0
  253. package/src/observation/PropagatorPairs.ts +45 -0
  254. package/src/operations/BoxMuller.ts +87 -0
  255. package/src/operations/EulerAngles.ts +183 -0
  256. package/src/operations/Quaternion.ts +222 -0
  257. package/src/operations/RandomGaussianSource.ts +51 -0
  258. package/src/operations/index.ts +4 -0
  259. package/src/optimize/ChebyshevCompressor.ts +96 -0
  260. package/src/optimize/DownhillSimplex.ts +212 -0
  261. package/src/optimize/GoldenSection.ts +71 -0
  262. package/src/optimize/PolynomialRegression.ts +109 -0
  263. package/src/optimize/PolynomicalRegressionResult.ts +32 -0
  264. package/src/optimize/SimpleLinearRegression.ts +127 -0
  265. package/src/optimize/SimplexEntry.ts +50 -0
  266. package/src/orbit_determination/BatchLeastSquaresOD.ts +174 -0
  267. package/src/orbit_determination/BatchLeastSquaresResult.ts +33 -0
  268. package/src/orbit_determination/GibbsIOD.ts +95 -0
  269. package/src/orbit_determination/GoodingIOD.ts +380 -0
  270. package/src/orbit_determination/HerrickGibbsIOD.ts +51 -0
  271. package/src/orbit_determination/LambertIOD.ts +260 -0
  272. package/src/orbit_determination/ModifiedGoodingIOD.ts +133 -0
  273. package/src/propagator/DormandPrince54Propagator.ts +73 -0
  274. package/src/propagator/KeplerPropagator.ts +102 -0
  275. package/src/propagator/Propagator.ts +253 -0
  276. package/src/propagator/RkCheckpoint.ts +25 -0
  277. package/src/propagator/RkResult.ts +26 -0
  278. package/src/propagator/RungeKutta4Propagator.ts +179 -0
  279. package/src/propagator/RungeKutta89Propagator.ts +132 -0
  280. package/src/propagator/RungeKuttaAdaptive.ts +232 -0
  281. package/src/propagator/Sgp4Propagator.ts +71 -0
  282. package/src/smoothing/ExponentialSmoothing.ts +90 -0
  283. package/src/transforms/index.ts +1 -0
  284. package/src/transforms/transforms.ts +117 -0
  285. package/src/types/types.ts +135 -0
  286. package/src/utils/index.ts +1 -0
  287. package/src/utils/jacobian.ts +38 -0
  288. package/.eslintrc.json +0 -244
  289. package/.prettierrc +0 -17
  290. package/babel.config.js +0 -16
  291. package/codecov.yml +0 -21
  292. package/dist/objects/base-object.d.ts +0 -40
  293. package/dist/objects/detailed-sat.d.ts +0 -66
  294. package/dist/objects/sat.d.ts +0 -92
  295. package/dist/objects/sensor.d.ts +0 -93
  296. package/dist/objects/star.d.ts +0 -46
  297. package/dist/ootk.js +0 -2
  298. package/dist/ootk.js.LICENSE.txt +0 -77
  299. package/dist/sgp4/sgp4.d.ts +0 -82
  300. package/dist/tle/tle-format-data.d.ts +0 -6
  301. package/dist/tle/tle.d.ts +0 -375
  302. package/dist/utils/constants.d.ts +0 -34
  303. package/dist/utils/moon-math.d.ts +0 -113
  304. package/dist/utils/sun-math.d.ts +0 -230
  305. package/dist/utils/utils.d.ts +0 -39
  306. package/jest.config.ts +0 -30
  307. package/lib/objects/base-object.d.ts +0 -40
  308. package/lib/objects/base-object.js +0 -79
  309. package/lib/objects/base-object.js.map +0 -1
  310. package/lib/objects/detailed-sat.js +0 -149
  311. package/lib/objects/detailed-sat.js.map +0 -1
  312. package/lib/objects/index.d.ts +0 -4
  313. package/lib/objects/index.js +0 -5
  314. package/lib/objects/index.js.map +0 -1
  315. package/lib/objects/sat.d.ts +0 -92
  316. package/lib/objects/sat.js +0 -188
  317. package/lib/objects/sat.js.map +0 -1
  318. package/lib/objects/sensor.d.ts +0 -93
  319. package/lib/objects/sensor.js +0 -273
  320. package/lib/objects/sensor.js.map +0 -1
  321. package/lib/objects/space-object.js +0 -60
  322. package/lib/objects/space-object.js.map +0 -1
  323. package/lib/objects/star.d.ts +0 -46
  324. package/lib/objects/star.js +0 -91
  325. package/lib/objects/star.js.map +0 -1
  326. package/lib/ootk.js.map +0 -1
  327. package/lib/sgp4/sgp4.d.ts +0 -82
  328. package/lib/sgp4/sgp4.js +0 -3262
  329. package/lib/sgp4/sgp4.js.map +0 -1
  330. package/lib/tle/tle-format-data.d.ts +0 -6
  331. package/lib/tle/tle-format-data.js +0 -10
  332. package/lib/tle/tle-format-data.js.map +0 -1
  333. package/lib/tle/tle.d.ts +0 -375
  334. package/lib/tle/tle.js +0 -611
  335. package/lib/tle/tle.js.map +0 -1
  336. package/lib/transforms/transforms.d.ts +0 -94
  337. package/lib/transforms/transforms.js +0 -308
  338. package/lib/transforms/transforms.js.map +0 -1
  339. package/lib/types/types.d.ts +0 -605
  340. package/lib/types/types.js +0 -36
  341. package/lib/types/types.js.map +0 -1
  342. package/lib/utils/constants.d.ts +0 -34
  343. package/lib/utils/constants.js +0 -35
  344. package/lib/utils/constants.js.map +0 -1
  345. package/lib/utils/moon-math.d.ts +0 -113
  346. package/lib/utils/moon-math.js +0 -387
  347. package/lib/utils/moon-math.js.map +0 -1
  348. package/lib/utils/sun-math.d.ts +0 -230
  349. package/lib/utils/sun-math.js +0 -422
  350. package/lib/utils/sun-math.js.map +0 -1
  351. package/lib/utils/utils.d.ts +0 -39
  352. package/lib/utils/utils.js +0 -102
  353. package/lib/utils/utils.js.map +0 -1
  354. package/sandbox.html +0 -8
  355. package/tsconfig.base.json +0 -31
  356. package/tsconfig.build.json +0 -14
  357. /package/{LICENSE.MD → LICENSE.md} +0 -0
@@ -0,0 +1,194 @@
1
+ /**
2
+ * @author @thkruz Theodore Kruczek
3
+ * @license AGPL-3.0-or-later
4
+ * @copyright (c) 2020-2024 Theodore Kruczek
5
+ *
6
+ * Orbital Object ToolKit is free software: you can redistribute it and/or modify it under the
7
+ * terms of the GNU Affero General Public License as published by the Free Software
8
+ * Foundation, either version 3 of the License, or (at your option) any later version.
9
+ *
10
+ * Orbital Object ToolKit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
+ * See the GNU Affero General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Affero General Public License along with
15
+ * Orbital Object ToolKit. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+
18
+ /* eslint-disable class-methods-use-this */
19
+ import {
20
+ Epoch,
21
+ EpochUTC,
22
+ J2000,
23
+ Kilometers,
24
+ KilometersPerSecond,
25
+ Matrix,
26
+ RelativeState,
27
+ RIC,
28
+ Vector,
29
+ Vector3D,
30
+ } from 'ootk-core';
31
+ import { ForceModel } from '../force/ForceModel';
32
+ import { Thrust } from '../force/Thrust';
33
+ import { RungeKutta89Propagator } from '../propagator/RungeKutta89Propagator';
34
+ import { CovarianceFrame, StateCovariance } from './StateCovariance';
35
+
36
+ // / Sigma point covariance sample.
37
+ export class CovarianceSample {
38
+ private _origin: RungeKutta89Propagator;
39
+ private _samples: RungeKutta89Propagator[] = [];
40
+ private matrix_ = Matrix.zero(6, 12);
41
+
42
+ /**
43
+ * Create a new [CovarianceSample] object from an inertial state, covariance
44
+ * and optional force models for the origin state and samples.
45
+ *
46
+ * Two-body physics will be used if a force model is not provided.
47
+ * @param state The origin state.
48
+ * @param covariance The covariance.
49
+ * @param originForceModel The force model for the origin state.
50
+ * @param sampleForceModel The force model for the samples.
51
+ */
52
+ constructor(state: J2000, covariance: StateCovariance, originForceModel?: ForceModel, sampleForceModel?: ForceModel) {
53
+ originForceModel ??= new ForceModel().setGravity();
54
+ sampleForceModel ??= new ForceModel().setGravity();
55
+ this._origin = new RungeKutta89Propagator(state, originForceModel);
56
+ const s = covariance.matrix.cholesky().elements;
57
+ const sqrt6 = Math.sqrt(6.0);
58
+
59
+ for (let i = 0; i < 6; i++) {
60
+ for (let j = 0; j < 6; j++) {
61
+ s[i][j] *= sqrt6;
62
+ }
63
+ }
64
+
65
+ // 6 x 12 matrix
66
+ const sigmapts = Matrix.zero(6, 12).elements;
67
+
68
+ for (let i = 0; i < 6; i++) {
69
+ const jj = (i - 1) * 2 + 2;
70
+
71
+ for (let j = 0; j < 3; j++) {
72
+ sigmapts[j][jj] = s[j][i];
73
+ sigmapts[j + 3][jj] = s[j + 3][i];
74
+
75
+ sigmapts[j][jj + 1] = -s[j][i];
76
+ sigmapts[j + 3][jj + 1] = -s[j + 3][i];
77
+ }
78
+ }
79
+
80
+ for (let i = 0; i < 12; i++) {
81
+ const sampleR = new Vector3D(
82
+ sigmapts[0][i] as Kilometers,
83
+ sigmapts[1][i] as Kilometers,
84
+ sigmapts[2][i] as Kilometers,
85
+ );
86
+ const sampleV = new Vector3D(
87
+ sigmapts[3][i] as KilometersPerSecond,
88
+ sigmapts[4][i] as KilometersPerSecond,
89
+ sigmapts[5][i] as KilometersPerSecond,
90
+ );
91
+
92
+ if (covariance.frame === CovarianceFrame.ECI) {
93
+ const sample = new J2000(state.epoch, state.position.add(sampleR), state.velocity.add(sampleV));
94
+
95
+ this._samples.push(new RungeKutta89Propagator(sample, sampleForceModel));
96
+ } else if (covariance.frame === CovarianceFrame.RIC) {
97
+ const sample = new RIC(sampleR, sampleV).toJ2000(state);
98
+
99
+ this._samples.push(new RungeKutta89Propagator(sample, sampleForceModel));
100
+ }
101
+ }
102
+ }
103
+
104
+ // / Current covariance sample epoch.
105
+ get epoch(): Epoch {
106
+ return this._origin.state.epoch;
107
+ }
108
+
109
+ // / Current covariance sample origin state.
110
+ get state(): J2000 {
111
+ return this._origin.state;
112
+ }
113
+
114
+ // / Rebuild covariance from sigma points.
115
+ private _rebuildCovariance(matrix: Matrix): Matrix {
116
+ const pts = matrix.elements;
117
+ const c = 1.0 / 12.0;
118
+ const yu = new Vector([0, 0, 0, 0, 0, 0]).elements;
119
+ const y = Matrix.zero(6, 12);
120
+
121
+ for (let i = 0; i < 12; i++) {
122
+ for (let j = 0; j < 6; j++) {
123
+ yu[j] += pts[j][i];
124
+ }
125
+ }
126
+
127
+ for (let j = 0; j < 6; j++) {
128
+ yu[j] *= c;
129
+ }
130
+
131
+ for (let i = 0; i < 12; i++) {
132
+ for (let j = 0; j < 6; j++) {
133
+ y.elements[j][i] = pts[j][i] - yu[j];
134
+ }
135
+ }
136
+
137
+ const yt = y.transpose();
138
+ const tmp = y.multiply(yt);
139
+
140
+ return tmp.scale(c);
141
+ }
142
+
143
+ // / Propagate covariance to a new epoch.
144
+ propagate(epoch: EpochUTC): void {
145
+ this._origin.propagate(epoch);
146
+ for (const sample of this._samples) {
147
+ sample.propagate(epoch);
148
+ }
149
+ }
150
+
151
+ // / Apply a maneuver to this covariance.
152
+ maneuver(maneuver: Thrust): void {
153
+ this._origin.maneuver(maneuver);
154
+ for (const sample of this._samples) {
155
+ sample.maneuver(maneuver);
156
+ }
157
+ }
158
+
159
+ // / Desample covariance in J2000 frame.
160
+ desampleJ2000(): StateCovariance {
161
+ for (let i = 0; i < 12; i++) {
162
+ const state = this._samples[i].state;
163
+
164
+ this.matrix_.elements[0][i] = state.position.x;
165
+ this.matrix_.elements[1][i] = state.position.y;
166
+ this.matrix_.elements[2][i] = state.position.z;
167
+ this.matrix_.elements[3][i] = state.velocity.x;
168
+ this.matrix_.elements[4][i] = state.velocity.y;
169
+ this.matrix_.elements[5][i] = state.velocity.z;
170
+ }
171
+ const matrix = this._rebuildCovariance(this.matrix_);
172
+
173
+ return new StateCovariance(matrix, CovarianceFrame.ECI);
174
+ }
175
+
176
+ // / Desample covariance in RIC frame.
177
+ desampleRIC(): StateCovariance {
178
+ const rot = RelativeState.createMatrix(this._origin.state.position, this._origin.state.velocity);
179
+
180
+ for (let i = 0; i < 12; i++) {
181
+ const state = RIC.fromJ2000Matrix(this._samples[i].state, this._origin.state, rot);
182
+
183
+ this.matrix_.elements[0][i] = state.position.x;
184
+ this.matrix_.elements[1][i] = state.position.y;
185
+ this.matrix_.elements[2][i] = state.position.z;
186
+ this.matrix_.elements[3][i] = state.velocity.x;
187
+ this.matrix_.elements[4][i] = state.velocity.y;
188
+ this.matrix_.elements[5][i] = state.velocity.z;
189
+ }
190
+ const matrix = this._rebuildCovariance(this.matrix_);
191
+
192
+ return new StateCovariance(matrix, CovarianceFrame.RIC);
193
+ }
194
+ }
@@ -0,0 +1,69 @@
1
+ /**
2
+ * @author @thkruz Theodore Kruczek
3
+ * @license AGPL-3.0-or-later
4
+ * @copyright (c) 2020-2024 Theodore Kruczek
5
+ *
6
+ * Orbital Object ToolKit is free software: you can redistribute it and/or modify it under the
7
+ * terms of the GNU Affero General Public License as published by the Free Software
8
+ * Foundation, either version 3 of the License, or (at your option) any later version.
9
+ *
10
+ * Orbital Object ToolKit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
+ * See the GNU Affero General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Affero General Public License along with
15
+ * Orbital Object ToolKit. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+
18
+ import { Matrix, Vector } from 'ootk-core';
19
+
20
+ /** Covariance Frame */
21
+ export enum CovarianceFrame {
22
+ /** Earth-centered inertial */
23
+ ECI = 'eci',
24
+ /** Radial-Intrack-Crosstrack */
25
+ RIC = 'ric',
26
+ }
27
+
28
+ // / State covariance.
29
+ export class StateCovariance {
30
+ /**
31
+ * Create a new [StateCovariance] object given its covariance [matrix] and
32
+ * [CovarianceFrame].
33
+ * @param matrix The covariance matrix.
34
+ * @param frame The covariance frame.
35
+ * @returns A new [StateCovariance] object.
36
+ */
37
+ constructor(public matrix: Matrix, public frame: CovarianceFrame) {
38
+ // Nothing to do here.
39
+ }
40
+
41
+ // / Create a new [StateCovariance] object from 1-sigma values.
42
+ static fromSigmas(sigmas: number[], frame: CovarianceFrame): StateCovariance {
43
+ const n = sigmas.length;
44
+ const output = Matrix.zero(n, n);
45
+
46
+ for (let i = 0; i < n; i++) {
47
+ output.elements[i][i] = Math.max(sigmas[i] * sigmas[i], 1e-32);
48
+ }
49
+
50
+ return new StateCovariance(output, frame);
51
+ }
52
+
53
+ /**
54
+ * Calculates the standard deviations (sigmas) of each element in the covariance matrix.
55
+ * @returns A vector containing the standard deviations of each element in the covariance matrix.
56
+ */
57
+ sigmas(): Vector {
58
+ const c = this.matrix.columns;
59
+ const result = new Float64Array(c);
60
+
61
+ for (let i = 0; i < c; i++) {
62
+ const variance = this.matrix.elements[i][i];
63
+
64
+ result[i] = Math.sqrt(variance);
65
+ }
66
+
67
+ return new Vector(result);
68
+ }
69
+ }
@@ -0,0 +1,101 @@
1
+ /**
2
+ * @author @thkruz Theodore Kruczek
3
+ * @license AGPL-3.0-or-later
4
+ * @copyright (c) 2020-2024 Theodore Kruczek
5
+ *
6
+ * Orbital Object ToolKit is free software: you can redistribute it and/or modify it under the
7
+ * terms of the GNU Affero General Public License as published by the Free Software
8
+ * Foundation, either version 3 of the License, or (at your option) any later version.
9
+ *
10
+ * Orbital Object ToolKit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
+ * See the GNU Affero General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Affero General Public License along with
15
+ * Orbital Object ToolKit. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+
18
+ import {
19
+ DataHandler,
20
+ DEG2RAD,
21
+ Earth,
22
+ ITRF,
23
+ J2000,
24
+ Kilometers,
25
+ KilometersPerSecond,
26
+ Radians,
27
+ Sun,
28
+ Vector3D,
29
+ } from 'ootk-core';
30
+ import { Force } from './Force';
31
+
32
+ /**
33
+ * Harris-Priester atmospheric drag force model.
34
+ * Atmospheric density model assumes mean solar flux.
35
+ */
36
+ export class AtmosphericDrag implements Force {
37
+ mass: number;
38
+ area: number;
39
+ dragCoeff: number;
40
+ cosine: number;
41
+
42
+ constructor(mass: number, area: number, dragCoeff: number, cosine: number) {
43
+ this.mass = mass;
44
+ this.area = area;
45
+ this.dragCoeff = dragCoeff;
46
+ this.cosine = cosine;
47
+ }
48
+
49
+ private static _getHPDensity(state: ITRF, n: number): number {
50
+ const hpa = DataHandler.getInstance().getHpAtmosphere(state.height);
51
+
52
+ if (hpa === null) {
53
+ return 0.0;
54
+ }
55
+ const sunPos = Sun.positionApparent(state.epoch);
56
+ const sunVec = new J2000(
57
+ state.epoch,
58
+ sunPos,
59
+ Vector3D.origin as Vector3D<KilometersPerSecond>,
60
+ ).toITRF().position.normalize();
61
+ const bulVec = sunVec.rotZ(-30.0 * DEG2RAD as Radians);
62
+ const cosPsi = bulVec.normalize().dot(state.position.normalize());
63
+ const c2Psi2 = 0.5 * (1.0 + cosPsi);
64
+ const cPsi2 = Math.sqrt(c2Psi2);
65
+ const cosPow = cPsi2 > 1e-12 ? c2Psi2 * cPsi2 ** (n - 2) : 0.0;
66
+ const altitude = hpa.height;
67
+ const [h0, min0, max0] = hpa.hp0;
68
+ const [h1, min1, max1] = hpa.hp1;
69
+ const dH = (h0 - altitude) / (h0 - h1);
70
+ const rhoMin = min0 * (min1 / min0) ** dH;
71
+
72
+ if (cosPow === 0) {
73
+ return rhoMin;
74
+ }
75
+ const rhoMax = max0 * (max1 / max0) ** dH;
76
+
77
+ return rhoMin + (rhoMax - rhoMin) * cosPow;
78
+ }
79
+
80
+ acceleration(state: J2000): Vector3D {
81
+ const itrfState = state.toITRF();
82
+ const density = AtmosphericDrag._getHPDensity(itrfState, this.cosine);
83
+
84
+ if (density === 0) {
85
+ return Vector3D.origin;
86
+ }
87
+ const rotation = new ITRF(
88
+ state.epoch,
89
+ // TODO: #26 This is a bit of a hack to get Radians/Second to work with StateVector class
90
+ Earth.rotation as unknown as Vector3D<Kilometers>,
91
+ Vector3D.origin as Vector3D<KilometersPerSecond>,
92
+ ).toJ2000().position;
93
+ // TODO: #26 This is a bit of a hack to get Radians/Second to work with StateVector class
94
+ const vRel = state.velocity.subtract(rotation.cross(state.position) as unknown as Vector3D<KilometersPerSecond>)
95
+ .scale(1000.0 as KilometersPerSecond);
96
+ const vm = vRel.magnitude();
97
+ const fScale = -0.5 * density * ((this.dragCoeff * this.area) / this.mass) * vm;
98
+
99
+ return vRel.scale(fScale / 1000.0);
100
+ }
101
+ }
@@ -0,0 +1,157 @@
1
+ /**
2
+ * @author @thkruz Theodore Kruczek
3
+ * @license AGPL-3.0-or-later
4
+ * @copyright (c) 2020-2024 Theodore Kruczek
5
+ *
6
+ * Orbital Object ToolKit is free software: you can redistribute it and/or modify it under the
7
+ * terms of the GNU Affero General Public License as published by the Free Software
8
+ * Foundation, either version 3 of the License, or (at your option) any later version.
9
+ *
10
+ * Orbital Object ToolKit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
+ * See the GNU Affero General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Affero General Public License along with
15
+ * Orbital Object ToolKit. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+
18
+ import { DataHandler, Earth, ITRF, J2000, Kilometers, KilometersPerSecond, Vector3D } from 'ootk-core';
19
+ /* eslint-disable class-methods-use-this */
20
+ // / Complex Earth gravity model, accounting for EGM-96 zonal, sectoral, and
21
+
22
+ import { Force } from './Force';
23
+
24
+ // / tesseral geopotential perturbations.
25
+ export class EarthGravity implements Force {
26
+ degree: number;
27
+ order: number;
28
+ _asphericalFlag: boolean;
29
+
30
+ constructor(degree: number, order: number) {
31
+ this.degree = Math.min(Math.max(degree, 0), 36);
32
+ this.order = Math.min(Math.max(order, 0), 36);
33
+ this._asphericalFlag = degree >= 2;
34
+ }
35
+
36
+ _spherical(state: J2000): Vector3D {
37
+ const rMag = state.position.magnitude();
38
+
39
+ return state.position.scale(-Earth.mu / (rMag * rMag * rMag));
40
+ }
41
+
42
+ // eslint-disable-next-line max-statements
43
+ _aspherical(state: J2000): Vector3D {
44
+ const posEcef = state.toITRF().position;
45
+ const ri = 1.0 / posEcef.magnitude();
46
+ const xor = posEcef.x * ri;
47
+ const yor = posEcef.y * ri;
48
+ const zor = posEcef.z * ri;
49
+
50
+ const ep = zor;
51
+ const reor = Earth.radiusEquator * ri;
52
+ let reorn = reor;
53
+ const muor2 = Earth.mu * ri * ri;
54
+
55
+ let sumH = 0.0;
56
+ let sumGm = 0.0;
57
+ let sumJ = 0.0;
58
+ let sumK = 0.0;
59
+
60
+ const cTil = new Float64Array(this.order + 4);
61
+ const sTil = new Float64Array(this.order + 4);
62
+
63
+ const pN = new Float64Array(this.order + 4);
64
+ const pNm1 = new Float64Array(this.order + 4);
65
+ const pNm2 = new Float64Array(this.order + 4);
66
+
67
+ pNm2[0] = 1.0;
68
+ pNm1[0] = ep;
69
+ pNm1[1] = 1.0;
70
+ cTil[0] = 1.0;
71
+ cTil[1] = xor;
72
+ sTil[1] = yor;
73
+
74
+ const dh = DataHandler.getInstance();
75
+
76
+ for (let n = 2, nm1 = 1, nm2 = 0, np1 = 3; n <= this.degree; nm2++, nm1++, n++, np1++) {
77
+ const twonm1 = 2.0 * n - 1.0;
78
+
79
+ reorn *= reor;
80
+ const cN0 = dh.getEgm96Coeffs(n, 0)[2];
81
+
82
+ pN[0] = (twonm1 * ep * pNm1[0] - nm1 * pNm2[0]) / n;
83
+ pN[1] = pNm2[1] + twonm1 * pNm1[0];
84
+ pN[2] = pNm2[2] + twonm1 * pNm1[1];
85
+
86
+ let sumHn = pN[1] * cN0;
87
+ let sumGmn = pN[0] * cN0 * np1;
88
+
89
+ if (this.order > 0) {
90
+ let sumJn = 0.0;
91
+ let sumKn = 0.0;
92
+
93
+ cTil[n] = cTil[1] * cTil[nm1] - sTil[1] * sTil[nm1];
94
+ sTil[n] = sTil[1] * cTil[nm1] + cTil[1] * sTil[nm1];
95
+
96
+ const lim = n < this.order ? n : this.order;
97
+
98
+ for (let m = 1, mm1 = 0, mm2 = -1, mp1 = 2, mp2 = 3; m <= lim; mm2++, mm1++, m++, mp1++, mp2++) {
99
+ pN[mp1] = pNm2[mp1] + twonm1 * pNm1[m];
100
+
101
+ const dm = m;
102
+ const npmp1 = n + mp1;
103
+
104
+ const pNm = pN[m];
105
+ const pNmp1 = pN[mp1];
106
+
107
+ const coefs = dh.getEgm96Coeffs(n, m);
108
+ const cNm = coefs[2];
109
+ const sNm = coefs[3];
110
+
111
+ const mxPnm = dm * pNm;
112
+ const bNmtil = cNm * cTil[m] + sNm * sTil[m];
113
+ const pNmBnm = pNm * bNmtil;
114
+ const bNmtm1 = cNm * cTil[mm1] + sNm * sTil[mm1];
115
+ const aNmtm1 = cNm * sTil[mm1] - sNm * cTil[mm1];
116
+
117
+ sumHn += pNmp1 * bNmtil;
118
+ sumGmn += npmp1 * pNmBnm;
119
+ sumJn += mxPnm * bNmtm1;
120
+ sumKn -= mxPnm * aNmtm1;
121
+ }
122
+
123
+ sumJ += reorn * sumJn;
124
+ sumK += reorn * sumKn;
125
+ }
126
+
127
+ sumH += reorn * sumHn;
128
+ sumGm += reorn * sumGmn;
129
+
130
+ if (n < this.degree) {
131
+ for (let i = 0; i <= n; i++) {
132
+ pNm2[i] = pNm1[i];
133
+ pNm1[i] = pN[i];
134
+ }
135
+ }
136
+ }
137
+
138
+ const lambda = sumGm + ep * sumH;
139
+ const g = new Vector3D<Kilometers>(
140
+ -muor2 * (lambda * xor - sumJ) as Kilometers,
141
+ -muor2 * (lambda * yor - sumK) as Kilometers,
142
+ -muor2 * (lambda * zor - sumH) as Kilometers,
143
+ );
144
+
145
+ return new ITRF(state.epoch, g, Vector3D.origin as Vector3D<KilometersPerSecond>).toJ2000().position;
146
+ }
147
+
148
+ acceleration(state: J2000): Vector3D {
149
+ let accVec = this._spherical(state);
150
+
151
+ if (this._asphericalFlag) {
152
+ accVec = accVec.add(this._aspherical(state));
153
+ }
154
+
155
+ return accVec;
156
+ }
157
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @author @thkruz Theodore Kruczek
3
+ * @license AGPL-3.0-or-later
4
+ * @copyright (c) 2020-2024 Theodore Kruczek
5
+ *
6
+ * Orbital Object ToolKit is free software: you can redistribute it and/or modify it under the
7
+ * terms of the GNU Affero General Public License as published by the Free Software
8
+ * Foundation, either version 3 of the License, or (at your option) any later version.
9
+ *
10
+ * Orbital Object ToolKit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
+ * See the GNU Affero General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Affero General Public License along with
15
+ * Orbital Object ToolKit. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+
18
+ import { J2000, Vector3D } from 'ootk-core';
19
+ /* eslint-disable @typescript-eslint/no-unused-vars */
20
+ /* eslint-disable class-methods-use-this */
21
+
22
+ // / Base class for perturbation forces.
23
+ export abstract class Force {
24
+ /**
25
+ * Calculate the acceleration due to the perturbing force on a given
26
+ * state vector.
27
+ * @param state The state vector.
28
+ * @throws If the force cannot be calculated.
29
+ */
30
+ acceleration(state: J2000): Vector3D {
31
+ throw Error('Not implemented');
32
+ }
33
+ }
@@ -0,0 +1,91 @@
1
+ /**
2
+ * @author @thkruz Theodore Kruczek
3
+ * @license AGPL-3.0-or-later
4
+ * @copyright (c) 2020-2024 Theodore Kruczek
5
+ *
6
+ * Orbital Object ToolKit is free software: you can redistribute it and/or modify it under the
7
+ * terms of the GNU Affero General Public License as published by the Free Software
8
+ * Foundation, either version 3 of the License, or (at your option) any later version.
9
+ *
10
+ * Orbital Object ToolKit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
+ * See the GNU Affero General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Affero General Public License along with
15
+ * Orbital Object ToolKit. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+
18
+ import { Earth, J2000, Vector, Vector3D } from 'ootk-core';
19
+ import { AtmosphericDrag } from './AtmosphericDrag';
20
+ import { EarthGravity } from './EarthGravity';
21
+ import { Force } from './Force';
22
+ import { Gravity } from './Gravity';
23
+ import { SolarRadiationPressure } from './SolarRadiationPressure';
24
+ import { ThirdBodyGravity } from './ThirdBodyGravity';
25
+ import { Thrust } from './Thrust';
26
+
27
+ // / Force model for spacecraft propagation.
28
+
29
+ export class ForceModel {
30
+ private _centralGravity?: Force;
31
+ private _thirdBodyGravity?: Force;
32
+ private _solarRadiationPressure?: Force;
33
+ private _atmosphericDrag?: Force;
34
+ private _maneuverThrust: Force | null = null;
35
+
36
+ setGravity(mu: number = Earth.mu): this {
37
+ this._centralGravity = new Gravity(mu);
38
+
39
+ return this;
40
+ }
41
+
42
+ setEarthGravity(degree: number, order: number): void {
43
+ this._centralGravity = new EarthGravity(degree, order);
44
+ }
45
+
46
+ setThirdBodyGravity({ moon = false, sun = false }): void {
47
+ this._thirdBodyGravity = new ThirdBodyGravity(moon, sun);
48
+ }
49
+
50
+ setSolarRadiationPressure(mass: number, area: number, coeff = 1.2): void {
51
+ this._solarRadiationPressure = new SolarRadiationPressure(mass, area, coeff);
52
+ }
53
+
54
+ setAtmosphericDrag(mass: number, area: number, coeff = 2.2, cosine = 4): void {
55
+ this._atmosphericDrag = new AtmosphericDrag(mass, area, coeff, cosine);
56
+ }
57
+
58
+ loadManeuver(maneuver: Thrust): void {
59
+ this._maneuverThrust = maneuver;
60
+ }
61
+
62
+ clearManeuver(): void {
63
+ this._maneuverThrust = null;
64
+ }
65
+
66
+ acceleration(state: J2000): Vector3D {
67
+ let accVec = Vector3D.origin;
68
+
69
+ if (this._centralGravity) {
70
+ accVec = accVec.add(this._centralGravity.acceleration(state));
71
+ }
72
+ if (this._thirdBodyGravity) {
73
+ accVec = accVec.add(this._thirdBodyGravity.acceleration(state));
74
+ }
75
+ if (this._solarRadiationPressure) {
76
+ accVec = accVec.add(this._solarRadiationPressure.acceleration(state));
77
+ }
78
+ if (this._atmosphericDrag) {
79
+ accVec = accVec.add(this._atmosphericDrag.acceleration(state));
80
+ }
81
+ if (this._maneuverThrust) {
82
+ accVec = accVec.add(this._maneuverThrust.acceleration(state));
83
+ }
84
+
85
+ return accVec;
86
+ }
87
+
88
+ derivative(state: J2000): Vector {
89
+ return state.velocity.join(this.acceleration(state));
90
+ }
91
+ }
@@ -0,0 +1,53 @@
1
+ /**
2
+ * @author @thkruz Theodore Kruczek
3
+ * @license AGPL-3.0-or-later
4
+ * @copyright (c) 2020-2024 Theodore Kruczek
5
+ *
6
+ * Orbital Object ToolKit is free software: you can redistribute it and/or modify it under the
7
+ * terms of the GNU Affero General Public License as published by the Free Software
8
+ * Foundation, either version 3 of the License, or (at your option) any later version.
9
+ *
10
+ * Orbital Object ToolKit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
+ * See the GNU Affero General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Affero General Public License along with
15
+ * Orbital Object ToolKit. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+
18
+ import { Earth, J2000, Vector3D } from 'ootk-core';
19
+ import { Force } from './Force';
20
+
21
+ // / Simple central-body gravity model.
22
+ export class Gravity implements Force {
23
+ // / Gravitational parameter _(km²/s³)_.
24
+ mu: number;
25
+
26
+ /**
27
+ * Create a new [Gravity] object with optional gravitational
28
+ * @param mu Gravitational parameter _(km²/s³)_.
29
+ */
30
+ constructor(mu: number = Earth.mu) {
31
+ this.mu = mu;
32
+ }
33
+
34
+ /**
35
+ * Calculates the gravitational force in spherical coordinates.
36
+ * @param state The J2000 state containing the position and velocity vectors.
37
+ * @returns The gravitational force vector in spherical coordinates.
38
+ */
39
+ private _spherical(state: J2000): Vector3D {
40
+ const rMag = state.position.magnitude();
41
+
42
+ return state.position.scale(-this.mu / (rMag * rMag * rMag));
43
+ }
44
+
45
+ /**
46
+ * Calculates the acceleration due to gravity at a given state.
47
+ * @param state The J2000 state at which to calculate the acceleration.
48
+ * @returns The acceleration vector.
49
+ */
50
+ acceleration(state: J2000): Vector3D {
51
+ return this._spherical(state);
52
+ }
53
+ }