@johnmorrisdotca/wakusei-planets 0.37.2 → 0.39.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.
- package/CHANGELOG.md +20 -0
- package/NOTICE.md +14 -3
- package/README.md +6 -4
- package/dist/belts/data.d.ts +2 -0
- package/dist/belts/data.js +12 -0
- package/dist/belts/index.d.ts +270 -0
- package/dist/belts/index.js +308 -0
- package/dist/belts/totals.d.ts +43 -0
- package/dist/belts/totals.js +25 -0
- package/dist/data/orbiters.d.ts +221 -199
- package/dist/data/orbiters.js +288 -200
- package/dist/data-door.d.ts +2 -0
- package/dist/data-door.js +4 -2
- package/dist/door/own.js +4 -2
- package/dist/door/points.d.ts +14 -5
- package/dist/door/points.js +78 -27
- package/dist/earth-places.d.ts +40 -0
- package/dist/earth-places.js +47 -0
- package/dist/embed.d.ts +4 -1
- package/dist/embed.js +21 -10
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/orbiter-facts.d.ts +61 -4
- package/dist/orbiter-facts.js +17 -3
- package/dist/orbiters.d.ts +122 -2
- package/dist/orbiters.js +205 -3
- package/dist/picture-credits.d.ts +78 -0
- package/dist/picture-credits.js +120 -0
- package/dist/place-marks.d.ts +76 -0
- package/dist/place-marks.js +66 -0
- package/dist/places.d.ts +1 -1
- package/dist/places.js +1 -1
- package/dist/scene/earth-places.d.ts +190 -0
- package/dist/scene/earth-places.js +190 -0
- package/dist/scene/painter.d.ts +11 -0
- package/dist/scene/painter.js +30 -2
- package/dist/scene/textures.d.ts +2 -2
- package/dist/space/element.d.ts +74 -3
- package/dist/space/element.js +293 -8
- package/dist/space/ride.d.ts +4 -4
- package/dist/space/ride.js +10 -3
- package/dist/space/scene.d.ts +44 -2
- package/dist/space/scene.js +139 -11
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +15 -2
package/dist/orbiter-facts.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// What is known about each orbiter: names, operator, launch, instruments, a line about it in our own words, and the state of its mission. Every fact is typed from the craft's own
|
|
2
|
-
// JPL Horizons object page as a plain fact, in our own words, read 2026-11-11 by scripts/make-orbiter-data.py
|
|
2
|
+
// JPL Horizons object page as a plain fact, in our own words, read 2026-11-11 by scripts/make-orbiter-data.py, and MAVEN's end from NASA's news release of 2026-06-03 (NOTICE.md names the pages
|
|
3
|
+
// and the agency that supplies each trajectory); a fact the page does not give is left out, never guessed.
|
|
3
4
|
// The Japanese names and lines are ours.
|
|
4
5
|
/**
|
|
5
6
|
* The orbiters' facts by id.
|
|
@@ -14,6 +15,7 @@
|
|
|
14
15
|
export const ORBITER_FACTS = {
|
|
15
16
|
lro: {
|
|
16
17
|
name: { en: "Lunar Reconnaissance Orbiter", ja: "ルナー・リコネサンス・オービター" },
|
|
18
|
+
short: { en: "LRO", ja: "LRO" },
|
|
17
19
|
centre: "moon",
|
|
18
20
|
operator: "NASA (Goddard Space Flight Center)",
|
|
19
21
|
launch: { date: "2009-06-18T09:32Z", vehicle: "Atlas V", site: "Cape Canaveral, launch complex 41" },
|
|
@@ -32,6 +34,7 @@ export const ORBITER_FACTS = {
|
|
|
32
34
|
},
|
|
33
35
|
"chandrayaan-2": {
|
|
34
36
|
name: { en: "Chandrayaan-2 orbiter", ja: "チャンドラヤーン2号 オービター" },
|
|
37
|
+
short: { en: "Chandrayaan-2", ja: "チャンドラヤーン2号" },
|
|
35
38
|
centre: "moon",
|
|
36
39
|
operator: "ISRO",
|
|
37
40
|
launch: { date: "2019-07-22T09:13Z", vehicle: "GSLV Mk III", site: "Satish Dhawan Space Centre, Sriharikota" },
|
|
@@ -42,6 +45,7 @@ export const ORBITER_FACTS = {
|
|
|
42
45
|
},
|
|
43
46
|
danuri: {
|
|
44
47
|
name: { en: "Danuri (KPLO)", ja: "ダヌリ (KPLO)" },
|
|
48
|
+
short: { en: "Danuri", ja: "ダヌリ" },
|
|
45
49
|
centre: "moon",
|
|
46
50
|
operator: "KARI (Korea Aerospace Research Institute)",
|
|
47
51
|
launch: { date: "2022-08-04T23:08Z", vehicle: "Falcon 9 Block 5", site: "Cape Canaveral, SLC-40" },
|
|
@@ -59,6 +63,7 @@ export const ORBITER_FACTS = {
|
|
|
59
63
|
},
|
|
60
64
|
"artemis-p1": {
|
|
61
65
|
name: { en: "ARTEMIS P1", ja: "ARTEMIS P1" },
|
|
66
|
+
short: { en: "ARTEMIS P1", ja: "ARTEMIS P1" },
|
|
62
67
|
centre: "moon",
|
|
63
68
|
operator: "NASA (University of California, Berkeley)",
|
|
64
69
|
launch: { date: "2007-02-17T23:01Z", vehicle: "Delta II 7925-10C", site: "Cape Canaveral" },
|
|
@@ -75,6 +80,7 @@ export const ORBITER_FACTS = {
|
|
|
75
80
|
},
|
|
76
81
|
"artemis-p2": {
|
|
77
82
|
name: { en: "ARTEMIS P2", ja: "ARTEMIS P2" },
|
|
83
|
+
short: { en: "ARTEMIS P2", ja: "ARTEMIS P2" },
|
|
78
84
|
centre: "moon",
|
|
79
85
|
operator: "NASA (University of California, Berkeley)",
|
|
80
86
|
launch: { date: "2007-02-17T23:01Z", vehicle: "Delta II 7925-10C", site: "Cape Canaveral" },
|
|
@@ -91,6 +97,7 @@ export const ORBITER_FACTS = {
|
|
|
91
97
|
},
|
|
92
98
|
capstone: {
|
|
93
99
|
name: { en: "CAPSTONE", ja: "キャップストーン" },
|
|
100
|
+
short: { en: "CAPSTONE", ja: "CAPSTONE" },
|
|
94
101
|
centre: "moon",
|
|
95
102
|
operator: "NASA (Advanced Space)",
|
|
96
103
|
launch: { date: "2022-06-28T09:55:52Z", vehicle: "Electron (Rocket Lab)", site: "Mahia Peninsula, New Zealand" },
|
|
@@ -101,6 +108,7 @@ export const ORBITER_FACTS = {
|
|
|
101
108
|
},
|
|
102
109
|
mro: {
|
|
103
110
|
name: { en: "Mars Reconnaissance Orbiter", ja: "マーズ・リコネサンス・オービター" },
|
|
111
|
+
short: { en: "MRO", ja: "MRO" },
|
|
104
112
|
centre: "mars",
|
|
105
113
|
operator: "NASA (JPL)",
|
|
106
114
|
launch: { date: "2005-08-12T11:43Z", vehicle: "Atlas V", site: "Cape Canaveral" },
|
|
@@ -111,6 +119,7 @@ export const ORBITER_FACTS = {
|
|
|
111
119
|
},
|
|
112
120
|
odyssey: {
|
|
113
121
|
name: { en: "2001 Mars Odyssey", ja: "2001マーズ・オデッセイ" },
|
|
122
|
+
short: { en: "Odyssey", ja: "オデッセイ" },
|
|
114
123
|
centre: "mars",
|
|
115
124
|
operator: "NASA (JPL)",
|
|
116
125
|
launch: { date: "2001-04-07T15:02Z", vehicle: "Delta II 7925" },
|
|
@@ -125,6 +134,7 @@ export const ORBITER_FACTS = {
|
|
|
125
134
|
},
|
|
126
135
|
maven: {
|
|
127
136
|
name: { en: "MAVEN", ja: "メイブン" },
|
|
137
|
+
short: { en: "MAVEN", ja: "MAVEN" },
|
|
128
138
|
centre: "mars",
|
|
129
139
|
operator: "NASA (Goddard Space Flight Center)",
|
|
130
140
|
launch: { date: "2013-11-18T18:28Z", vehicle: "Atlas V 401", site: "Cape Canaveral, SLC-41" },
|
|
@@ -133,12 +143,13 @@ export const ORBITER_FACTS = {
|
|
|
133
143
|
{ name: "Imaging Ultraviolet Spectrometer", short: "IUVS" },
|
|
134
144
|
{ name: "Neutral Gas and Ion Mass Spectrometer", short: "NGIMS" },
|
|
135
145
|
],
|
|
136
|
-
about: { en: "The Mars Atmosphere and Volatile Evolution orbiter studied how the upper atmosphere is lost to space from a 150 by 6,200 km orbit; contact was lost in December 2025 and NASA
|
|
137
|
-
status: { state: "ended", since: "2025-12-06", note: { en: "Horizons' page: no contact since 2025-12-06, with evidence of an unplanned change of velocity on 2025-12-04; its fit reaches 2025-12-04 and its track ends 2026-03-01.", ja: "Horizonsのページ: 2025-12-06から交信がなく、2025-12-04に予定外の速度変化があった形跡があります。合わせた期間は2025-12-04まで、経路データは2026-03-01で終わります。" } },
|
|
146
|
+
about: { en: "The Mars Atmosphere and Volatile Evolution orbiter studied how the upper atmosphere is lost to space from a 150 by 6,200 km orbit; contact was lost in December 2025 and NASA said on 2026-06-03 that the mission had ended, so its last known orbit is shown as modelled.", ja: "火星の上層大気がどう宇宙へ失われるかを、150 × 6,200 kmの軌道から調べた探査機。2025年12月に交信が途絶え、2026-06-03にNASAがミッションが終わったと発表したので、最後に分かっている軌道をモデルの軌道として示します。" },
|
|
147
|
+
status: { state: "ended", since: "2025-12-06", note: { en: "Horizons' page: no contact since 2025-12-06, with evidence of an unplanned change of velocity on 2025-12-04; its fit reaches 2025-12-04 and its track ends 2026-03-01. NASA's news release of 2026-06-03, \"NASA Says Farewell to MAVEN Mars Mission\", says the mission has ended.", ja: "Horizonsのページ: 2025-12-06から交信がなく、2025-12-04に予定外の速度変化があった形跡があります。合わせた期間は2025-12-04まで、経路データは2026-03-01で終わります。NASAは2026-06-03の発表「NASA Says Farewell to MAVEN Mars Mission」で、ミッションが終わったと伝えました。" } },
|
|
138
148
|
horizonsId: -202,
|
|
139
149
|
},
|
|
140
150
|
"mars-express": {
|
|
141
151
|
name: { en: "Mars Express", ja: "マーズ・エクスプレス" },
|
|
152
|
+
short: { en: "Mars Express", ja: "マーズ・エクスプレス" },
|
|
142
153
|
centre: "mars",
|
|
143
154
|
operator: "ESA",
|
|
144
155
|
launch: { date: "2003-06-02", vehicle: "Soyuz-Fregat", site: "Baikonur" },
|
|
@@ -149,6 +160,7 @@ export const ORBITER_FACTS = {
|
|
|
149
160
|
},
|
|
150
161
|
tgo: {
|
|
151
162
|
name: { en: "ExoMars Trace Gas Orbiter", ja: "エクソマーズ・トレース・ガス・オービター" },
|
|
163
|
+
short: { en: "TGO", ja: "TGO" },
|
|
152
164
|
centre: "mars",
|
|
153
165
|
operator: "ESA (with Roscosmos)",
|
|
154
166
|
launch: { date: "2016-03-14T09:31Z", vehicle: "Proton", site: "Baikonur" },
|
|
@@ -164,6 +176,7 @@ export const ORBITER_FACTS = {
|
|
|
164
176
|
},
|
|
165
177
|
hope: {
|
|
166
178
|
name: { en: "Hope (Emirates Mars Mission)", ja: "ホープ (エミレーツ・マーズ・ミッション)" },
|
|
179
|
+
short: { en: "Hope", ja: "ホープ" },
|
|
167
180
|
centre: "mars",
|
|
168
181
|
operator: "Mohammed Bin Rashid Space Centre (United Arab Emirates)",
|
|
169
182
|
launch: { date: "2020-07-19T21:58:14Z", vehicle: "H-IIA 202", site: "Tanegashima, Japan" },
|
|
@@ -178,6 +191,7 @@ export const ORBITER_FACTS = {
|
|
|
178
191
|
},
|
|
179
192
|
"tianwen-1": {
|
|
180
193
|
name: { en: "Tianwen-1 orbiter", ja: "天問1号 オービター" },
|
|
194
|
+
short: { en: "Tianwen-1", ja: "天問1号" },
|
|
181
195
|
centre: "mars",
|
|
182
196
|
operator: "CNSA",
|
|
183
197
|
launch: { date: "2020-07-23T04:41Z", vehicle: "Long March 5", site: "Wenchang, Hainan" },
|
package/dist/orbiters.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ORBITER_FITS } from "./data/orbiters.ts";
|
|
2
2
|
import { type OrbiterFacts } from "./orbiter-facts.ts";
|
|
3
3
|
import type { When } from "./when.ts";
|
|
4
|
-
import type
|
|
4
|
+
import { type Vec3 } from "./vec.ts";
|
|
5
5
|
export { ORBITER_FACTS, type OrbiterFacts, type OrbiterInstrument } from "./orbiter-facts.ts";
|
|
6
6
|
export type { When } from "./when.ts";
|
|
7
7
|
/**
|
|
@@ -66,7 +66,7 @@ export interface OrbiterElements {
|
|
|
66
66
|
/** The semi-major axis in kilometres from the body's centre. */
|
|
67
67
|
a: number;
|
|
68
68
|
e: number;
|
|
69
|
-
/** Inclination, node, argument of periapsis and mean anomaly at the epoch, in degrees
|
|
69
|
+
/** Inclination to the body's equator, node (from the ascending node of the body's equator on the Earth's J2000 equator), argument of periapsis and mean anomaly at the epoch, in degrees. */
|
|
70
70
|
i: number;
|
|
71
71
|
raan: number;
|
|
72
72
|
argp: number;
|
|
@@ -202,6 +202,36 @@ export declare function orbiterNumbers(id: OrbiterId, when: When): {
|
|
|
202
202
|
status: OrbiterStatus;
|
|
203
203
|
errorKm: number | null;
|
|
204
204
|
} | undefined;
|
|
205
|
+
/**
|
|
206
|
+
* How far a predicted path may miss Horizons, as a share of its body's mean radius, and still be drawn as a tracked one is: 2 per cent, about 35 km at the Moon and 68 km at Mars, a hair's breadth
|
|
207
|
+
* on a picture of the body.
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* ```ts
|
|
211
|
+
* import { ORBITER_DIM_SHARE } from "@johnmorrisdotca/wakusei-planets/orbiters";
|
|
212
|
+
*
|
|
213
|
+
* console.log((ORBITER_DIM_SHARE * 3389.5).toFixed(0), "km at Mars");
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
export declare const ORBITER_DIM_SHARE = 0.02;
|
|
217
|
+
/**
|
|
218
|
+
* Whether a page should draw an orbiter dim at a moment: a `modelled` path always (outside the fit's days, or a mean orbit only), and a `predicted` one when its worst error measured against
|
|
219
|
+
* Horizons in the days after the fit (`predictedErrorKm.max`) is more than `ORBITER_DIM_SHARE` of its body's mean radius. A `tracked` path is never dim; a craft with no path (`none`) is not drawn at all,
|
|
220
|
+
* and answers `true`.
|
|
221
|
+
*
|
|
222
|
+
* @param id - The orbiter.
|
|
223
|
+
* @param when - A `Date` or milliseconds since 1970 (UTC).
|
|
224
|
+
* @returns `true` to draw it dim.
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```ts
|
|
228
|
+
* import { orbiterDim, orbiterStatus } from "@johnmorrisdotca/wakusei-planets/orbiters";
|
|
229
|
+
*
|
|
230
|
+
* const when = Date.UTC(2026, 10, 12);
|
|
231
|
+
* console.log(orbiterStatus("hope", when), orbiterDim("hope", when), orbiterStatus("lro", when), orbiterDim("lro", when));
|
|
232
|
+
* ```
|
|
233
|
+
*/
|
|
234
|
+
export declare function orbiterDim(id: OrbiterId, when: When): boolean;
|
|
205
235
|
/**
|
|
206
236
|
* The orbit as points round one trip, in kilometres from the body's centre, ecliptic J2000, at the moment's node and periapsis: for an orbit line.
|
|
207
237
|
*
|
|
@@ -218,6 +248,96 @@ export declare function orbiterNumbers(id: OrbiterId, when: When): {
|
|
|
218
248
|
* ```
|
|
219
249
|
*/
|
|
220
250
|
export declare function orbiterPath(id: OrbiterId, when: When, points?: number): Vec3[];
|
|
251
|
+
/**
|
|
252
|
+
* The point on the body straight below an orbiter at a moment: planetocentric latitude and east longitude in degrees (-180 to 180), from the body's IAU pole and prime meridian (the Moon's without
|
|
253
|
+
* its small wobbles, a degree or two).
|
|
254
|
+
*
|
|
255
|
+
* @param id - The orbiter.
|
|
256
|
+
* @param when - A `Date` or milliseconds since 1970 (UTC).
|
|
257
|
+
* @returns The point, or `undefined` for a craft with no path.
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* ```ts
|
|
261
|
+
* import { orbiterGround } from "@johnmorrisdotca/wakusei-planets/orbiters";
|
|
262
|
+
*
|
|
263
|
+
* const below = orbiterGround("mro", Date.UTC(2026, 10, 12))!;
|
|
264
|
+
* console.log(below.lat.toFixed(1), below.lon.toFixed(1));
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
267
|
+
export declare function orbiterGround(id: OrbiterId, when: When): {
|
|
268
|
+
lat: number;
|
|
269
|
+
lon: number;
|
|
270
|
+
} | undefined;
|
|
271
|
+
/**
|
|
272
|
+
* The ground track: the points under an orbiter from one moment to another, each with its moment, for a line on a map or a globe. The body turns beneath the orbit, so each trip crosses the
|
|
273
|
+
* equator further west.
|
|
274
|
+
*
|
|
275
|
+
* @param id - The orbiter.
|
|
276
|
+
* @param from - The first moment.
|
|
277
|
+
* @param to - The last moment.
|
|
278
|
+
* @param points - How many steps between them (there are `points + 1` points).
|
|
279
|
+
* @returns The points, or an empty list for a craft with no path.
|
|
280
|
+
*
|
|
281
|
+
* @example
|
|
282
|
+
* ```ts
|
|
283
|
+
* import { orbiterGroundTrack } from "@johnmorrisdotca/wakusei-planets/orbiters";
|
|
284
|
+
*
|
|
285
|
+
* const start = Date.UTC(2026, 10, 12);
|
|
286
|
+
* const track = orbiterGroundTrack("mro", start, start + 112 * 60_000, 8);
|
|
287
|
+
* console.log(track.map((p) => `${p.lat.toFixed(0)},${p.lon.toFixed(0)}`).join(" "));
|
|
288
|
+
* ```
|
|
289
|
+
*/
|
|
290
|
+
export declare function orbiterGroundTrack(id: OrbiterId, from: When, to: When, points?: number): {
|
|
291
|
+
lat: number;
|
|
292
|
+
lon: number;
|
|
293
|
+
ms: number;
|
|
294
|
+
}[];
|
|
295
|
+
/**
|
|
296
|
+
* One pass of an orbiter over a place: when it rises above the elevation asked for, when it is highest and how high, when it sets, and where its path came from at the highest moment.
|
|
297
|
+
*
|
|
298
|
+
* @example
|
|
299
|
+
* ```ts
|
|
300
|
+
* import { orbiterNextPass, type OrbiterPass } from "@johnmorrisdotca/wakusei-planets/orbiters";
|
|
301
|
+
*
|
|
302
|
+
* const pass: OrbiterPass | undefined = orbiterNextPass("mro", { lat: 18.4446, lon: 77.4508 }, Date.UTC(2026, 10, 12));
|
|
303
|
+
* console.log(pass && new Date(pass.highest).toISOString(), pass?.elevationDeg.toFixed(0));
|
|
304
|
+
* ```
|
|
305
|
+
*/
|
|
306
|
+
export interface OrbiterPass {
|
|
307
|
+
/** Milliseconds since 1970 (UTC). `rise` is before the moment asked about when the craft was already up then. */
|
|
308
|
+
rise: number;
|
|
309
|
+
highest: number;
|
|
310
|
+
set: number;
|
|
311
|
+
/** The elevation at the highest moment, in degrees above the horizon. */
|
|
312
|
+
elevationDeg: number;
|
|
313
|
+
status: OrbiterStatus;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* The next pass of an orbiter over a place on its body: the first time from `when` it is above `minElevationDeg` as seen from there, with the moment it is highest and the moment it sets. When it is
|
|
317
|
+
* already up at `when`, that pass is the one given (its rise is earlier). Searched in steps of a hundred and twentieth of a trip up to `withinDays` ahead, then narrowed to a second.
|
|
318
|
+
*
|
|
319
|
+
* @param id - The orbiter.
|
|
320
|
+
* @param place - Planetocentric latitude and east longitude on the body, in degrees (a place from `/places` fits).
|
|
321
|
+
* @param when - Where to start looking: a `Date` or milliseconds since 1970 (UTC).
|
|
322
|
+
* @param options - `minElevationDeg` (10 by default) and `withinDays` (30: a polar orbit round the slow-turning Moon comes back over a place about every two weeks).
|
|
323
|
+
* @returns The pass, or `undefined` when there is none in that time or the craft has no path.
|
|
324
|
+
*
|
|
325
|
+
* @example
|
|
326
|
+
* ```ts
|
|
327
|
+
* import { orbiterNextPass } from "@johnmorrisdotca/wakusei-planets/orbiters";
|
|
328
|
+
*
|
|
329
|
+
* // Jezero crater, where Perseverance landed
|
|
330
|
+
* const pass = orbiterNextPass("mro", { lat: 18.4446, lon: 77.4508 }, Date.UTC(2026, 10, 12))!;
|
|
331
|
+
* console.log(new Date(pass.rise).toISOString(), pass.elevationDeg.toFixed(0), "degrees up at best,", pass.status);
|
|
332
|
+
* ```
|
|
333
|
+
*/
|
|
334
|
+
export declare function orbiterNextPass(id: OrbiterId, place: {
|
|
335
|
+
lat: number;
|
|
336
|
+
lon: number;
|
|
337
|
+
}, when: When, options?: {
|
|
338
|
+
minElevationDeg?: number;
|
|
339
|
+
withinDays?: number;
|
|
340
|
+
}): OrbiterPass | undefined;
|
|
221
341
|
/**
|
|
222
342
|
* What is known about an orbiter: names, operator, launch, instruments, a line about it, and the state of its path.
|
|
223
343
|
*
|
package/dist/orbiters.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// equinox J2000, the same axes as `/roadster` and the ten deep-space craft; `eclipticToScene` from `/space` turns them into the space view's axes.
|
|
4
4
|
import { ORBITER_FITS } from "./data/orbiters.js";
|
|
5
5
|
import { ORBITER_FACTS } from "./orbiter-facts.js";
|
|
6
|
+
import { cross, DEG, dot, fromRaDec, toEcliptic, wrap360 } from "./vec.js";
|
|
6
7
|
export { ORBITER_FACTS } from "./orbiter-facts.js";
|
|
7
8
|
/**
|
|
8
9
|
* The orbiters the package knows: six round the Moon and seven round Mars.
|
|
@@ -161,6 +162,44 @@ export function orbiterNumbers(id, when) {
|
|
|
161
162
|
}
|
|
162
163
|
/** The mean radius of the Moon and Mars in kilometres (IAU), for heights above the surface. */
|
|
163
164
|
const MEAN_RADIUS_KM = { moon: 1737.4, mars: 3389.5 };
|
|
165
|
+
/**
|
|
166
|
+
* How far a predicted path may miss Horizons, as a share of its body's mean radius, and still be drawn as a tracked one is: 2 per cent, about 35 km at the Moon and 68 km at Mars, a hair's breadth
|
|
167
|
+
* on a picture of the body.
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```ts
|
|
171
|
+
* import { ORBITER_DIM_SHARE } from "@johnmorrisdotca/wakusei-planets/orbiters";
|
|
172
|
+
*
|
|
173
|
+
* console.log((ORBITER_DIM_SHARE * 3389.5).toFixed(0), "km at Mars");
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
export const ORBITER_DIM_SHARE = 0.02;
|
|
177
|
+
/**
|
|
178
|
+
* Whether a page should draw an orbiter dim at a moment: a `modelled` path always (outside the fit's days, or a mean orbit only), and a `predicted` one when its worst error measured against
|
|
179
|
+
* Horizons in the days after the fit (`predictedErrorKm.max`) is more than `ORBITER_DIM_SHARE` of its body's mean radius. A `tracked` path is never dim; a craft with no path (`none`) is not drawn at all,
|
|
180
|
+
* and answers `true`.
|
|
181
|
+
*
|
|
182
|
+
* @param id - The orbiter.
|
|
183
|
+
* @param when - A `Date` or milliseconds since 1970 (UTC).
|
|
184
|
+
* @returns `true` to draw it dim.
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```ts
|
|
188
|
+
* import { orbiterDim, orbiterStatus } from "@johnmorrisdotca/wakusei-planets/orbiters";
|
|
189
|
+
*
|
|
190
|
+
* const when = Date.UTC(2026, 10, 12);
|
|
191
|
+
* console.log(orbiterStatus("hope", when), orbiterDim("hope", when), orbiterStatus("lro", when), orbiterDim("lro", when));
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
export function orbiterDim(id, when) {
|
|
195
|
+
const status = orbiterStatus(id, when);
|
|
196
|
+
if (status === "tracked")
|
|
197
|
+
return false;
|
|
198
|
+
if (status !== "predicted")
|
|
199
|
+
return true;
|
|
200
|
+
const error = orbiterElements(id)?.predictedErrorKm?.max;
|
|
201
|
+
return error === undefined || error > ORBITER_DIM_SHARE * MEAN_RADIUS_KM[orbiterCentre(id)];
|
|
202
|
+
}
|
|
164
203
|
/**
|
|
165
204
|
* The orbit as points round one trip, in kilometres from the body's centre, ecliptic J2000, at the moment's node and periapsis: for an orbit line.
|
|
166
205
|
*
|
|
@@ -184,7 +223,7 @@ export function orbiterPath(id, when, points = 96) {
|
|
|
184
223
|
const out = [];
|
|
185
224
|
// evenly spaced in eccentric anomaly, not mean: a lopsided orbit (ARTEMIS P1, e about 0.8) is then sampled fastest where it bends least, and has no sharp corner at periapsis
|
|
186
225
|
for (let k = 0; k <= points; k += 1)
|
|
187
|
-
out.push(placeAt(elements, dt, (2 * Math.PI * k) / points));
|
|
226
|
+
out.push(toEclipticOf(id, placeAt(elements, dt, (2 * Math.PI * k) / points)));
|
|
188
227
|
return out;
|
|
189
228
|
}
|
|
190
229
|
function stateOf(id, when) {
|
|
@@ -195,10 +234,24 @@ function stateOf(id, when) {
|
|
|
195
234
|
const dt = tdbJdOf(when) - elements.epochJd;
|
|
196
235
|
const n = meanMotion(elements, centre);
|
|
197
236
|
const m = (elements.m0 + n * dt) % 360;
|
|
198
|
-
const
|
|
237
|
+
const body = placeOf(elements, centre, dt, undefined, m);
|
|
199
238
|
// the velocity from the ellipse: a small step along it in time
|
|
200
239
|
const later = placeOf(elements, centre, dt + 1 / 86_400, undefined, (elements.m0 + n * (dt + 1 / 86_400)) % 360);
|
|
201
|
-
return { position, velocity: [later[0] -
|
|
240
|
+
return { position: toEclipticOf(id, body), velocity: toEclipticOf(id, [later[0] - body[0], later[1] - body[1], later[2] - body[2]]), body };
|
|
241
|
+
}
|
|
242
|
+
/** The body's equator frame in ecliptic J2000 axes, from the pole the data file carries: x to the ascending node of the body's equator on the Earth's J2000 equator, z to the pole. */
|
|
243
|
+
const frames = new Map();
|
|
244
|
+
function toEclipticOf(id, v) {
|
|
245
|
+
const [ra, dec] = ORBITER_FITS[id].pole;
|
|
246
|
+
let frame = frames.get(id);
|
|
247
|
+
if (frame === undefined) {
|
|
248
|
+
const pole = toEcliptic(fromRaDec(ra, dec));
|
|
249
|
+
const node = toEcliptic(fromRaDec(ra + 90, 0));
|
|
250
|
+
frame = [node, cross(pole, node), pole];
|
|
251
|
+
frames.set(id, frame);
|
|
252
|
+
}
|
|
253
|
+
const [x, y, z] = frame;
|
|
254
|
+
return [v[0] * x[0] + v[1] * y[0] + v[2] * z[0], v[0] * x[1] + v[1] * y[1] + v[2] * z[1], v[0] * x[2] + v[1] * y[2] + v[2] * z[2]];
|
|
202
255
|
}
|
|
203
256
|
/** The mean motion in degrees a day: Kepler's for `a`, corrected by the fit. */
|
|
204
257
|
const meanMotion = (elements, centre) => (Math.sqrt(GM[centre] / elements.a ** 3) * 86_400) / RAD + elements.meanMotionCorrection;
|
|
@@ -227,6 +280,155 @@ function placeAt(elements, dt, ea) {
|
|
|
227
280
|
r * Math.sin(u) * Math.sin(inc),
|
|
228
281
|
];
|
|
229
282
|
}
|
|
283
|
+
const J2000_TDB_JD = 2451545.0;
|
|
284
|
+
/** The latitude and east longitude under a point of the body's equator frame at a TDB Julian date, from the IAU prime meridian the data file carries. */
|
|
285
|
+
function groundOf(id, body, jd) {
|
|
286
|
+
const [w0, rate] = ORBITER_FITS[id].prime;
|
|
287
|
+
const r = Math.hypot(body[0], body[1], body[2]);
|
|
288
|
+
const lon = wrap360(Math.atan2(body[1], body[0]) * DEG - (w0 + rate * (jd - J2000_TDB_JD)) + 180) - 180;
|
|
289
|
+
return { lat: Math.asin(body[2] / r) * DEG, lon };
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* The point on the body straight below an orbiter at a moment: planetocentric latitude and east longitude in degrees (-180 to 180), from the body's IAU pole and prime meridian (the Moon's without
|
|
293
|
+
* its small wobbles, a degree or two).
|
|
294
|
+
*
|
|
295
|
+
* @param id - The orbiter.
|
|
296
|
+
* @param when - A `Date` or milliseconds since 1970 (UTC).
|
|
297
|
+
* @returns The point, or `undefined` for a craft with no path.
|
|
298
|
+
*
|
|
299
|
+
* @example
|
|
300
|
+
* ```ts
|
|
301
|
+
* import { orbiterGround } from "@johnmorrisdotca/wakusei-planets/orbiters";
|
|
302
|
+
*
|
|
303
|
+
* const below = orbiterGround("mro", Date.UTC(2026, 10, 12))!;
|
|
304
|
+
* console.log(below.lat.toFixed(1), below.lon.toFixed(1));
|
|
305
|
+
* ```
|
|
306
|
+
*/
|
|
307
|
+
export function orbiterGround(id, when) {
|
|
308
|
+
if (orbiterElements(id) === undefined)
|
|
309
|
+
return undefined;
|
|
310
|
+
return groundOf(id, stateOf(id, when).body, tdbJdOf(when));
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* The ground track: the points under an orbiter from one moment to another, each with its moment, for a line on a map or a globe. The body turns beneath the orbit, so each trip crosses the
|
|
314
|
+
* equator further west.
|
|
315
|
+
*
|
|
316
|
+
* @param id - The orbiter.
|
|
317
|
+
* @param from - The first moment.
|
|
318
|
+
* @param to - The last moment.
|
|
319
|
+
* @param points - How many steps between them (there are `points + 1` points).
|
|
320
|
+
* @returns The points, or an empty list for a craft with no path.
|
|
321
|
+
*
|
|
322
|
+
* @example
|
|
323
|
+
* ```ts
|
|
324
|
+
* import { orbiterGroundTrack } from "@johnmorrisdotca/wakusei-planets/orbiters";
|
|
325
|
+
*
|
|
326
|
+
* const start = Date.UTC(2026, 10, 12);
|
|
327
|
+
* const track = orbiterGroundTrack("mro", start, start + 112 * 60_000, 8);
|
|
328
|
+
* console.log(track.map((p) => `${p.lat.toFixed(0)},${p.lon.toFixed(0)}`).join(" "));
|
|
329
|
+
* ```
|
|
330
|
+
*/
|
|
331
|
+
export function orbiterGroundTrack(id, from, to, points = 120) {
|
|
332
|
+
if (orbiterElements(id) === undefined)
|
|
333
|
+
return [];
|
|
334
|
+
const a = msOf(from);
|
|
335
|
+
const b = msOf(to);
|
|
336
|
+
const out = [];
|
|
337
|
+
for (let k = 0; k <= points; k += 1) {
|
|
338
|
+
const ms = a + ((b - a) * k) / points;
|
|
339
|
+
out.push({ ...groundOf(id, stateOf(id, ms).body, tdbJdOf(ms)), ms });
|
|
340
|
+
}
|
|
341
|
+
return out;
|
|
342
|
+
}
|
|
343
|
+
/** The elevation of a craft above the horizon of a place on the body's mean sphere, in degrees. */
|
|
344
|
+
function elevationAt(id, site, ms) {
|
|
345
|
+
const jd = tdbJdOf(ms);
|
|
346
|
+
const body = stateOf(id, ms).body;
|
|
347
|
+
const [w0, rate] = ORBITER_FITS[id].prime;
|
|
348
|
+
const lon = (site.lon + w0 + rate * (jd - J2000_TDB_JD)) * RAD;
|
|
349
|
+
const lat = site.lat * RAD;
|
|
350
|
+
const up = [Math.cos(lat) * Math.cos(lon), Math.cos(lat) * Math.sin(lon), Math.sin(lat)];
|
|
351
|
+
const radius = MEAN_RADIUS_KM[orbiterCentre(id)];
|
|
352
|
+
const d = [body[0] - up[0] * radius, body[1] - up[1] * radius, body[2] - up[2] * radius];
|
|
353
|
+
return Math.asin(Math.max(-1, Math.min(1, dot(d, up) / Math.hypot(d[0], d[1], d[2])))) * DEG;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* The next pass of an orbiter over a place on its body: the first time from `when` it is above `minElevationDeg` as seen from there, with the moment it is highest and the moment it sets. When it is
|
|
357
|
+
* already up at `when`, that pass is the one given (its rise is earlier). Searched in steps of a hundred and twentieth of a trip up to `withinDays` ahead, then narrowed to a second.
|
|
358
|
+
*
|
|
359
|
+
* @param id - The orbiter.
|
|
360
|
+
* @param place - Planetocentric latitude and east longitude on the body, in degrees (a place from `/places` fits).
|
|
361
|
+
* @param when - Where to start looking: a `Date` or milliseconds since 1970 (UTC).
|
|
362
|
+
* @param options - `minElevationDeg` (10 by default) and `withinDays` (30: a polar orbit round the slow-turning Moon comes back over a place about every two weeks).
|
|
363
|
+
* @returns The pass, or `undefined` when there is none in that time or the craft has no path.
|
|
364
|
+
*
|
|
365
|
+
* @example
|
|
366
|
+
* ```ts
|
|
367
|
+
* import { orbiterNextPass } from "@johnmorrisdotca/wakusei-planets/orbiters";
|
|
368
|
+
*
|
|
369
|
+
* // Jezero crater, where Perseverance landed
|
|
370
|
+
* const pass = orbiterNextPass("mro", { lat: 18.4446, lon: 77.4508 }, Date.UTC(2026, 10, 12))!;
|
|
371
|
+
* console.log(new Date(pass.rise).toISOString(), pass.elevationDeg.toFixed(0), "degrees up at best,", pass.status);
|
|
372
|
+
* ```
|
|
373
|
+
*/
|
|
374
|
+
export function orbiterNextPass(id, place, when, options = {}) {
|
|
375
|
+
const elements = orbiterElements(id);
|
|
376
|
+
if (elements === undefined)
|
|
377
|
+
return undefined;
|
|
378
|
+
const start = msOf(when);
|
|
379
|
+
const min = options.minElevationDeg ?? 10;
|
|
380
|
+
const end = start + (options.withinDays ?? 30) * 86_400_000;
|
|
381
|
+
const trip = elements.periodDays * 86_400_000;
|
|
382
|
+
const step = Math.max(10_000, trip / 120);
|
|
383
|
+
const above = (ms) => elevationAt(id, place, ms) - min;
|
|
384
|
+
// the moment between two others where the elevation crosses the limit, to a second
|
|
385
|
+
const edge = (lo, hi) => {
|
|
386
|
+
const belowAtLo = above(lo) < 0;
|
|
387
|
+
while (hi - lo > 1000) {
|
|
388
|
+
const mid = (lo + hi) / 2;
|
|
389
|
+
if (above(mid) < 0 === belowAtLo)
|
|
390
|
+
lo = mid;
|
|
391
|
+
else
|
|
392
|
+
hi = mid;
|
|
393
|
+
}
|
|
394
|
+
return Math.round((lo + hi) / 2);
|
|
395
|
+
};
|
|
396
|
+
let rise;
|
|
397
|
+
let t = start;
|
|
398
|
+
if (above(t) >= 0) {
|
|
399
|
+
// up already: back to its rise, no further than a trip
|
|
400
|
+
let back = t;
|
|
401
|
+
while (above(back - step) >= 0 && t - back < trip)
|
|
402
|
+
back -= step;
|
|
403
|
+
rise = above(back - step) < 0 ? edge(back - step, back) : back;
|
|
404
|
+
}
|
|
405
|
+
else {
|
|
406
|
+
while (t < end && above(t + step) < 0)
|
|
407
|
+
t += step;
|
|
408
|
+
if (t >= end)
|
|
409
|
+
return undefined;
|
|
410
|
+
rise = edge(t, t + step);
|
|
411
|
+
t += step;
|
|
412
|
+
}
|
|
413
|
+
let set = Math.max(t, rise);
|
|
414
|
+
while (above(set + step) >= 0 && set - rise < trip)
|
|
415
|
+
set += step;
|
|
416
|
+
set = above(set + step) < 0 ? edge(set, set + step) : set;
|
|
417
|
+
// the highest moment: golden-section search between rise and set
|
|
418
|
+
let lo = rise;
|
|
419
|
+
let hi = set;
|
|
420
|
+
const g = (Math.sqrt(5) - 1) / 2;
|
|
421
|
+
while (hi - lo > 1000) {
|
|
422
|
+
const m1 = hi - g * (hi - lo);
|
|
423
|
+
const m2 = lo + g * (hi - lo);
|
|
424
|
+
if (above(m1) < above(m2))
|
|
425
|
+
lo = m1;
|
|
426
|
+
else
|
|
427
|
+
hi = m2;
|
|
428
|
+
}
|
|
429
|
+
const highest = Math.round((lo + hi) / 2);
|
|
430
|
+
return { rise, highest, set, elevationDeg: elevationAt(id, place, highest), status: orbiterStatus(id, highest) };
|
|
431
|
+
}
|
|
230
432
|
/**
|
|
231
433
|
* What is known about an orbiter: names, operator, launch, instruments, a line about it, and the state of its path.
|
|
232
434
|
*
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { type BodyId } from "./facts.ts";
|
|
2
|
+
/**
|
|
3
|
+
* One body's surface picture: who made the map, the licence named in `NOTICE.md`, and, for a CC BY 4.0 map, what this package changed.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { PICTURE_CREDITS, type PictureCredit } from "@johnmorrisdotca/wakusei-planets";
|
|
8
|
+
*
|
|
9
|
+
* const jupiter: PictureCredit = PICTURE_CREDITS.find((row) => row.id === "jupiter")!;
|
|
10
|
+
* console.log(jupiter.licence);
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export interface PictureCredit {
|
|
14
|
+
/** The body, as `BODY_IDS` names it. */
|
|
15
|
+
readonly id: BodyId;
|
|
16
|
+
/** The licence of that body's map in `NOTICE.md`: `CC BY 4.0` or `Public domain`. */
|
|
17
|
+
readonly licence: "CC BY 4.0" | "Public domain";
|
|
18
|
+
/** The credit column of `NOTICE.md` for this picture, in English, and the same fact in Japanese. */
|
|
19
|
+
readonly credit: {
|
|
20
|
+
readonly en: string;
|
|
21
|
+
readonly ja: string;
|
|
22
|
+
};
|
|
23
|
+
/** What this package changed, from the table's "What was done" column. Present for a CC BY 4.0 map, which asks that changes be named. */
|
|
24
|
+
readonly changes?: {
|
|
25
|
+
readonly en: string;
|
|
26
|
+
readonly ja: string;
|
|
27
|
+
};
|
|
28
|
+
/** Another picture drawn with the body (Saturn's rings), with its own credit and licence. */
|
|
29
|
+
readonly also?: {
|
|
30
|
+
readonly en: string;
|
|
31
|
+
readonly ja: string;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The surface picture of every body that has one, in the order of the table in `NOTICE.md`. A body with no row is drawn from numbers and has no picture to credit.
|
|
36
|
+
* The English of a CC BY 4.0 row is that table's credit column. Jupiter and Uranus keep the authors' own attribution sentences, including the spelling of the name.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* import { PICTURE_CREDITS } from "@johnmorrisdotca/wakusei-planets";
|
|
41
|
+
*
|
|
42
|
+
* console.log(PICTURE_CREDITS.filter((row) => row.licence === "CC BY 4.0").map((row) => row.id).join(","));
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare const PICTURE_CREDITS: readonly PictureCredit[];
|
|
46
|
+
/**
|
|
47
|
+
* The credit for Mercury's finer map tiles. Their detail is a public-domain map, and their colour is the 2048 picture, which is CC BY 4.0, so the tiles carry that credit too.
|
|
48
|
+
* The words are the Mercury row of `NOTICE.md`'s "Finer map tiles" table.
|
|
49
|
+
*
|
|
50
|
+
* @param lang - `en` or `ja`.
|
|
51
|
+
* @returns The one sentence.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* import { mercuryTilesCredit } from "@johnmorrisdotca/wakusei-planets";
|
|
56
|
+
*
|
|
57
|
+
* console.log(mercuryTilesCredit("en").includes("CC BY 4.0"));
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare function mercuryTilesCredit(lang: "en" | "ja"): string;
|
|
61
|
+
/**
|
|
62
|
+
* The credit line for the surface pictures of the named bodies, in one language. A name is a body id in any case (`Jupiter`, `moon`). A body with no picture is left out.
|
|
63
|
+
* Only the named bodies are credited: Jupiter names Nestaeric and CC BY 4.0, and the Moon and Mars, whose maps are public domain, name no CC BY 4.0 source.
|
|
64
|
+
* An empty list, or a list of bodies with no pictures, is an empty string.
|
|
65
|
+
*
|
|
66
|
+
* @param bodies - The bodies a page is showing.
|
|
67
|
+
* @param lang - `en` or `ja`.
|
|
68
|
+
* @returns The line, or `""` when none of the bodies has a picture.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* import { picturesCredit } from "@johnmorrisdotca/wakusei-planets";
|
|
73
|
+
*
|
|
74
|
+
* console.log(picturesCredit(["Jupiter"], "en").includes("Nestaeric"));
|
|
75
|
+
* console.log(picturesCredit(["Moon", "Mars"], "en").includes("CC BY") === false);
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export declare function picturesCredit(bodies: readonly string[], lang: "en" | "ja"): string;
|