@johnmorrisdotca/wakusei-planets 0.20.0 → 0.21.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 (83) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/NOTICE.md +9 -0
  3. package/README.md +34 -4
  4. package/dist/bodies/earth.js +13 -5
  5. package/dist/calendar.js +7 -6
  6. package/dist/clock.js +5 -6
  7. package/dist/coordinates.d.ts +7 -12
  8. package/dist/coordinates.js +19 -18
  9. package/dist/craft/cassini.d.ts +1 -0
  10. package/dist/craft/cassini.js +1131 -0
  11. package/dist/craft/galileo.d.ts +1 -0
  12. package/dist/craft/galileo.js +224 -0
  13. package/dist/craft/juno.d.ts +1 -0
  14. package/dist/craft/juno.js +640 -0
  15. package/dist/craft/newhorizons.d.ts +1 -0
  16. package/dist/craft/newhorizons.js +18 -0
  17. package/dist/craft/parker.d.ts +1 -0
  18. package/dist/craft/parker.js +221 -0
  19. package/dist/craft/pioneer10.d.ts +1 -0
  20. package/dist/craft/pioneer10.js +24 -0
  21. package/dist/craft/pioneer11.d.ts +1 -0
  22. package/dist/craft/pioneer11.js +34 -0
  23. package/dist/craft/voyager1.d.ts +1 -0
  24. package/dist/craft/voyager1.js +28 -0
  25. package/dist/craft/voyager2.d.ts +1 -0
  26. package/dist/craft/voyager2.js +43 -0
  27. package/dist/craft/webb.d.ts +1 -0
  28. package/dist/craft/webb.js +28 -0
  29. package/dist/data/craft.d.ts +23 -0
  30. package/dist/data/craft.js +53 -0
  31. package/dist/data/stars.d.ts +4 -0
  32. package/dist/data/stars.js +5088 -0
  33. package/dist/element.d.ts +1 -23
  34. package/dist/element.js +74 -110
  35. package/dist/ephemeris.d.ts +20 -0
  36. package/dist/ephemeris.js +51 -20
  37. package/dist/index.d.ts +1 -1
  38. package/dist/index.js +1 -1
  39. package/dist/portrait/element.d.ts +1 -0
  40. package/dist/portrait/element.js +27 -39
  41. package/dist/scene/basis.d.ts +3 -0
  42. package/dist/scene/basis.js +4 -0
  43. package/dist/scene/body.d.ts +2 -4
  44. package/dist/scene/body.js +55 -67
  45. package/dist/scene/fallback.d.ts +4 -0
  46. package/dist/scene/fallback.js +5 -0
  47. package/dist/scene/painter.js +10 -23
  48. package/dist/scene/store.d.ts +2 -2
  49. package/dist/scene/textures.d.ts +30 -0
  50. package/dist/scene/textures.js +47 -0
  51. package/dist/sidereal.d.ts +4 -0
  52. package/dist/sidereal.js +15 -9
  53. package/dist/sky/engine.d.ts +6 -15
  54. package/dist/sky/engine.js +9 -38
  55. package/dist/sky/frames.d.ts +3 -0
  56. package/dist/sky/frames.js +26 -0
  57. package/dist/sky/types.d.ts +20 -0
  58. package/dist/sky/types.js +1 -0
  59. package/dist/space/aim.d.ts +18 -0
  60. package/dist/space/aim.js +28 -0
  61. package/dist/space/element.d.ts +212 -0
  62. package/dist/space/element.js +524 -0
  63. package/dist/space/frame.d.ts +152 -0
  64. package/dist/space/frame.js +169 -0
  65. package/dist/space/index.d.ts +4 -0
  66. package/dist/space/index.js +5 -0
  67. package/dist/space/ride.d.ts +89 -0
  68. package/dist/space/ride.js +58 -0
  69. package/dist/space/scale.d.ts +126 -0
  70. package/dist/space/scale.js +139 -0
  71. package/dist/space/scene.d.ts +189 -0
  72. package/dist/space/scene.js +422 -0
  73. package/dist/spacecraft-facts.d.ts +114 -0
  74. package/dist/spacecraft-facts.js +215 -0
  75. package/dist/spacecraft.d.ts +134 -0
  76. package/dist/spacecraft.js +198 -0
  77. package/dist/stars.d.ts +160 -0
  78. package/dist/stars.js +193 -0
  79. package/dist/suncalc.js +4 -10
  80. package/dist/version.d.ts +1 -1
  81. package/dist/version.js +1 -1
  82. package/dist/when.js +6 -11
  83. package/package.json +53 -4
