astraeus 0.0.0-stage → 0.1.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 (407) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/LICENSE +21 -0
  3. package/NOTICE +14 -0
  4. package/README.md +108 -2
  5. package/data/ephemerides/planets/planets.json +1 -0
  6. package/data/moons/jupiter.json +3097 -0
  7. package/data/moons/neptune.json +517 -0
  8. package/data/moons/pluto.json +189 -0
  9. package/data/moons/saturn.json +7677 -0
  10. package/data/moons/uranus.json +825 -0
  11. package/data/orbits/callisto.json +192 -0
  12. package/data/orbits/charon.json +96 -0
  13. package/data/orbits/dione.json +102 -0
  14. package/data/orbits/enceladus.json +102 -0
  15. package/data/orbits/europa.json +189 -0
  16. package/data/orbits/ganymede.json +186 -0
  17. package/data/orbits/iapetus.json +102 -0
  18. package/data/orbits/io.json +181 -0
  19. package/data/orbits/mimas.json +170 -0
  20. package/data/orbits/rhea.json +170 -0
  21. package/data/orbits/tethys.json +170 -0
  22. package/data/orbits/titan.json +170 -0
  23. package/data/orbits/triton.json +230 -0
  24. package/data/rings/jupiter.json +24 -0
  25. package/data/rings/neptune.json +73 -0
  26. package/data/rings/saturn.json +69 -0
  27. package/data/rings/uranus.json +80 -0
  28. package/licenses/ERFA.txt +50 -0
  29. package/licenses/orbjs-MIT.txt +21 -0
  30. package/licenses/python-sgp4.txt +20 -0
  31. package/package.json +45 -4
  32. package/src/api/bodies.d.ts +40 -0
  33. package/src/api/bodies.js +35 -0
  34. package/src/api/data.d.ts +24 -0
  35. package/src/api/data.js +34 -0
  36. package/src/api/errors.d.ts +7 -0
  37. package/src/api/errors.js +9 -0
  38. package/src/api/index.d.ts +8 -0
  39. package/src/api/index.js +6 -0
  40. package/src/api/mount.d.ts +15 -0
  41. package/src/api/mount.js +26 -0
  42. package/src/api/scene.d.ts +76 -0
  43. package/src/api/scene.js +194 -0
  44. package/src/app/AnchorLabels.d.ts +17 -0
  45. package/src/app/AnchorLabels.js +46 -0
  46. package/src/app/App.d.ts +13 -0
  47. package/src/app/App.js +379 -0
  48. package/src/app/AstraeusScene.d.ts +133 -0
  49. package/src/app/AstraeusScene.js +47 -0
  50. package/src/app/AtmosphereGlow.d.ts +6 -0
  51. package/src/app/AtmosphereGlow.js +38 -0
  52. package/src/app/BodyMesh.d.ts +14 -0
  53. package/src/app/BodyMesh.js +20 -0
  54. package/src/app/BodySetLabels.d.ts +17 -0
  55. package/src/app/BodySetLabels.js +98 -0
  56. package/src/app/BodySetView.d.ts +50 -0
  57. package/src/app/BodySetView.js +206 -0
  58. package/src/app/BodyView.d.ts +37 -0
  59. package/src/app/BodyView.js +58 -0
  60. package/src/app/CameraController.d.ts +51 -0
  61. package/src/app/CameraController.js +163 -0
  62. package/src/app/DebugOverlay.d.ts +58 -0
  63. package/src/app/DebugOverlay.js +72 -0
  64. package/src/app/DeveloperSettings.d.ts +80 -0
  65. package/src/app/DeveloperSettings.js +40 -0
  66. package/src/app/FeatureMarkers.d.ts +76 -0
  67. package/src/app/FeatureMarkers.js +205 -0
  68. package/src/app/FrameRateSection.d.ts +16 -0
  69. package/src/app/FrameRateSection.js +35 -0
  70. package/src/app/KeplerPoints.d.ts +18 -0
  71. package/src/app/KeplerPoints.js +64 -0
  72. package/src/app/LayeredRender.d.ts +14 -0
  73. package/src/app/LayeredRender.js +35 -0
  74. package/src/app/OrbitSetView.d.ts +65 -0
  75. package/src/app/OrbitSetView.js +519 -0
  76. package/src/app/PathView.d.ts +135 -0
  77. package/src/app/PathView.js +574 -0
  78. package/src/app/PointsView.d.ts +103 -0
  79. package/src/app/PointsView.js +552 -0
  80. package/src/app/RingView.d.ts +34 -0
  81. package/src/app/RingView.js +96 -0
  82. package/src/app/SceneLabels.d.ts +22 -0
  83. package/src/app/SceneLabels.js +81 -0
  84. package/src/app/SettingControls.d.ts +32 -0
  85. package/src/app/SettingControls.js +19 -0
  86. package/src/app/SkyView.d.ts +63 -0
  87. package/src/app/SkyView.js +237 -0
  88. package/src/app/StoryMarkers.d.ts +38 -0
  89. package/src/app/StoryMarkers.js +81 -0
  90. package/src/app/TrackedBodyView.d.ts +36 -0
  91. package/src/app/TrackedBodyView.js +175 -0
  92. package/src/app/addressNavigation.d.ts +17 -0
  93. package/src/app/addressNavigation.js +16 -0
  94. package/src/app/bodyDraw.d.ts +118 -0
  95. package/src/app/bodyDraw.js +171 -0
  96. package/src/app/bodyMetrics.d.ts +19 -0
  97. package/src/app/bodyMetrics.js +85 -0
  98. package/src/app/bodySet.d.ts +113 -0
  99. package/src/app/bodySet.js +79 -0
  100. package/src/app/catalogueItem.d.ts +9 -0
  101. package/src/app/catalogueItem.js +17 -0
  102. package/src/app/ephemerisProvenance.d.ts +2 -0
  103. package/src/app/ephemerisProvenance.js +1 -0
  104. package/src/app/experienceDefinition.d.ts +265 -0
  105. package/src/app/experienceDefinition.js +257 -0
  106. package/src/app/floatingOrigin.d.ts +14 -0
  107. package/src/app/floatingOrigin.js +32 -0
  108. package/src/app/frameStats.d.ts +28 -0
  109. package/src/app/frameStats.js +68 -0
  110. package/src/app/keplerShader.d.ts +45 -0
  111. package/src/app/keplerShader.js +112 -0
  112. package/src/app/lighting.d.ts +9 -0
  113. package/src/app/lighting.js +24 -0
  114. package/src/app/metricReadouts.d.ts +10 -0
  115. package/src/app/metricReadouts.js +67 -0
  116. package/src/app/mission.d.ts +78 -0
  117. package/src/app/mission.js +80 -0
  118. package/src/app/pathRules.d.ts +52 -0
  119. package/src/app/pathRules.js +104 -0
  120. package/src/app/planetNeeds.d.ts +3 -0
  121. package/src/app/planetNeeds.js +6 -0
  122. package/src/app/renderCoordinates.d.ts +13 -0
  123. package/src/app/renderCoordinates.js +14 -0
  124. package/src/app/sceneBodies.d.ts +42 -0
  125. package/src/app/sceneBodies.js +58 -0
  126. package/src/app/sceneBodySets.d.ts +5 -0
  127. package/src/app/sceneBodySets.js +45 -0
  128. package/src/app/sceneCamera.d.ts +34 -0
  129. package/src/app/sceneCamera.js +110 -0
  130. package/src/app/sceneContentsHooks.d.ts +102 -0
  131. package/src/app/sceneContentsHooks.js +127 -0
  132. package/src/app/sceneDebug.d.ts +55 -0
  133. package/src/app/sceneDebug.js +76 -0
  134. package/src/app/sceneFrame.d.ts +175 -0
  135. package/src/app/sceneFrame.js +272 -0
  136. package/src/app/sceneFraming.d.ts +57 -0
  137. package/src/app/sceneFraming.js +99 -0
  138. package/src/app/sceneHooks.d.ts +28 -0
  139. package/src/app/sceneHooks.js +68 -0
  140. package/src/app/sceneLayout.d.ts +59 -0
  141. package/src/app/sceneLayout.js +97 -0
  142. package/src/app/sceneLights.d.ts +13 -0
  143. package/src/app/sceneLights.js +13 -0
  144. package/src/app/scenePicking.d.ts +97 -0
  145. package/src/app/scenePicking.js +102 -0
  146. package/src/app/scenePointer.d.ts +15 -0
  147. package/src/app/scenePointer.js +35 -0
  148. package/src/app/sceneSky.d.ts +9 -0
  149. package/src/app/sceneSky.js +17 -0
  150. package/src/app/sceneTargets.d.ts +34 -0
  151. package/src/app/sceneTargets.js +58 -0
  152. package/src/app/skyModel.d.ts +62 -0
  153. package/src/app/skyModel.js +114 -0
  154. package/src/app/style.css +206 -0
  155. package/src/app/useBodyTexture.d.ts +2 -0
  156. package/src/app/useBodyTexture.js +25 -0
  157. package/src/app/viewLink.d.ts +48 -0
  158. package/src/app/viewLink.js +117 -0
  159. package/src/app/viewUp.d.ts +24 -0
  160. package/src/app/viewUp.js +36 -0
  161. package/src/assets/bodies/earth.d.ts +18 -0
  162. package/src/assets/bodies/earth.js +33 -0
  163. package/src/assets/bodies/galileanMoons.d.ts +9 -0
  164. package/src/assets/bodies/galileanMoons.js +18 -0
  165. package/src/assets/bodies/io.d.ts +9 -0
  166. package/src/assets/bodies/io.js +12 -0
  167. package/src/assets/bodies/jupiter.d.ts +19 -0
  168. package/src/assets/bodies/jupiter.js +33 -0
  169. package/src/assets/bodies/jupiterMoonCatalogue.d.ts +3 -0
  170. package/src/assets/bodies/jupiterMoonCatalogue.js +4 -0
  171. package/src/assets/bodies/jupiterRings.d.ts +3 -0
  172. package/src/assets/bodies/jupiterRings.js +4 -0
  173. package/src/assets/bodies/mars.d.ts +15 -0
  174. package/src/assets/bodies/mars.js +29 -0
  175. package/src/assets/bodies/mercury.d.ts +15 -0
  176. package/src/assets/bodies/mercury.js +29 -0
  177. package/src/assets/bodies/moon.d.ts +16 -0
  178. package/src/assets/bodies/moon.js +30 -0
  179. package/src/assets/bodies/outerPlanetCatalogues.d.ts +11 -0
  180. package/src/assets/bodies/outerPlanetCatalogues.js +12 -0
  181. package/src/assets/bodies/planetSystemMaps.d.ts +18 -0
  182. package/src/assets/bodies/planetSystemMaps.js +65 -0
  183. package/src/assets/bodies/sun.d.ts +21 -0
  184. package/src/assets/bodies/sun.js +32 -0
  185. package/src/assets/bodies/swiftTuttle.d.ts +12 -0
  186. package/src/assets/bodies/swiftTuttle.js +13 -0
  187. package/src/assets/bodies/venus.d.ts +20 -0
  188. package/src/assets/bodies/venus.js +37 -0
  189. package/src/assets/catalogue.d.ts +37 -0
  190. package/src/assets/catalogue.js +106 -0
  191. package/src/assets/compositions.d.ts +52 -0
  192. package/src/assets/compositions.js +91 -0
  193. package/src/assets/licence.d.ts +44 -0
  194. package/src/assets/licence.js +20 -0
  195. package/src/assets/moonCatalogue.d.ts +47 -0
  196. package/src/assets/moonCatalogue.js +79 -0
  197. package/src/assets/orbitLook.d.ts +94 -0
  198. package/src/assets/orbitLook.js +46 -0
  199. package/src/assets/pictures.d.ts +17 -0
  200. package/src/assets/pictures.js +23 -0
  201. package/src/assets/rings.d.ts +31 -0
  202. package/src/assets/rings.js +45 -0
  203. package/src/assets/sky.d.ts +91 -0
  204. package/src/assets/sky.js +139 -0
  205. package/src/assets/stars/hyg-v42-naked-eye.json +1 -0
  206. package/src/assets/textures/earth-bmng-july-4k.jpg +0 -0
  207. package/src/assets/textures/jupiter-2k.jpg +0 -0
  208. package/src/assets/textures/mars-2k.jpg +0 -0
  209. package/src/assets/textures/mercury-2k.jpg +0 -0
  210. package/src/assets/textures/moon-lroc-2k.jpg +0 -0
  211. package/src/assets/textures/neptune-2k.jpg +0 -0
  212. package/src/assets/textures/saturn-2k.jpg +0 -0
  213. package/src/assets/textures/sun-2k.jpg +0 -0
  214. package/src/assets/textures/uranus-2k.jpg +0 -0
  215. package/src/assets/textures/venus-2k-balanced.jpg +0 -0
  216. package/src/assets/visual.d.ts +56 -0
  217. package/src/assets/visual.js +1 -0
  218. package/src/core/astronomyAdapter.d.ts +13 -0
  219. package/src/core/astronomyAdapter.js +88 -0
  220. package/src/core/bodies/earth.d.ts +7 -0
  221. package/src/core/bodies/earth.js +38 -0
  222. package/src/core/bodies/index.d.ts +16 -0
  223. package/src/core/bodies/index.js +45 -0
  224. package/src/core/bodies/io.d.ts +54 -0
  225. package/src/core/bodies/io.js +120 -0
  226. package/src/core/bodies/jupiter.d.ts +8 -0
  227. package/src/core/bodies/jupiter.js +40 -0
  228. package/src/core/bodies/jupiterData.d.ts +2 -0
  229. package/src/core/bodies/jupiterData.js +9 -0
  230. package/src/core/bodies/jupiterMoons.d.ts +31 -0
  231. package/src/core/bodies/jupiterMoons.js +44 -0
  232. package/src/core/bodies/mars.d.ts +6 -0
  233. package/src/core/bodies/mars.js +34 -0
  234. package/src/core/bodies/mercury.d.ts +6 -0
  235. package/src/core/bodies/mercury.js +32 -0
  236. package/src/core/bodies/moon.d.ts +3 -0
  237. package/src/core/bodies/moon.js +36 -0
  238. package/src/core/bodies/moonSystem.d.ts +98 -0
  239. package/src/core/bodies/moonSystem.js +151 -0
  240. package/src/core/bodies/outerPlanetData.d.ts +7 -0
  241. package/src/core/bodies/outerPlanetData.js +19 -0
  242. package/src/core/bodies/outerPlanets.d.ts +23 -0
  243. package/src/core/bodies/outerPlanets.js +68 -0
  244. package/src/core/bodies/planetMoons.d.ts +28 -0
  245. package/src/core/bodies/planetMoons.js +86 -0
  246. package/src/core/bodies/planetRecords.d.ts +8 -0
  247. package/src/core/bodies/planetRecords.js +19 -0
  248. package/src/core/bodies/planetTrajectory.d.ts +10 -0
  249. package/src/core/bodies/planetTrajectory.js +31 -0
  250. package/src/core/bodies/sun.d.ts +3 -0
  251. package/src/core/bodies/sun.js +25 -0
  252. package/src/core/bodies/swiftTuttle.d.ts +46 -0
  253. package/src/core/bodies/swiftTuttle.js +104 -0
  254. package/src/core/bodies/venus.d.ts +6 -0
  255. package/src/core/bodies/venus.js +34 -0
  256. package/src/core/body.d.ts +45 -0
  257. package/src/core/body.js +8 -0
  258. package/src/core/bodyOrientation.d.ts +8 -0
  259. package/src/core/bodyOrientation.js +92 -0
  260. package/src/core/chebyshev.d.ts +12 -0
  261. package/src/core/chebyshev.js +38 -0
  262. package/src/core/chebyshevEphemeris.d.ts +93 -0
  263. package/src/core/chebyshevEphemeris.js +344 -0
  264. package/src/core/chebyshevSeries.d.ts +30 -0
  265. package/src/core/chebyshevSeries.js +89 -0
  266. package/src/core/clock.d.ts +28 -0
  267. package/src/core/clock.js +98 -0
  268. package/src/core/elementsBody.d.ts +94 -0
  269. package/src/core/elementsBody.js +201 -0
  270. package/src/core/ephemerisGroup.d.ts +36 -0
  271. package/src/core/ephemerisGroup.js +51 -0
  272. package/src/core/events.d.ts +9 -0
  273. package/src/core/events.js +18 -0
  274. package/src/core/fieldReaders.d.ts +14 -0
  275. package/src/core/fieldReaders.js +32 -0
  276. package/src/core/iauRotation.d.ts +59 -0
  277. package/src/core/iauRotation.js +72 -0
  278. package/src/core/illumination.d.ts +9 -0
  279. package/src/core/illumination.js +54 -0
  280. package/src/core/keplerAnomaly.d.ts +2 -0
  281. package/src/core/keplerAnomaly.js +8 -0
  282. package/src/core/keplerElements.d.ts +35 -0
  283. package/src/core/keplerElements.js +87 -0
  284. package/src/core/listedOrbitGroup.d.ts +64 -0
  285. package/src/core/listedOrbitGroup.js +221 -0
  286. package/src/core/moonTrajectory.d.ts +11 -0
  287. package/src/core/moonTrajectory.js +28 -0
  288. package/src/core/orbitGroup.d.ts +41 -0
  289. package/src/core/orbitGroup.js +141 -0
  290. package/src/core/orbitPeriod.d.ts +25 -0
  291. package/src/core/orbitPeriod.js +58 -0
  292. package/src/core/planetModels.d.ts +7 -0
  293. package/src/core/planetModels.js +43 -0
  294. package/src/core/planetSeries.d.ts +26 -0
  295. package/src/core/planetSeries.js +22 -0
  296. package/src/core/pointGroup.d.ts +51 -0
  297. package/src/core/pointGroup.js +49 -0
  298. package/src/core/provenance.d.ts +9 -0
  299. package/src/core/provenance.js +14 -0
  300. package/src/core/referenceCenters.d.ts +6 -0
  301. package/src/core/referenceCenters.js +55 -0
  302. package/src/core/sampledTrajectory.d.ts +28 -0
  303. package/src/core/sampledTrajectory.js +127 -0
  304. package/src/core/satelliteMeanElements.d.ts +78 -0
  305. package/src/core/satelliteMeanElements.js +81 -0
  306. package/src/core/scalePolicy.d.ts +44 -0
  307. package/src/core/scalePolicy.js +58 -0
  308. package/src/core/state.d.ts +30 -0
  309. package/src/core/state.js +66 -0
  310. package/src/core/stateResolver.d.ts +16 -0
  311. package/src/core/stateResolver.js +126 -0
  312. package/src/core/sunCentredSources.d.ts +61 -0
  313. package/src/core/sunCentredSources.js +179 -0
  314. package/src/core/timeScale.d.ts +28 -0
  315. package/src/core/timeScale.js +81 -0
  316. package/src/core/timeWindow.d.ts +33 -0
  317. package/src/core/timeWindow.js +112 -0
  318. package/src/core/trajectory.d.ts +13 -0
  319. package/src/core/trajectory.js +1 -0
  320. package/src/core/twoBodyAdapter.d.ts +30 -0
  321. package/src/core/twoBodyAdapter.js +45 -0
  322. package/src/experiences/apollo11/spacecraftMetrics.d.ts +34 -0
  323. package/src/experiences/apollo11/spacecraftMetrics.js +142 -0
  324. package/src/experiences/settingsFields.d.ts +8 -0
  325. package/src/experiences/settingsFields.js +12 -0
  326. package/src/experiences/showers/showerChoice.d.ts +25 -0
  327. package/src/experiences/showers/showerChoice.js +19 -0
  328. package/src/shell/AstraeusShell.d.ts +66 -0
  329. package/src/shell/AstraeusShell.js +223 -0
  330. package/src/shell/Collapsible.d.ts +23 -0
  331. package/src/shell/Collapsible.js +43 -0
  332. package/src/shell/ControlsDrawer.d.ts +16 -0
  333. package/src/shell/ControlsDrawer.js +18 -0
  334. package/src/shell/InfoPanel.d.ts +13 -0
  335. package/src/shell/InfoPanel.js +20 -0
  336. package/src/shell/Label.d.ts +10 -0
  337. package/src/shell/Label.js +15 -0
  338. package/src/shell/MetricVisual.d.ts +5 -0
  339. package/src/shell/MetricVisual.js +114 -0
  340. package/src/shell/MoonFamilyPanel.d.ts +16 -0
  341. package/src/shell/MoonFamilyPanel.js +28 -0
  342. package/src/shell/ObjectControls.d.ts +13 -0
  343. package/src/shell/ObjectControls.js +18 -0
  344. package/src/shell/ProvenanceBadge.d.ts +5 -0
  345. package/src/shell/ProvenanceBadge.js +9 -0
  346. package/src/shell/ScaleControl.d.ts +14 -0
  347. package/src/shell/ScaleControl.js +99 -0
  348. package/src/shell/Sources.d.ts +9 -0
  349. package/src/shell/Sources.js +9 -0
  350. package/src/shell/StoryPanelView.d.ts +18 -0
  351. package/src/shell/StoryPanelView.js +24 -0
  352. package/src/shell/SwitchControl.d.ts +24 -0
  353. package/src/shell/SwitchControl.js +26 -0
  354. package/src/shell/TimelineBar.css +120 -0
  355. package/src/shell/TimelineBar.d.ts +48 -0
  356. package/src/shell/TimelineBar.js +76 -0
  357. package/src/shell/TopBar.css +74 -0
  358. package/src/shell/TopBar.d.ts +28 -0
  359. package/src/shell/TopBar.js +14 -0
  360. package/src/shell/bodyFeatures.d.ts +51 -0
  361. package/src/shell/bodyFeatures.js +24 -0
  362. package/src/shell/bootLoader.d.ts +17 -0
  363. package/src/shell/bootLoader.js +73 -0
  364. package/src/shell/controls.css +108 -0
  365. package/src/shell/embedded.css +36 -0
  366. package/src/shell/embedded.d.ts +2 -0
  367. package/src/shell/embedded.js +15 -0
  368. package/src/shell/experience.d.ts +72 -0
  369. package/src/shell/experience.js +1 -0
  370. package/src/shell/infoModel.d.ts +43 -0
  371. package/src/shell/infoModel.js +80 -0
  372. package/src/shell/metrics.d.ts +202 -0
  373. package/src/shell/metrics.js +224 -0
  374. package/src/shell/moonFamilies.d.ts +51 -0
  375. package/src/shell/moonFamilies.js +34 -0
  376. package/src/shell/objectModel.d.ts +18 -0
  377. package/src/shell/objectModel.js +34 -0
  378. package/src/shell/phone.css +179 -0
  379. package/src/shell/phoneLayout.d.ts +29 -0
  380. package/src/shell/phoneLayout.js +48 -0
  381. package/src/shell/scaleModel.d.ts +16 -0
  382. package/src/shell/scaleModel.js +42 -0
  383. package/src/shell/storyPanels.d.ts +69 -0
  384. package/src/shell/storyPanels.js +134 -0
  385. package/src/shell/style.css +378 -0
  386. package/src/shell/timelineGlow.d.ts +43 -0
  387. package/src/shell/timelineGlow.js +86 -0
  388. package/src/shell/timelineModel.d.ts +65 -0
  389. package/src/shell/timelineModel.js +153 -0
  390. package/src/shell/topBarIcons.d.ts +13 -0
  391. package/src/shell/topBarIcons.js +15 -0
  392. package/src/shell/useDrawerSwipe.d.ts +22 -0
  393. package/src/shell/useDrawerSwipe.js +35 -0
  394. package/src/shell/useDrawers.d.ts +11 -0
  395. package/src/shell/useDrawers.js +29 -0
  396. package/src/shell/useStoryPanels.d.ts +19 -0
  397. package/src/shell/useStoryPanels.js +55 -0
  398. package/src/shell/useSwipeToDismiss.d.ts +6 -0
  399. package/src/shell/useSwipeToDismiss.js +46 -0
  400. package/src/synthetic/syntheticDefinition.d.ts +5 -0
  401. package/src/synthetic/syntheticDefinition.js +183 -0
  402. package/src/synthetic/syntheticEccentricDefinition.d.ts +18 -0
  403. package/src/synthetic/syntheticEccentricDefinition.js +50 -0
  404. package/src/synthetic/syntheticListedDefinition.d.ts +20 -0
  405. package/src/synthetic/syntheticListedDefinition.js +135 -0
  406. package/src/synthetic/syntheticRingDefinition.d.ts +20 -0
  407. package/src/synthetic/syntheticRingDefinition.js +215 -0