@@ -0,0 +1,114 @@
1
+ import type { PlanetId } from "./facts.ts";
2
+ /**
3
+ * The ten craft: `voyager1`, `voyager2`, `newhorizons`, `pioneer10`, `pioneer11`, `cassini`, `galileo`, `juno`, `parker` and `webb`.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * import { SPACECRAFT_IDS } from "@johnmorrisdotca/wakusei-planets/spacecraft";
8
+ *
9
+ * console.log(SPACECRAFT_IDS.join(", "));
10
+ * ```
11
+ */
12
+ export declare const SPACECRAFT_IDS: readonly ["voyager1", "voyager2", "newhorizons", "pioneer10", "pioneer11", "cassini", "galileo", "juno", "parker", "webb"];
13
+ /**
14
+ * The name of a craft: `voyager1`, `cassini`, `webb`...
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * import { SPACECRAFT_IDS, type SpacecraftId } from "@johnmorrisdotca/wakusei-planets/spacecraft";
19
+ *
20
+ * const id: SpacecraftId = SPACECRAFT_IDS[0];
21
+ * console.log(id);
22
+ * ```
23
+ */
24
+ export type SpacecraftId = (typeof SPACECRAFT_IDS)[number];
25
+ /**
26
+ * One thing that happened on a craft's voyage.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * import { SPACECRAFT, type SpacecraftEvent } from "@johnmorrisdotca/wakusei-planets/spacecraft";
31
+ *
32
+ * const jupiter: SpacecraftEvent = SPACECRAFT.voyager1.events.find((e) => e.body === "jupiter")!;
33
+ * console.log(new Date(jupiter.date).toISOString(), jupiter.name.en);
34
+ * ```
35
+ */
36
+ export interface SpacecraftEvent {
37
+ /** What happened: the launch, a flyby, going into orbit round a planet, getting to the place the craft works from, or the end of the mission. */
38
+ kind: "launch" | "flyby" | "orbit-insertion" | "arrival" | "end";
39
+ /** The moment, in milliseconds since 1970 (UTC). Where `precision` is "day", only the date is known: this is that day's noon. */
40
+ date: number;
41
+ /** "minute" where the page gives a time, "day" where it gives only a date. */
42
+ precision: "minute" | "day";
43
+ /** The name of the event in English and Japanese. */
44
+ name: {
45
+ en: string;
46
+ ja: string;
47
+ };
48
+ /** The planet (or Pluto) the event is at, when it is at one. A flyby of an asteroid or of Arrokoth has none. */
49
+ body?: PlanetId;
50
+ /** The closest the craft came, in kilometres, as NASA gives it: above the planet's cloud tops or the body's surface, or from a planet for the one distant pass (Cassini at Jupiter). Left out where NASA gives none. */
51
+ distanceKm?: number;
52
+ }
53
+ /**
54
+ * Facts about one craft.
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * import { SPACECRAFT, type SpacecraftFacts } from "@johnmorrisdotca/wakusei-planets/spacecraft";
59
+ *
60
+ * const cassini: SpacecraftFacts = SPACECRAFT.cassini;
61
+ * console.log(cassini.name.ja, cassini.agency, cassini.status);
62
+ * ```
63
+ */
64
+ export interface SpacecraftFacts {
65
+ id: SpacecraftId;
66
+ /** The craft's name in English and Japanese. */
67
+ name: {
68
+ en: string;
69
+ ja: string;
70
+ };
71
+ /** The agency or agencies. */
72
+ agency: string;
73
+ /** The launch: when, from where and on what. */
74
+ launch: {
75
+ date: number;
76
+ precision: "minute" | "day";
77
+ site: {
78
+ en: string;
79
+ ja: string;
80
+ };
81
+ vehicle: string;
82
+ };
83
+ /** The end of the mission (the last signal, or the planned plunge), in milliseconds since 1970 (UTC), or `undefined` while it goes on. */
84
+ end: number | undefined;
85
+ /** "active" while NASA's page lists the mission as active, else "ended". */
86
+ status: "active" | "ended";
87
+ /** NASA's page for the mission. */
88
+ url: string;
89
+ /** The craft's number in JPL Horizons. */
90
+ horizons: string;
91
+ /** The span of Horizons' record of the craft, in milliseconds since 1970 (UTC), which is the span `spacecraftPosition` answers for. The record begins about an hour after the launch; for a craft still flying, its end is Horizons' predicted path. */
92
+ record: {
93
+ start: number;
94
+ end: number;
95
+ };
96
+ /** Places where Horizons' record steps by more than the fit's error because two solutions meet there: at `date` (milliseconds since 1970, UTC) the position jumps by `km` kilometres, and a line drawn through the path should break. Empty where the record is smooth. */
97
+ joins: readonly {
98
+ date: number;
99
+ km: number;
100
+ }[];
101
+ /** The voyage, in order. */
102
+ events: readonly SpacecraftEvent[];
103
+ }
104
+ /**
105
+ * The ten craft and their facts, keyed by id.
106
+ *
107
+ * @example
108
+ * ```ts
109
+ * import { SPACECRAFT } from "@johnmorrisdotca/wakusei-planets/spacecraft";
110
+ *
111
+ * console.log(SPACECRAFT.voyager1.name.ja, new Date(SPACECRAFT.voyager1.launch.date).toISOString());
112
+ * ```
113
+ */
114
+ export declare const SPACECRAFT: Readonly<Record<SpacecraftId, SpacecraftFacts>>;
@@ -0,0 +1,215 @@
1
+ /**
2
+ * The ten craft: `voyager1`, `voyager2`, `newhorizons`, `pioneer10`, `pioneer11`, `cassini`, `galileo`, `juno`, `parker` and `webb`.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * import { SPACECRAFT_IDS } from "@johnmorrisdotca/wakusei-planets/spacecraft";
7
+ *
8
+ * console.log(SPACECRAFT_IDS.join(", "));
9
+ * ```
10
+ */
11
+ export const SPACECRAFT_IDS = ["voyager1", "voyager2", "newhorizons", "pioneer10", "pioneer11", "cassini", "galileo", "juno", "parker", "webb"];
12
+ const T = Date.UTC;
13
+ const noon = (y, m, d) => T(y, m - 1, d, 12);
14
+ const ev = (kind, date, precision, en, ja, more = {}) => ({ kind, date, precision, name: { en, ja }, ...more });
15
+ const flyby = (date, precision, en, ja, body, distanceKm) => ev("flyby", date, precision, en, ja, { ...(body === undefined ? {} : { body }), ...(distanceKm === undefined ? {} : { distanceKm }) });
16
+ /**
17
+ * The ten craft and their facts, keyed by id.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * import { SPACECRAFT } from "@johnmorrisdotca/wakusei-planets/spacecraft";
22
+ *
23
+ * console.log(SPACECRAFT.voyager1.name.ja, new Date(SPACECRAFT.voyager1.launch.date).toISOString());
24
+ * ```
25
+ */
26
+ export const SPACECRAFT = {
27
+ voyager1: {
28
+ id: "voyager1",
29
+ name: { en: "Voyager 1", ja: "ボイジャー1号" },
30
+ agency: "NASA",
31
+ launch: { date: T(1977, 8, 5, 12, 56, 1), precision: "minute", site: { en: "Cape Canaveral, Florida (Launch Complex 41)", ja: "ケープカナベラル 41番発射施設 (フロリダ州)" }, vehicle: "Titan IIIE-Centaur" },
32
+ end: undefined,
33
+ status: "active",
34
+ url: "https://science.nasa.gov/mission/voyager/voyager-1/",
35
+ horizons: "-31",
36
+ record: { start: 242_315_917_199, end: 4_102_444_730_199 },
37
+ joins: [{ date: 347_155_166_199, km: 65_200 }],
38
+ events: [
39
+ ev("launch", T(1977, 8, 5, 12, 56, 1), "minute", "Launch", "打ち上げ"),
40
+ flyby(T(1979, 2, 5, 12, 5), "minute", "Jupiter flyby", "木星フライバイ", "jupiter", 280_000),
41
+ flyby(T(1980, 10, 12, 23, 46), "minute", "Saturn flyby", "土星フライバイ", "saturn", 126_000),
42
+ ],
43
+ },
44
+ voyager2: {
45
+ id: "voyager2",
46
+ name: { en: "Voyager 2", ja: "ボイジャー2号" },
47
+ agency: "NASA",
48
+ launch: { date: T(1977, 7, 20, 14, 29, 44), precision: "minute", site: { en: "Cape Canaveral, Florida (Launch Complex 41)", ja: "ケープカナベラル 41番発射施設 (フロリダ州)" }, vehicle: "Titan IIIE-Centaur" },
49
+ end: undefined,
50
+ status: "active",
51
+ url: "https://science.nasa.gov/mission/voyager/voyager-2/",
52
+ horizons: "-32",
53
+ record: { start: 240_939_104_999, end: 4_102_444_729_999 },
54
+ joins: [{ date: 620_380_819_999, km: 13_700 }],
55
+ events: [
56
+ ev("launch", T(1977, 7, 20, 14, 29, 44), "minute", "Launch", "打ち上げ"),
57
+ flyby(T(1979, 6, 9, 22, 29), "minute", "Jupiter flyby", "木星フライバイ", "jupiter", 645_000),
58
+ flyby(noon(1981, 8, 26), "day", "Saturn flyby", "土星フライバイ", "saturn", 101_000),
59
+ flyby(T(1986, 0, 24, 17, 59), "minute", "Uranus flyby", "天王星フライバイ", "uranus", 81_500),
60
+ flyby(T(1989, 7, 25, 3, 56), "minute", "Neptune flyby", "海王星フライバイ", "neptune", 4_800),
61
+ ],
62
+ },
63
+ newhorizons: {
64
+ id: "newhorizons",
65
+ name: { en: "New Horizons", ja: "ニュー・ホライズンズ" },
66
+ agency: "NASA",
67
+ launch: { date: T(2006, 0, 19, 19, 0, 0), precision: "minute", site: { en: "Cape Canaveral, Florida (Launch Complex 41)", ja: "ケープカナベラル 41番発射施設 (フロリダ州)" }, vehicle: "Atlas V 551" },
68
+ end: undefined,
69
+ status: "active",
70
+ url: "https://science.nasa.gov/mission/new-horizons/",
71
+ horizons: "-98",
72
+ record: { start: 1_137_700_214_146, end: 2_524_607_930_146 },
73
+ joins: [],
74
+ events: [
75
+ ev("launch", T(2006, 0, 19, 19, 0, 0), "minute", "Launch", "打ち上げ"),
76
+ flyby(noon(2006, 6, 13), "day", "Flyby of asteroid 132524 APL", "小惑星 132524 APL フライバイ", undefined, 101_867),
77
+ flyby(T(2007, 1, 28, 5, 43, 40), "minute", "Jupiter flyby", "木星フライバイ", "jupiter"),
78
+ flyby(T(2015, 6, 14, 11, 49), "minute", "Pluto flyby", "冥王星フライバイ", "pluto"),
79
+ flyby(noon(2019, 1, 1), "day", "Flyby of Arrokoth", "アロコス フライバイ", undefined, 3_500),
80
+ ],
81
+ },
82
+ pioneer10: {
83
+ id: "pioneer10",
84
+ name: { en: "Pioneer 10", ja: "パイオニア10号" },
85
+ agency: "NASA",
86
+ launch: { date: T(1972, 2, 2, 1, 49, 4), precision: "minute", site: { en: "Cape Canaveral, Florida (Launch Complex 36A)", ja: "ケープカナベラル 36A発射施設 (フロリダ州)" }, vehicle: "Atlas-Centaur" },
87
+ end: T(2003, 0, 23, 12),
88
+ status: "ended",
89
+ url: "https://science.nasa.gov/mission/pioneer-10/",
90
+ horizons: "-23",
91
+ record: { start: 68_436_241_001, end: 2_524_607_931_001 },
92
+ joins: [{ date: 70_284_612_001, km: 6_500 }, { date: 125_539_174_001, km: 19_400 }, { date: 424_224_010_001, km: 126_400 }, { date: 631_238_409_001, km: 31_900 }],
93
+ events: [
94
+ ev("launch", T(1972, 2, 2, 1, 49, 4), "minute", "Launch", "打ち上げ"),
95
+ flyby(T(1973, 11, 4, 2, 26), "minute", "Jupiter flyby", "木星フライバイ", "jupiter", 130_354),
96
+ ev("end", T(2003, 0, 23, 12), "day", "Last signal received", "最後の電波を受信"),
97
+ ],
98
+ },
99
+ pioneer11: {
100
+ id: "pioneer11",
101
+ name: { en: "Pioneer 11", ja: "パイオニア11号" },
102
+ agency: "NASA",
103
+ launch: { date: T(1973, 3, 6, 2, 11), precision: "minute", site: { en: "Cape Canaveral, Florida (Launch Complex 36B)", ja: "ケープカナベラル 36B発射施設 (フロリダ州)" }, vehicle: "Atlas-Centaur" },
104
+ end: T(1995, 8, 30, 12),
105
+ status: "ended",
106
+ url: "https://science.nasa.gov/mission/pioneer-11/",
107
+ horizons: "-24",
108
+ record: { start: 102_911_101_002, end: 2_524_607_931_002 },
109
+ joins: [{ date: 135_622_819_002, km: 64_200 }, { date: 155_797_215_002, km: 3_300 }, { date: 201_943_154_002, km: 458_900 }, { date: 269_136_019_002, km: 12_100 }, { date: 310_262_422_002, km: 32_100 }, { date: 473_299_210_002, km: 376_100 }],
110
+ events: [
111
+ ev("launch", T(1973, 3, 6, 2, 11), "minute", "Launch", "打ち上げ"),
112
+ flyby(T(1974, 11, 3, 5, 22), "minute", "Jupiter flyby", "木星フライバイ", "jupiter", 42_500),
113
+ flyby(T(1979, 8, 1, 16, 31), "minute", "Saturn flyby", "土星フライバイ", "saturn", 20_900),
114
+ ev("end", T(1995, 8, 30, 12), "day", "Last contact", "最後の通信"),
115
+ ],
116
+ },
117
+ cassini: {
118
+ id: "cassini",
119
+ name: { en: "Cassini", ja: "カッシーニ" },
120
+ agency: "NASA, ESA, ASI",
121
+ launch: { date: noon(1997, 10, 15), precision: "day", site: { en: "Cape Canaveral, Florida", ja: "ケープカナベラル (フロリダ州)" }, vehicle: "Titan IVB/Centaur" },
122
+ end: noon(2017, 9, 15),
123
+ status: "ended",
124
+ url: "https://science.nasa.gov/mission/cassini/",
125
+ horizons: "-82",
126
+ record: { start: 876_907_569_388, end: 1_505_476_609_388 },
127
+ joins: [{ date: 1_018_483_137_388, km: 6_200 }],
128
+ events: [
129
+ ev("launch", noon(1997, 10, 15), "day", "Launch", "打ち上げ"),
130
+ flyby(noon(1998, 4, 26), "day", "Venus flyby", "金星フライバイ", "venus", 284),
131
+ flyby(noon(1999, 6, 24), "day", "Second Venus flyby", "2回目の金星フライバイ", "venus", 600),
132
+ flyby(noon(1999, 8, 18), "day", "Earth flyby", "地球フライバイ", "earth", 1_100),
133
+ flyby(noon(2000, 12, 30), "day", "Jupiter flyby", "木星フライバイ", "jupiter", 10_000_000),
134
+ ev("orbit-insertion", noon(2004, 7, 1), "day", "Saturn orbit insertion", "土星周回軌道に入る", { body: "saturn" }),
135
+ ev("end", noon(2017, 9, 15), "day", "Grand Finale: plunge into Saturn", "グランドフィナーレ: 土星に突入"),
136
+ ],
137
+ },
138
+ galileo: {
139
+ id: "galileo",
140
+ name: { en: "Galileo", ja: "ガリレオ" },
141
+ agency: "NASA",
142
+ launch: { date: T(1989, 9, 18, 23, 15), precision: "minute", site: { en: "Kennedy Space Center, Florida", ja: "ケネディ宇宙センター (フロリダ州)" }, vehicle: "Space Shuttle Atlantis (STS-34)" },
143
+ end: noon(2003, 9, 21),
144
+ status: "ended",
145
+ url: "https://science.nasa.gov/mission/galileo/",
146
+ horizons: "-77",
147
+ record: { start: 624_763_718_076, end: 1_064_923_135_076 },
148
+ joins: [],
149
+ events: [
150
+ ev("launch", T(1989, 9, 18, 23, 15), "minute", "Launch", "打ち上げ"),
151
+ flyby(noon(1990, 2, 10), "day", "Venus flyby", "金星フライバイ", "venus", 16_000),
152
+ flyby(noon(1990, 12, 8), "day", "Earth flyby", "地球フライバイ", "earth", 960),
153
+ flyby(noon(1991, 10, 29), "day", "Flyby of asteroid Gaspra", "小惑星ガスプラ フライバイ", undefined, 1_601),
154
+ flyby(noon(1992, 12, 8), "day", "Second Earth flyby", "2回目の地球フライバイ", "earth", 303),
155
+ flyby(noon(1993, 8, 28), "day", "Flyby of asteroid Ida", "小惑星イダ フライバイ", undefined, 2_400),
156
+ ev("orbit-insertion", noon(1995, 12, 7), "day", "Jupiter orbit insertion", "木星周回軌道に入る", { body: "jupiter" }),
157
+ ev("end", noon(2003, 9, 21), "day", "Plunge into Jupiter", "木星に突入"),
158
+ ],
159
+ },
160
+ juno: {
161
+ id: "juno",
162
+ name: { en: "Juno", ja: "ジュノー" },
163
+ agency: "NASA",
164
+ launch: { date: T(2011, 7, 5, 16, 25), precision: "minute", site: { en: "Cape Canaveral, Florida (Launch Complex 41)", ja: "ケープカナベラル 41番発射施設 (フロリダ州)" }, vehicle: "Atlas V 551" },
165
+ end: undefined,
166
+ status: "active",
167
+ url: "https://science.nasa.gov/mission/juno/",
168
+ horizons: "-61",
169
+ record: { start: 1_312_564_686_999, end: 1_851_471_472_999 },
170
+ joins: [],
171
+ events: [
172
+ ev("launch", T(2011, 7, 5, 16, 25), "minute", "Launch", "打ち上げ"),
173
+ flyby(T(2013, 9, 9, 19, 21), "minute", "Earth flyby", "地球フライバイ", "earth", 559),
174
+ ev("orbit-insertion", noon(2016, 7, 5), "day", "Jupiter orbit insertion", "木星周回軌道に入る", { body: "jupiter", distanceKm: 4_200 }),
175
+ ],
176
+ },
177
+ parker: {
178
+ id: "parker",
179
+ name: { en: "Parker Solar Probe", ja: "パーカー・ソーラー・プローブ" },
180
+ agency: "NASA",
181
+ launch: { date: T(2018, 7, 12, 7, 31), precision: "minute", site: { en: "Cape Canaveral, Florida", ja: "ケープカナベラル (フロリダ州)" }, vehicle: "Delta IV Heavy" },
182
+ end: undefined,
183
+ status: "active",
184
+ url: "https://science.nasa.gov/mission/parker-solar-probe/",
185
+ horizons: "-96",
186
+ record: { start: 1_534_061_715_159, end: 1_893_455_931_159 },
187
+ joins: [{ date: 1_750_831_215_159, km: 79_800 }, { date: 1_802_822_412_159, km: 7_600 }],
188
+ events: [
189
+ ev("launch", T(2018, 7, 12, 7, 31), "minute", "Launch", "打ち上げ"),
190
+ flyby(noon(2018, 10, 3), "day", "Venus flyby", "金星フライバイ", "venus", 2_500),
191
+ flyby(noon(2019, 12, 26), "day", "Second Venus flyby", "2回目の金星フライバイ", "venus", 3_000),
192
+ flyby(noon(2020, 7, 11), "day", "Third Venus flyby", "3回目の金星フライバイ", "venus", 800),
193
+ flyby(noon(2021, 2, 20), "day", "Fourth Venus flyby", "4回目の金星フライバイ", "venus", 2_400),
194
+ flyby(noon(2021, 10, 16), "day", "Fifth Venus flyby", "5回目の金星フライバイ", "venus", 3_800),
195
+ flyby(noon(2023, 8, 21), "day", "Sixth Venus flyby", "6回目の金星フライバイ", "venus", 3_900),
196
+ flyby(noon(2024, 11, 6), "day", "Seventh Venus flyby", "7回目の金星フライバイ", "venus", 300),
197
+ ],
198
+ },
199
+ webb: {
200
+ id: "webb",
201
+ name: { en: "James Webb Space Telescope", ja: "ジェイムズ・ウェッブ宇宙望遠鏡" },
202
+ agency: "NASA, ESA, CSA",
203
+ launch: { date: T(2021, 11, 25, 12, 20), precision: "minute", site: { en: "Kourou, French Guiana (ELA-3)", ja: "クールー (フランス領ギアナ) ELA-3" }, vehicle: "Ariane 5" },
204
+ end: undefined,
205
+ status: "active",
206
+ url: "https://science.nasa.gov/mission/webb/",
207
+ horizons: "-170",
208
+ record: { start: 1_640_437_201_000, end: 1_951_343_999_000 },
209
+ joins: [],
210
+ events: [
211
+ ev("launch", T(2021, 11, 25, 12, 20), "minute", "Launch", "打ち上げ"),
212
+ ev("arrival", noon(2022, 1, 24), "day", "Arrival at the Sun–Earth second Lagrange point (L2)", "太陽・地球系の第2ラグランジュ点 (L2) に到着"),
213
+ ],
214
+ },
215
+ };
@@ -0,0 +1,134 @@
1
+ import { type SpacecraftId } from "./spacecraft-facts.ts";
2
+ import { type Vec3 } from "./vec.ts";
3
+ import { type When } from "./when.ts";
4
+ export { SPACECRAFT, SPACECRAFT_IDS, type SpacecraftEvent, type SpacecraftFacts, type SpacecraftId } from "./spacecraft-facts.ts";
5
+ export type { When } from "./when.ts";
6
+ /**
7
+ * Load the fitted paths of some spacecraft (or all of them), each a table of its own that nothing else imports: about 6 kB gzipped for the Voyagers, the Pioneers, New Horizons and JWST, and more for the craft that orbited a planet.
8
+ * Call it once before the other functions; it is safe to call again.
9
+ *
10
+ * @param ids - The craft to load; none means all ten.
11
+ * @returns A promise that settles when every table is registered.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * import { loadSpacecraft, spacecraftPosition } from "@johnmorrisdotca/wakusei-planets/spacecraft";
16
+ *
17
+ * await loadSpacecraft("voyager1");
18
+ * const [x, y, z] = spacecraftPosition("voyager1", Date.UTC(2026, 10, 8));
19
+ * console.log((Math.hypot(x, y, z) / 149597870.7).toFixed(0), "au from the Sun");
20
+ * ```
21
+ */
22
+ export declare function loadSpacecraft(...ids: readonly SpacecraftId[]): Promise<void>;
23
+ /**
24
+ * Where a craft is at a moment: x, y, z in kilometres from the Sun, in the J2000 ecliptic frame (the same axes as `heliocentric`, which is in astronomical units).
25
+ * The path comes from Horizons, which is the craft's tracked path to now and its planned path after, so a moment in the future is a prediction. A moment outside the record (before about an hour after launch, or past its end) throws a RangeError.
26
+ *
27
+ * @param id - The craft.
28
+ * @param when - A `Date` or milliseconds since 1970 (UTC).
29
+ * @returns The position in kilometres.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * import { loadSpacecraft, spacecraftPosition } from "@johnmorrisdotca/wakusei-planets/spacecraft";
34
+ *
35
+ * await loadSpacecraft("newhorizons");
36
+ * console.log(spacecraftPosition("newhorizons", new Date("2015-07-14T11:49:00Z")).map((n) => Math.round(n / 1e6)));
37
+ * ```
38
+ */
39
+ export declare function spacecraftPosition(id: SpacecraftId, when: When): Vec3;
40
+ /**
41
+ * A craft's velocity relative to the Sun at a moment, in kilometres a second, in the same frame as `spacecraftPosition`.
42
+ *
43
+ * @param id - The craft.
44
+ * @param when - A `Date` or milliseconds since 1970 (UTC).
45
+ * @returns The velocity.
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * import { loadSpacecraft, spacecraftVelocity } from "@johnmorrisdotca/wakusei-planets/spacecraft";
50
+ *
51
+ * await loadSpacecraft("voyager2");
52
+ * console.log(spacecraftVelocity("voyager2", Date.UTC(2026, 0, 1)).map((n) => n.toFixed(1)));
53
+ * ```
54
+ */
55
+ export declare function spacecraftVelocity(id: SpacecraftId, when: When): Vec3;
56
+ /**
57
+ * A craft's speed relative to the Sun at a moment, in kilometres a second. Within about 3 per cent of Horizons' own figure at worst, and usually far closer.
58
+ *
59
+ * @param id - The craft.
60
+ * @param when - A `Date` or milliseconds since 1970 (UTC).
61
+ * @returns The speed.
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * import { loadSpacecraft, spacecraftSpeed } from "@johnmorrisdotca/wakusei-planets/spacecraft";
66
+ *
67
+ * await loadSpacecraft("voyager1");
68
+ * console.log(spacecraftSpeed("voyager1", Date.UTC(2026, 10, 8)).toFixed(1), "km/s");
69
+ * ```
70
+ */
71
+ export declare function spacecraftSpeed(id: SpacecraftId, when: When): number;
72
+ /**
73
+ * A craft's distance from the Sun at a moment, in kilometres.
74
+ *
75
+ * @param id - The craft.
76
+ * @param when - A `Date` or milliseconds since 1970 (UTC).
77
+ * @returns The distance.
78
+ *
79
+ * @example
80
+ * ```ts
81
+ * import { loadSpacecraft, spacecraftSunDistance } from "@johnmorrisdotca/wakusei-planets/spacecraft";
82
+ *
83
+ * await loadSpacecraft("parker");
84
+ * console.log((spacecraftSunDistance("parker", Date.UTC(2024, 11, 24, 11, 53)) / 1e6).toFixed(1), "million km");
85
+ * ```
86
+ */
87
+ export declare function spacecraftSunDistance(id: SpacecraftId, when: When): number;
88
+ /**
89
+ * A craft's distance from the Earth's centre at a moment, in kilometres: the craft's path from Horizons and the Earth from VSOP87B (a few thousand kilometres at most), both for the same instant, with no allowance for the light's travel.
90
+ *
91
+ * @param id - The craft.
92
+ * @param when - A `Date` or milliseconds since 1970 (UTC).
93
+ * @returns The distance.
94
+ *
95
+ * @example
96
+ * ```ts
97
+ * import { loadSpacecraft, spacecraftEarthDistance } from "@johnmorrisdotca/wakusei-planets/spacecraft";
98
+ *
99
+ * await loadSpacecraft("webb");
100
+ * console.log((spacecraftEarthDistance("webb", Date.UTC(2026, 10, 8)) / 1e6).toFixed(2), "million km");
101
+ * ```
102
+ */
103
+ export declare function spacecraftEarthDistance(id: SpacecraftId, when: When): number;
104
+ /**
105
+ * How long a radio signal takes from the Earth to a craft (or back), at a moment, in seconds: the distance from the Earth over the speed of light.
106
+ *
107
+ * @param id - The craft.
108
+ * @param when - A `Date` or milliseconds since 1970 (UTC).
109
+ * @returns One-way light time in seconds.
110
+ *
111
+ * @example
112
+ * ```ts
113
+ * import { loadSpacecraft, spacecraftLightTime } from "@johnmorrisdotca/wakusei-planets/spacecraft";
114
+ *
115
+ * await loadSpacecraft("voyager1");
116
+ * console.log((spacecraftLightTime("voyager1", Date.UTC(2026, 10, 8)) / 3600).toFixed(1), "hours");
117
+ * ```
118
+ */
119
+ export declare function spacecraftLightTime(id: SpacecraftId, when: When): number;
120
+ /**
121
+ * The worst error of a craft's loaded path against Horizons, in kilometres, as measured when it was made: on samples held back from the fit and on fresh samples at random times. It grows with the craft's distance from the Sun (a millionth of it in cruise), and is 1,000 km or better near a planet.
122
+ *
123
+ * @param id - The craft.
124
+ * @returns The error in kilometres.
125
+ *
126
+ * @example
127
+ * ```ts
128
+ * import { loadSpacecraft, spacecraftErrorKm } from "@johnmorrisdotca/wakusei-planets/spacecraft";
129
+ *
130
+ * await loadSpacecraft("juno");
131
+ * console.log(spacecraftErrorKm("juno") < 1000);
132
+ * ```
133
+ */
134
+ export declare function spacecraftErrorKm(id: SpacecraftId): number;
@@ -0,0 +1,198 @@
1
+ // Famous spacecraft: where they are at a date and their whole voyage. Each craft's path is a Chebyshev table fitted to JPL Horizons (scripts/make-spacecraft-data.py, src/craft/<craft>.ts) over the whole of Horizons' own record
2
+ // of it, loaded when asked for (`loadSpacecraft`) so a page pays only for the craft it draws. Positions are heliocentric, in kilometres, in the J2000 ecliptic frame like `heliocentric`. Pure: no DOM, no three.js.
3
+ import { craftSpan, craftState, craftTable } from "./data/craft.js";
4
+ import { toTerrestrialTime } from "./clock.js";
5
+ import { heliocentric } from "./ephemeris.js";
6
+ import { SPACECRAFT, SPACECRAFT_IDS } from "./spacecraft-facts.js";
7
+ import { length, scale, sub } from "./vec.js";
8
+ import { moment } from "./when.js";
9
+ export { SPACECRAFT, SPACECRAFT_IDS } from "./spacecraft-facts.js";
10
+ const AU_KM = 149_597_870.7;
11
+ /** The speed of light in kilometres a second. */
12
+ const LIGHT_KM_PER_SECOND = 299_792.458;
13
+ const LOADERS = {
14
+ voyager1: () => import("./craft/voyager1.js"),
15
+ voyager2: () => import("./craft/voyager2.js"),
16
+ newhorizons: () => import("./craft/newhorizons.js"),
17
+ pioneer10: () => import("./craft/pioneer10.js"),
18
+ pioneer11: () => import("./craft/pioneer11.js"),
19
+ cassini: () => import("./craft/cassini.js"),
20
+ galileo: () => import("./craft/galileo.js"),
21
+ juno: () => import("./craft/juno.js"),
22
+ parker: () => import("./craft/parker.js"),
23
+ webb: () => import("./craft/webb.js"),
24
+ };
25
+ function facts(id) {
26
+ const found = SPACECRAFT[id];
27
+ if (found === undefined || !Object.hasOwn(SPACECRAFT, id))
28
+ throw new RangeError(`unknown spacecraft ${JSON.stringify(id)}; expected one of ${SPACECRAFT_IDS.join(", ")}`);
29
+ return found;
30
+ }
31
+ /**
32
+ * Load the fitted paths of some spacecraft (or all of them), each a table of its own that nothing else imports: about 6 kB gzipped for the Voyagers, the Pioneers, New Horizons and JWST, and more for the craft that orbited a planet.
33
+ * Call it once before the other functions; it is safe to call again.
34
+ *
35
+ * @param ids - The craft to load; none means all ten.
36
+ * @returns A promise that settles when every table is registered.
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * import { loadSpacecraft, spacecraftPosition } from "@johnmorrisdotca/wakusei-planets/spacecraft";
41
+ *
42
+ * await loadSpacecraft("voyager1");
43
+ * const [x, y, z] = spacecraftPosition("voyager1", Date.UTC(2026, 10, 8));
44
+ * console.log((Math.hypot(x, y, z) / 149597870.7).toFixed(0), "au from the Sun");
45
+ * ```
46
+ */
47
+ export async function loadSpacecraft(...ids) {
48
+ const wanted = ids.length === 0 ? SPACECRAFT_IDS : ids;
49
+ for (const id of wanted)
50
+ facts(id);
51
+ await Promise.all(wanted.map((id) => LOADERS[id]()));
52
+ }
53
+ /** The terrestrial time of a moment on a craft's path, or a RangeError that names the moment and the record. */
54
+ function onPath(id, when) {
55
+ const craft = facts(id);
56
+ const ms = moment(when);
57
+ const table = craftTable(id);
58
+ if (table === undefined)
59
+ throw new Error(`the path of ${craft.name.en} is not loaded: await loadSpacecraft(${JSON.stringify(id)}) first`);
60
+ const tt = toTerrestrialTime(ms);
61
+ const [first, last] = craftSpan(table);
62
+ if (tt < first || tt > last) {
63
+ throw new RangeError(`when ${new Date(ms).toISOString()} is outside the record of ${craft.name.en}, which runs from ${new Date(craft.record.start).toISOString()} to ${new Date(craft.record.end).toISOString()}`);
64
+ }
65
+ return { tt, table };
66
+ }
67
+ /**
68
+ * Where a craft is at a moment: x, y, z in kilometres from the Sun, in the J2000 ecliptic frame (the same axes as `heliocentric`, which is in astronomical units).
69
+ * The path comes from Horizons, which is the craft's tracked path to now and its planned path after, so a moment in the future is a prediction. A moment outside the record (before about an hour after launch, or past its end) throws a RangeError.
70
+ *
71
+ * @param id - The craft.
72
+ * @param when - A `Date` or milliseconds since 1970 (UTC).
73
+ * @returns The position in kilometres.
74
+ *
75
+ * @example
76
+ * ```ts
77
+ * import { loadSpacecraft, spacecraftPosition } from "@johnmorrisdotca/wakusei-planets/spacecraft";
78
+ *
79
+ * await loadSpacecraft("newhorizons");
80
+ * console.log(spacecraftPosition("newhorizons", new Date("2015-07-14T11:49:00Z")).map((n) => Math.round(n / 1e6)));
81
+ * ```
82
+ */
83
+ export function spacecraftPosition(id, when) {
84
+ const { tt, table } = onPath(id, when);
85
+ return craftState(table, tt).position;
86
+ }
87
+ /**
88
+ * A craft's velocity relative to the Sun at a moment, in kilometres a second, in the same frame as `spacecraftPosition`.
89
+ *
90
+ * @param id - The craft.
91
+ * @param when - A `Date` or milliseconds since 1970 (UTC).
92
+ * @returns The velocity.
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * import { loadSpacecraft, spacecraftVelocity } from "@johnmorrisdotca/wakusei-planets/spacecraft";
97
+ *
98
+ * await loadSpacecraft("voyager2");
99
+ * console.log(spacecraftVelocity("voyager2", Date.UTC(2026, 0, 1)).map((n) => n.toFixed(1)));
100
+ * ```
101
+ */
102
+ export function spacecraftVelocity(id, when) {
103
+ const { tt, table } = onPath(id, when);
104
+ return craftState(table, tt).velocity;
105
+ }
106
+ /**
107
+ * A craft's speed relative to the Sun at a moment, in kilometres a second. Within about 3 per cent of Horizons' own figure at worst, and usually far closer.
108
+ *
109
+ * @param id - The craft.
110
+ * @param when - A `Date` or milliseconds since 1970 (UTC).
111
+ * @returns The speed.
112
+ *
113
+ * @example
114
+ * ```ts
115
+ * import { loadSpacecraft, spacecraftSpeed } from "@johnmorrisdotca/wakusei-planets/spacecraft";
116
+ *
117
+ * await loadSpacecraft("voyager1");
118
+ * console.log(spacecraftSpeed("voyager1", Date.UTC(2026, 10, 8)).toFixed(1), "km/s");
119
+ * ```
120
+ */
121
+ export function spacecraftSpeed(id, when) {
122
+ return length(spacecraftVelocity(id, when));
123
+ }
124
+ /**
125
+ * A craft's distance from the Sun at a moment, in kilometres.
126
+ *
127
+ * @param id - The craft.
128
+ * @param when - A `Date` or milliseconds since 1970 (UTC).
129
+ * @returns The distance.
130
+ *
131
+ * @example
132
+ * ```ts
133
+ * import { loadSpacecraft, spacecraftSunDistance } from "@johnmorrisdotca/wakusei-planets/spacecraft";
134
+ *
135
+ * await loadSpacecraft("parker");
136
+ * console.log((spacecraftSunDistance("parker", Date.UTC(2024, 11, 24, 11, 53)) / 1e6).toFixed(1), "million km");
137
+ * ```
138
+ */
139
+ export function spacecraftSunDistance(id, when) {
140
+ return length(spacecraftPosition(id, when));
141
+ }
142
+ /**
143
+ * A craft's distance from the Earth's centre at a moment, in kilometres: the craft's path from Horizons and the Earth from VSOP87B (a few thousand kilometres at most), both for the same instant, with no allowance for the light's travel.
144
+ *
145
+ * @param id - The craft.
146
+ * @param when - A `Date` or milliseconds since 1970 (UTC).
147
+ * @returns The distance.
148
+ *
149
+ * @example
150
+ * ```ts
151
+ * import { loadSpacecraft, spacecraftEarthDistance } from "@johnmorrisdotca/wakusei-planets/spacecraft";
152
+ *
153
+ * await loadSpacecraft("webb");
154
+ * console.log((spacecraftEarthDistance("webb", Date.UTC(2026, 10, 8)) / 1e6).toFixed(2), "million km");
155
+ * ```
156
+ */
157
+ export function spacecraftEarthDistance(id, when) {
158
+ const ms = moment(when);
159
+ return length(sub(spacecraftPosition(id, ms), scale(heliocentric("earth", ms), AU_KM)));
160
+ }
161
+ /**
162
+ * How long a radio signal takes from the Earth to a craft (or back), at a moment, in seconds: the distance from the Earth over the speed of light.
163
+ *
164
+ * @param id - The craft.
165
+ * @param when - A `Date` or milliseconds since 1970 (UTC).
166
+ * @returns One-way light time in seconds.
167
+ *
168
+ * @example
169
+ * ```ts
170
+ * import { loadSpacecraft, spacecraftLightTime } from "@johnmorrisdotca/wakusei-planets/spacecraft";
171
+ *
172
+ * await loadSpacecraft("voyager1");
173
+ * console.log((spacecraftLightTime("voyager1", Date.UTC(2026, 10, 8)) / 3600).toFixed(1), "hours");
174
+ * ```
175
+ */
176
+ export function spacecraftLightTime(id, when) {
177
+ return spacecraftEarthDistance(id, when) / LIGHT_KM_PER_SECOND;
178
+ }
179
+ /**
180
+ * The worst error of a craft's loaded path against Horizons, in kilometres, as measured when it was made: on samples held back from the fit and on fresh samples at random times. It grows with the craft's distance from the Sun (a millionth of it in cruise), and is 1,000 km or better near a planet.
181
+ *
182
+ * @param id - The craft.
183
+ * @returns The error in kilometres.
184
+ *
185
+ * @example
186
+ * ```ts
187
+ * import { loadSpacecraft, spacecraftErrorKm } from "@johnmorrisdotca/wakusei-planets/spacecraft";
188
+ *
189
+ * await loadSpacecraft("juno");
190
+ * console.log(spacecraftErrorKm("juno") < 1000);
191
+ * ```
192
+ */
193
+ export function spacecraftErrorKm(id) {
194
+ const table = craftTable(id);
195
+ if (table === undefined)
196
+ throw new Error(`the path of ${facts(id).name.en} is not loaded: await loadSpacecraft(${JSON.stringify(id)}) first`);
197
+ return table.worst;
198
+ }