@@ -0,0 +1,141 @@
1
+ import { gravitationalParameterOf, keplerElementsFromStates } from "./keplerElements.js";
2
+ import { createProvenance } from "./provenance.js";
3
+ import { assertFillBuffer, assertMemberRange, assertGroupCount, assertMemberIndex, assertWithinBounds, GroupElementsError, memberState, } from "./pointGroup.js";
4
+ import { assertUtcUnixMs, EQJ } from "./state.js";
5
+ const ELEMENT_KEYS = [
6
+ "semiMajorAxisKm",
7
+ "eccentricity",
8
+ "inclinationDeg",
9
+ "raanDeg",
10
+ "argumentOfPeriapsisDeg",
11
+ "trueAnomalyDeg",
12
+ ];
13
+ const RADIANS = Math.PI / 180;
14
+ const TWO_BODY_NOTE = "Motion is unperturbed two-body about the centre; no perturbations are modelled.";
15
+ // Local so a group never shares random state with other code (mulberry32, 32-bit seed).
16
+ export function seededRandom(seed) {
17
+ let state = seed >>> 0;
18
+ return () => {
19
+ state = (state + 0x6d2b79f5) >>> 0;
20
+ let t = state;
21
+ t = Math.imul(t ^ (t >>> 15), t | 1);
22
+ t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
23
+ return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
24
+ };
25
+ }
26
+ function assertInput(input) {
27
+ assertGroupCount(input.count);
28
+ assertUtcUnixMs(input.epochUtcMs);
29
+ if (!Number.isInteger(input.seed) || input.seed < 0 || input.seed > 0xffffffff) {
30
+ throw new GroupElementsError("seed must be an unsigned 32-bit integer");
31
+ }
32
+ for (const key of ELEMENT_KEYS) {
33
+ if (!Number.isFinite(input.base[key]))
34
+ throw new GroupElementsError(`base ${key} must be finite`);
35
+ const width = input.spread[key] ?? 0;
36
+ if (!Number.isFinite(width) || width < 0)
37
+ throw new GroupElementsError(`spread ${key} must be finite and not negative`);
38
+ }
39
+ }
40
+ function assertBoundOrbit(e, member) {
41
+ const bound = e.semiMajorAxisKm > 0 && e.eccentricity >= 0 && e.eccentricity < 1
42
+ && e.inclinationRad >= 0 && e.inclinationRad <= Math.PI;
43
+ if (!bound) {
44
+ throw new GroupElementsError(`member ${member} has elements outside a bound orbit; narrow the spread or change the base`);
45
+ }
46
+ }
47
+ /** Always draws six values per member so widening one element's spread never reshuffles the others. */
48
+ function sampleMembers(input) {
49
+ const random = seededRandom(input.seed);
50
+ const members = [];
51
+ for (let member = 0; member < input.count; member++) {
52
+ const value = (key) => input.base[key] + (2 * random() - 1) * (input.spread[key] ?? 0);
53
+ const elements = {
54
+ semiMajorAxisKm: value("semiMajorAxisKm"),
55
+ eccentricity: value("eccentricity"),
56
+ inclinationRad: value("inclinationDeg") * RADIANS,
57
+ raanRad: value("raanDeg") * RADIANS,
58
+ argumentOfPeriapsisRad: value("argumentOfPeriapsisDeg") * RADIANS,
59
+ trueAnomalyRad: value("trueAnomalyDeg") * RADIANS,
60
+ };
61
+ assertBoundOrbit(elements, member);
62
+ members.push(elements);
63
+ }
64
+ return members;
65
+ }
66
+ function rotateInto(matrix, v, out, offset) {
67
+ for (let row = 0; row < 3; row++) {
68
+ out[offset + row] = matrix[3 * row] * v[0] + matrix[3 * row + 1] * v[1] + matrix[3 * row + 2] * v[2];
69
+ }
70
+ }
71
+ /** Places each member on its orbit about `center`: six values per member (position, velocity), in J2000 equatorial axes. */
72
+ export function memberStatesOf(members, plane, center, adapter) {
73
+ const rotation = plane === "ecliptic-j2000" ? adapter.eclipticJ2000ToEqjMatrix() : null;
74
+ const states = new Float64Array(6 * members.length);
75
+ members.forEach((elements, member) => {
76
+ const { position, velocity } = adapter.elementsToState(elements, center);
77
+ if (rotation === null) {
78
+ states.set(position, 6 * member);
79
+ states.set(velocity, 6 * member + 3);
80
+ }
81
+ else {
82
+ rotateInto(rotation, position, states, 6 * member);
83
+ rotateInto(rotation, velocity, states, 6 * member + 3);
84
+ }
85
+ });
86
+ return states;
87
+ }
88
+ /**
89
+ * One member's position after `dtSeconds`, by the same propagation path as the batch, on a one-member view,
90
+ * so the single answer and the batch never disagree.
91
+ */
92
+ export function propagatedPositionOf(states, index, dtSeconds, center, adapter) {
93
+ const position = new Float64Array(3);
94
+ const single = new Float64Array(6);
95
+ single.set(states.subarray(6 * index, 6 * index + 6));
96
+ adapter.propagateMemberInto(single, 0, dtSeconds, center, position);
97
+ return position;
98
+ }
99
+ export function createOrbitGroup(input, adapter) {
100
+ assertInput(input);
101
+ const states = memberStatesOf(sampleMembers(input), input.plane, input.center, adapter);
102
+ const provenance = createProvenance({
103
+ ...input.provenance,
104
+ notes: `${input.provenance.notes} ${TWO_BODY_NOTE}`.trim(),
105
+ });
106
+ const { count, center, epochUtcMs, bounds } = input;
107
+ const fillPositionsRangeKm = (timeUtcMs, out, start, end) => {
108
+ assertUtcUnixMs(timeUtcMs);
109
+ assertWithinBounds(bounds, timeUtcMs);
110
+ assertFillBuffer(count, out);
111
+ assertMemberRange(count, start, end);
112
+ const dtSeconds = (timeUtcMs - epochUtcMs) / 1000;
113
+ for (let member = start; member < end; member++) {
114
+ adapter.propagateMemberInto(states, member, dtSeconds, center, out);
115
+ }
116
+ };
117
+ const fillPositionsKm = (timeUtcMs, out) => fillPositionsRangeKm(timeUtcMs, out, 0, count);
118
+ let kepler = null;
119
+ const group = {
120
+ id: input.id,
121
+ count,
122
+ center,
123
+ frame: EQJ,
124
+ ...(bounds === undefined ? {} : { bounds }),
125
+ provenance,
126
+ fillPositionsKm,
127
+ fillPositionsRangeKm,
128
+ keplerElements() {
129
+ kepler ??= keplerElementsFromStates(states, count, gravitationalParameterOf(adapter, center), epochUtcMs);
130
+ return kepler;
131
+ },
132
+ stateAt(index, timeUtcMs) {
133
+ assertMemberIndex(count, index);
134
+ assertUtcUnixMs(timeUtcMs);
135
+ assertWithinBounds(bounds, timeUtcMs);
136
+ const position = propagatedPositionOf(states, index, (timeUtcMs - epochUtcMs) / 1000, center, adapter);
137
+ return memberState(group, index, timeUtcMs, position);
138
+ },
139
+ };
140
+ return Object.freeze(group);
141
+ }
@@ -0,0 +1,25 @@
1
+ /** One osculating orbital period (s) of a body at position `r` (km) and velocity `v` (km/s) about a centre of `gm` (km^3/s^2); Infinity when unbound. */
2
+ export declare function osculatingPeriodS(r: ArrayLike<number>, v: ArrayLike<number>, gm: number): number;
3
+ /**
4
+ * A system whose centre and one big moon circle their common balance point (Pluto and Charon): that moon's body id and its GM (km^3/s^2).
5
+ * Data a moon system names, never a check on one planet in code.
6
+ */
7
+ export interface BalancePoint {
8
+ readonly body: string;
9
+ readonly gmKm3S2: number;
10
+ }
11
+ /** How far (as a share of the partner's centre-relative position) the centre sits from the balance point, towards the side away from the partner. */
12
+ export declare function balanceShare(centreGmKm3S2: number, partner: BalancePoint): number;
13
+ /**
14
+ * The orbital period (s) of a body whose centre-relative state is `r`, `v`, in a system that names a balance point: the partner itself orbits the
15
+ * centre with the pair's GM; any other body orbits the balance point, so its state is moved there first (the centre's own reflex motion would
16
+ * otherwise corrupt the period, I-056). `partnerR` and `partnerV` are the partner's centre-relative state at the same time.
17
+ */
18
+ export declare function periodAboutBalanceS(r: ArrayLike<number>, v: ArrayLike<number>, centreGmKm3S2: number, balance: BalancePoint | undefined, isPartner: boolean, partnerR: ArrayLike<number>, partnerV: ArrayLike<number>): number;
19
+ /**
20
+ * The mean orbital period (s) of a body whose place (km about the line's centre) `positionInto` gives, found from its own motion: the angle it
21
+ * sweeps over a short arc, read at four equally spaced phases back from `timeUtcMs` and averaged. An osculating period reads the instantaneous
22
+ * state, which a perturbed orbit (Pluto's small moons, circling a binary) does not keep for a lap; this is the lap the line must span (I-056).
23
+ * `guessS` (an osculating period) fixes the phase spacing and the arc and is returned when the arc cannot be read (the data does not reach back).
24
+ */
25
+ export declare function meanPeriodS(positionInto: (timeUtcMs: number, out: Float64Array) => void, timeUtcMs: number, guessS: number): number;
@@ -0,0 +1,58 @@
1
+ /** One osculating orbital period (s) of a body at position `r` (km) and velocity `v` (km/s) about a centre of `gm` (km^3/s^2); Infinity when unbound. */
2
+ export function osculatingPeriodS(r, v, gm) {
3
+ const radius = Math.hypot(r[0], r[1], r[2]);
4
+ const energy = (v[0] * v[0] + v[1] * v[1] + v[2] * v[2]) / 2 - gm / radius;
5
+ if (!(radius > 0) || !(energy < 0))
6
+ return Number.POSITIVE_INFINITY;
7
+ const a = -gm / (2 * energy);
8
+ return 2 * Math.PI * Math.sqrt((a * a * a) / gm);
9
+ }
10
+ /** How far (as a share of the partner's centre-relative position) the centre sits from the balance point, towards the side away from the partner. */
11
+ export function balanceShare(centreGmKm3S2, partner) {
12
+ return partner.gmKm3S2 / (centreGmKm3S2 + partner.gmKm3S2);
13
+ }
14
+ /**
15
+ * The orbital period (s) of a body whose centre-relative state is `r`, `v`, in a system that names a balance point: the partner itself orbits the
16
+ * centre with the pair's GM; any other body orbits the balance point, so its state is moved there first (the centre's own reflex motion would
17
+ * otherwise corrupt the period, I-056). `partnerR` and `partnerV` are the partner's centre-relative state at the same time.
18
+ */
19
+ export function periodAboutBalanceS(r, v, centreGmKm3S2, balance, isPartner, partnerR, partnerV) {
20
+ if (balance === undefined)
21
+ return osculatingPeriodS(r, v, centreGmKm3S2);
22
+ const gm = centreGmKm3S2 + balance.gmKm3S2;
23
+ if (isPartner)
24
+ return osculatingPeriodS(r, v, gm);
25
+ const f = balanceShare(centreGmKm3S2, balance);
26
+ return osculatingPeriodS([r[0] - f * partnerR[0], r[1] - f * partnerR[1], r[2] - f * partnerR[2]], [v[0] - f * partnerV[0], v[1] - f * partnerV[1], v[2] - f * partnerV[2]], gm);
27
+ }
28
+ /** How many phases of the orbit the mean motion is read at (equal spacing cancels the first and second harmonics of an eccentric orbit's rate). */
29
+ const MEAN_MOTION_PHASES = 4;
30
+ /** The short arc (a share of the first-guess period) each rate is measured over. */
31
+ const MEAN_MOTION_ARC = 1 / 256;
32
+ /**
33
+ * The mean orbital period (s) of a body whose place (km about the line's centre) `positionInto` gives, found from its own motion: the angle it
34
+ * sweeps over a short arc, read at four equally spaced phases back from `timeUtcMs` and averaged. An osculating period reads the instantaneous
35
+ * state, which a perturbed orbit (Pluto's small moons, circling a binary) does not keep for a lap; this is the lap the line must span (I-056).
36
+ * `guessS` (an osculating period) fixes the phase spacing and the arc and is returned when the arc cannot be read (the data does not reach back).
37
+ */
38
+ export function meanPeriodS(positionInto, timeUtcMs, guessS) {
39
+ if (!(guessS > 0) || !Number.isFinite(guessS))
40
+ return guessS;
41
+ const arcMs = Math.max(1, Math.round(guessS * 1000 * MEAN_MOTION_ARC));
42
+ const a = new Float64Array(3);
43
+ const b = new Float64Array(3);
44
+ let rate = 0;
45
+ try {
46
+ for (let k = 0; k < MEAN_MOTION_PHASES; k += 1) {
47
+ const at = Math.round(timeUtcMs - (k * guessS * 1000) / MEAN_MOTION_PHASES);
48
+ positionInto(at - arcMs, a);
49
+ positionInto(at, b);
50
+ const cross = Math.hypot(a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]);
51
+ rate += Math.atan2(cross, a[0] * b[0] + a[1] * b[1] + a[2] * b[2]) / (arcMs / 1000);
52
+ }
53
+ }
54
+ catch {
55
+ return guessS;
56
+ }
57
+ return rate > 0 ? (2 * Math.PI * MEAN_MOTION_PHASES) / rate : guessS;
58
+ }
@@ -0,0 +1,7 @@
1
+ import { type PlanetModels } from "./planetSeries.js";
2
+ /**
3
+ * The planet models from the stored curve fits (`data/ephemerides/planets/`, O-025 T-101): heliocentric ecliptic-J2000 positions as piecewise
4
+ * Chebyshev series in TT, refitted from Orb's full VSOP87A series within 1 km (Pluto: fitted to Horizons states; tools/import/planet-fits.mjs). UTC to TT uses the table stored
5
+ * beside them. Dates outside the fitted span (1969 to 2045) throw rather than extrapolate. Only planetSeries.ts imports this, lazily.
6
+ */
7
+ export declare function createPlanetModels(): PlanetModels;
@@ -0,0 +1,43 @@
1
+ import fits from "../../data/ephemerides/planets/planets.json";
2
+ import { chunkCovers, chunkPositionInto, decodeChunk } from "./chebyshevSeries.js";
3
+ import { PLANET_IDS } from "./planetSeries.js";
4
+ import { assertTimeScaleTable, ttMinusUtcSeconds } from "./timeScale.js";
5
+ /** The astronomical unit in km that the astronomy adapter multiplies the model's au by; the fits are stored in km with the same value. */
6
+ const AU_KM = 149_597_870.7;
7
+ const J2000_UNIX_MS = Date.UTC(2000, 0, 1, 12);
8
+ function decodeBase64(text) {
9
+ const binary = atob(text);
10
+ const bytes = new Uint8Array(binary.length);
11
+ for (let i = 0; i < binary.length; i += 1)
12
+ bytes[i] = binary.charCodeAt(i);
13
+ return bytes;
14
+ }
15
+ function planetModel(chunk, table) {
16
+ const km = new Float64Array(3);
17
+ return {
18
+ xyz(date) {
19
+ const utcMs = date.getTime();
20
+ const tt = (utcMs - J2000_UNIX_MS) / 1000 + ttMinusUtcSeconds(table, utcMs);
21
+ if (!chunkCovers(chunk, tt))
22
+ throw new RangeError(`the planet curve fits do not cover ${date.toISOString()}`);
23
+ chunkPositionInto(chunk, tt, km, 0);
24
+ return { x: km[0] / AU_KM, y: km[1] / AU_KM, z: km[2] / AU_KM, coordinate_keywords: "ecliptic rectangular j2000", unit_keywords: "au" };
25
+ },
26
+ };
27
+ }
28
+ /**
29
+ * The planet models from the stored curve fits (`data/ephemerides/planets/`, O-025 T-101): heliocentric ecliptic-J2000 positions as piecewise
30
+ * Chebyshev series in TT, refitted from Orb's full VSOP87A series within 1 km (Pluto: fitted to Horizons states; tools/import/planet-fits.mjs). UTC to TT uses the table stored
31
+ * beside them. Dates outside the fitted span (1969 to 2045) throw rather than extrapolate. Only planetSeries.ts imports this, lazily.
32
+ */
33
+ export function createPlanetModels() {
34
+ const table = fits.timeScale;
35
+ assertTimeScaleTable(table);
36
+ const planets = fits.planets;
37
+ const model = (id) => {
38
+ const p = planets[id];
39
+ const chunk = decodeChunk(decodeBase64(p.data), { startTdbS: p.startS, segmentSeconds: p.segmentSeconds, segmentCount: p.segmentCount, coefficientCount: p.coefficientCount, quantumKm: p.quantumKm });
40
+ return planetModel(chunk, table);
41
+ };
42
+ return Object.fromEntries(PLANET_IDS.map((id) => [id, model(id)]));
43
+ }
@@ -0,0 +1,26 @@
1
+ /** Planets the astronomy adapter has a heliocentric model for (Saturn to Pluto added by O-033 T-114). */
2
+ export type PlanetId = "mercury" | "venus" | "mars" | "jupiter" | "saturn" | "uranus" | "neptune" | "pluto";
3
+ export declare const PLANET_IDS: readonly PlanetId[];
4
+ export declare function isPlanetId(id: string): id is PlanetId;
5
+ /** One planet's heliocentric ecliptic-J2000 model (curve fits of VSOP87A), as the astronomy adapter reads it. */
6
+ export interface PlanetModel {
7
+ xyz(date: Date): {
8
+ readonly x: number;
9
+ readonly y: number;
10
+ readonly z: number;
11
+ readonly coordinate_keywords: string;
12
+ readonly unit_keywords: string;
13
+ };
14
+ }
15
+ export type PlanetModels = {
16
+ readonly [P in PlanetId]: PlanetModel;
17
+ };
18
+ /**
19
+ * Builds the planet models, once, from the stored curve fits of the full VSOP87A series (Pluto: of JPL Horizons states) (O-025 T-101, O-033 T-114; the library's compact
20
+ * default tables are off by tens of thousands of km, docs/ASTRONOMY_VALIDATION.md, and its full series were about 0.8 MB of code).
21
+ * The fits are a separate chunk fetched only when a mounted composition contains a planet; an experience without one never
22
+ * downloads them (I-022).
23
+ */
24
+ export declare function loadPlanetSeries(): Promise<void>;
25
+ /** The loaded planet models; throws before `loadPlanetSeries()` resolved rather than falling back to the compact tables. */
26
+ export declare function planetModels(): PlanetModels;
@@ -0,0 +1,22 @@
1
+ export const PLANET_IDS = Object.freeze(["mercury", "venus", "mars", "jupiter", "saturn", "uranus", "neptune", "pluto"]);
2
+ export function isPlanetId(id) {
3
+ return PLANET_IDS.includes(id);
4
+ }
5
+ let loading;
6
+ let models;
7
+ /**
8
+ * Builds the planet models, once, from the stored curve fits of the full VSOP87A series (Pluto: of JPL Horizons states) (O-025 T-101, O-033 T-114; the library's compact
9
+ * default tables are off by tens of thousands of km, docs/ASTRONOMY_VALIDATION.md, and its full series were about 0.8 MB of code).
10
+ * The fits are a separate chunk fetched only when a mounted composition contains a planet; an experience without one never
11
+ * downloads them (I-022).
12
+ */
13
+ export function loadPlanetSeries() {
14
+ loading ??= import("./planetModels.js").then((module) => { models = module.createPlanetModels(); });
15
+ return loading;
16
+ }
17
+ /** The loaded planet models; throws before `loadPlanetSeries()` resolved rather than falling back to the compact tables. */
18
+ export function planetModels() {
19
+ if (models === undefined)
20
+ throw new Error("the planet series are not loaded: await loadPlanetSeries() before mounting a composition with a planet");
21
+ return models;
22
+ }
@@ -0,0 +1,51 @@
1
+ import type { BodyId, CenterId } from "./body.js";
2
+ import type { KeplerElements } from "./keplerElements.js";
3
+ import type { Provenance } from "./provenance.js";
4
+ import { type FrameId, type State } from "./state.js";
5
+ import type { TimeBounds } from "./trajectory.js";
6
+ export declare class GroupBoundsError extends RangeError {
7
+ readonly name = "GroupBoundsError";
8
+ }
9
+ export declare class GroupBufferError extends RangeError {
10
+ readonly name = "GroupBufferError";
11
+ }
12
+ export declare class GroupCountError extends RangeError {
13
+ readonly name = "GroupCountError";
14
+ }
15
+ export declare class GroupElementsError extends TypeError {
16
+ readonly name = "GroupElementsError";
17
+ }
18
+ /**
19
+ * Positions for a whole population at once. Members are anonymous: the batch fill avoids the
20
+ * per-member State allocation that makes one Trajectory per member too slow for thousands.
21
+ */
22
+ export interface PointGroup {
23
+ readonly id: BodyId;
24
+ readonly count: number;
25
+ readonly center: CenterId;
26
+ readonly frame: FrameId;
27
+ /** Absent means the group is valid for every time. */
28
+ readonly bounds?: TimeBounds;
29
+ readonly provenance: Provenance;
30
+ /** Writes every member's position (EQJ km, x y z per member) into `out`, which must hold 3 × count values. */
31
+ fillPositionsKm(timeUtcMs: number, out: Float64Array): void;
32
+ /**
33
+ * Optional: the same values as `fillPositionsKm` for members `start` up to (not including) `end` only; the other
34
+ * entries of `out` are left alone. Lets the points layer spread a large fill over several frames.
35
+ */
36
+ fillPositionsRangeKm?(timeUtcMs: number, out: Float64Array, start: number, end: number): void;
37
+ /**
38
+ * Optional: every member's orbit as an ellipse with its place along it at an epoch (see `KeplerElements`), for a presentation that
39
+ * evaluates the positions itself. Evaluating them reproduces `fillPositionsKm`. Absent for groups that are not two-body orbits.
40
+ */
41
+ keplerElements?(): KeplerElements;
42
+ /** One member as an ordinary State; positionKm equals the batch values for the same time. */
43
+ stateAt(index: number, timeUtcMs: number): State;
44
+ }
45
+ export declare function assertGroupCount(count: number): void;
46
+ export declare function assertWithinBounds(bounds: TimeBounds | undefined, timeUtcMs: number): void;
47
+ export declare function assertFillBuffer(count: number, out: Float64Array): void;
48
+ export declare function assertMemberRange(count: number, start: number, end: number): void;
49
+ export declare function assertMemberIndex(count: number, index: number): void;
50
+ /** Builds a member's State from its already-computed position; shared so every group reads members the same way. */
51
+ export declare function memberState(group: Pick<PointGroup, "id" | "center" | "bounds">, index: number, timeUtcMs: number, positionKm: ArrayLike<number>): State;
@@ -0,0 +1,49 @@
1
+ import { createState, EQJ } from "./state.js";
2
+ export class GroupBoundsError extends RangeError {
3
+ name = "GroupBoundsError";
4
+ }
5
+ export class GroupBufferError extends RangeError {
6
+ name = "GroupBufferError";
7
+ }
8
+ export class GroupCountError extends RangeError {
9
+ name = "GroupCountError";
10
+ }
11
+ export class GroupElementsError extends TypeError {
12
+ name = "GroupElementsError";
13
+ }
14
+ export function assertGroupCount(count) {
15
+ if (!Number.isSafeInteger(count) || count <= 0) {
16
+ throw new GroupCountError("group count must be a positive integer");
17
+ }
18
+ }
19
+ export function assertWithinBounds(bounds, timeUtcMs) {
20
+ if (bounds !== undefined && (timeUtcMs < bounds.startUtcMs || timeUtcMs > bounds.endUtcMs)) {
21
+ throw new GroupBoundsError(`time ${timeUtcMs} is outside the group's bounds`);
22
+ }
23
+ }
24
+ export function assertFillBuffer(count, out) {
25
+ if (out.length !== 3 * count) {
26
+ throw new GroupBufferError(`fill buffer must hold ${3 * count} values, received ${out.length}`);
27
+ }
28
+ }
29
+ export function assertMemberRange(count, start, end) {
30
+ if (!Number.isInteger(start) || !Number.isInteger(end) || start < 0 || end > count || start > end) {
31
+ throw new RangeError(`member range must satisfy 0 <= start <= end <= ${count}`);
32
+ }
33
+ }
34
+ export function assertMemberIndex(count, index) {
35
+ if (!Number.isInteger(index) || index < 0 || index >= count) {
36
+ throw new RangeError(`member index must be an integer from 0 to ${count - 1}`);
37
+ }
38
+ }
39
+ /** Builds a member's State from its already-computed position; shared so every group reads members the same way. */
40
+ export function memberState(group, index, timeUtcMs, positionKm) {
41
+ return createState({
42
+ body: `${group.id}:${index}`,
43
+ center: group.center,
44
+ timeUtcMs,
45
+ frame: EQJ,
46
+ positionKm,
47
+ orientation: null,
48
+ });
49
+ }
@@ -0,0 +1,9 @@
1
+ export type ProvenanceSourceType = "ephemeris" | "observed" | "reconstructed" | "illustrative";
2
+ /** Where a Trajectory's samples came from and how far to trust them. Never affects State. */
3
+ export interface Provenance {
4
+ readonly sourceType: ProvenanceSourceType;
5
+ readonly sources: readonly string[];
6
+ readonly accuracy: string;
7
+ readonly notes: string;
8
+ }
9
+ export declare function createProvenance(input: Provenance): Provenance;
@@ -0,0 +1,14 @@
1
+ const SOURCE_TYPES = ["ephemeris", "observed", "reconstructed", "illustrative"];
2
+ export function createProvenance(input) {
3
+ if (!SOURCE_TYPES.includes(input.sourceType))
4
+ throw new RangeError("provenance sourceType is not recognised");
5
+ if (input.sources.some((source) => typeof source !== "string" || source.length === 0)) {
6
+ throw new TypeError("provenance sources must be non-empty strings");
7
+ }
8
+ return Object.freeze({
9
+ sourceType: input.sourceType,
10
+ sources: Object.freeze([...input.sources]),
11
+ accuracy: input.accuracy,
12
+ notes: input.notes,
13
+ });
14
+ }
@@ -0,0 +1,6 @@
1
+ import type { AstronomyAdapter } from "./astronomyAdapter.js";
2
+ import { type CenteredPosition, type State } from "./state.js";
3
+ export declare function composeCenteredPositions(bodyFromOrigin: CenteredPosition, originFromCenter: CenteredPosition): CenteredPosition;
4
+ export declare function inverseCenteredPosition(position: CenteredPosition): CenteredPosition;
5
+ export declare function earthStateAt(adapter: AstronomyAdapter, timeUtcMs: number): State;
6
+ export declare function sunPositionFromEarthAt(adapter: AstronomyAdapter, timeUtcMs: number): CenteredPosition;
@@ -0,0 +1,55 @@
1
+ import { assertCenterId } from "./body.js";
2
+ import { earthOrientationFromEcefToEqj } from "./bodyOrientation.js";
3
+ import { createCenteredPosition, createState, EQJ } from "./state.js";
4
+ function sameEpochAndFrame(a, b) {
5
+ if (a.timeUtcMs !== b.timeUtcMs)
6
+ throw new RangeError("center composition requires identical timestamps");
7
+ if (a.frame !== b.frame)
8
+ throw new RangeError("center composition requires identical frames");
9
+ }
10
+ export function composeCenteredPositions(bodyFromOrigin, originFromCenter) {
11
+ sameEpochAndFrame(bodyFromOrigin, originFromCenter);
12
+ if (bodyFromOrigin.center !== originFromCenter.body) {
13
+ throw new RangeError("center composition requires the second body's identity to match the first center");
14
+ }
15
+ return createCenteredPosition({
16
+ body: bodyFromOrigin.body,
17
+ center: originFromCenter.center,
18
+ timeUtcMs: bodyFromOrigin.timeUtcMs,
19
+ frame: bodyFromOrigin.frame,
20
+ positionKm: [
21
+ bodyFromOrigin.positionKm[0] + originFromCenter.positionKm[0],
22
+ bodyFromOrigin.positionKm[1] + originFromCenter.positionKm[1],
23
+ bodyFromOrigin.positionKm[2] + originFromCenter.positionKm[2],
24
+ ],
25
+ });
26
+ }
27
+ export function inverseCenteredPosition(position) {
28
+ assertCenterId(position.body);
29
+ return createCenteredPosition({
30
+ body: position.center,
31
+ center: position.body,
32
+ timeUtcMs: position.timeUtcMs,
33
+ frame: position.frame,
34
+ positionKm: [-position.positionKm[0], -position.positionKm[1], -position.positionKm[2]],
35
+ });
36
+ }
37
+ export function earthStateAt(adapter, timeUtcMs) {
38
+ return createState({
39
+ body: "earth",
40
+ center: "sun",
41
+ timeUtcMs,
42
+ frame: EQJ,
43
+ positionKm: adapter.earthPositionFromSunKm(timeUtcMs),
44
+ orientation: earthOrientationFromEcefToEqj(adapter.earthFixedToEqjMatrix(timeUtcMs)),
45
+ });
46
+ }
47
+ export function sunPositionFromEarthAt(adapter, timeUtcMs) {
48
+ return createCenteredPosition({
49
+ body: "sun",
50
+ center: "earth",
51
+ timeUtcMs,
52
+ frame: EQJ,
53
+ positionKm: adapter.sunPositionFromEarthKm(timeUtcMs),
54
+ });
55
+ }
@@ -0,0 +1,28 @@
1
+ import { type BodyId, type CenterId } from "./body.js";
2
+ import { type Provenance } from "./provenance.js";
3
+ import { type FrameId, type State } from "./state.js";
4
+ import type { TimeBounds, Trajectory } from "./trajectory.js";
5
+ export interface TrajectorySample {
6
+ readonly timeUtcMs: number;
7
+ readonly positionKm: ArrayLike<number>;
8
+ readonly velocityKmS?: ArrayLike<number>;
9
+ }
10
+ export interface SampledTrajectoryInput {
11
+ readonly body: BodyId;
12
+ readonly center: CenterId;
13
+ readonly frame?: FrameId;
14
+ readonly samples: readonly TrajectorySample[];
15
+ readonly provenance?: Provenance;
16
+ }
17
+ export declare class TrajectoryOutOfRangeError extends RangeError {
18
+ constructor(timeUtcMs: number, bounds: TimeBounds);
19
+ }
20
+ /** A bounded trajectory of discrete samples: cubic Hermite with velocity, linear without. */
21
+ export declare class SampledTrajectory implements Trajectory {
22
+ #private;
23
+ readonly body: BodyId;
24
+ readonly bounds: TimeBounds;
25
+ readonly provenance?: Provenance;
26
+ constructor(input: SampledTrajectoryInput);
27
+ stateAt(timeUtcMs: number, center?: CenterId): State;
28
+ }