@johnmorrisdotca/wakusei-planets 0.64.0 → 0.66.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 +24 -0
- package/NOTICE.md +10 -1
- package/README.md +3 -3
- package/dist/data/discovery.d.ts +3 -0
- package/dist/data/discovery.js +719 -0
- package/dist/data/moon-catalogue.d.ts +4 -2
- package/dist/data/moon-catalogue.js +468 -468
- package/dist/data/moon-osculating.d.ts +6 -0
- package/dist/data/moon-osculating.js +401 -0
- package/dist/discovery.d.ts +118 -0
- package/dist/discovery.js +67 -0
- package/dist/facts.js +1 -1
- package/dist/moon-catalogue.d.ts +88 -2
- package/dist/moon-catalogue.js +94 -14
- package/dist/plan/element.d.ts +7 -1
- package/dist/plan/element.js +44 -28
- package/dist/plan/layout.d.ts +7 -0
- package/dist/plan/layout.js +7 -5
- package/dist/plan/svg.js +2 -1
- package/dist/space/element.d.ts +24 -0
- package/dist/space/element.js +79 -10
- package/dist/space/index.d.ts +1 -1
- package/dist/space/index.js +1 -1
- package/dist/space/labels.d.ts +116 -2
- package/dist/space/labels.js +107 -8
- package/dist/space/scene.d.ts +2 -0
- package/dist/space/scene.js +31 -23
- package/dist/space/travel.d.ts +2 -2
- package/dist/space/travel.js +2 -2
- package/dist/surface/element.d.ts +1 -0
- package/dist/surface/element.js +1 -1
- package/dist/surface/scene.d.ts +2 -0
- package/dist/surface/scene.js +7 -1
- package/package.json +6 -1
package/dist/moon-catalogue.d.ts
CHANGED
|
@@ -43,6 +43,51 @@ export declare const MOON_GROUPS: readonly MoonGroup[];
|
|
|
43
43
|
* ```
|
|
44
44
|
*/
|
|
45
45
|
export type MoonGrade = "close" | "rough" | "loose" | "unmeasured" | "none";
|
|
46
|
+
/**
|
|
47
|
+
* The osculating orbit of an irregular moon on one day: the two-body orbit that fits its place and speed that day (JPL Horizons), in the J2000 ecliptic frame, as `a` (km), `e`, `i`, `node`, `w` (the argument of periapsis)
|
|
48
|
+
* and `m` (the mean anomaly), all angles in degrees, at `epochJd` (a Julian date, TDB). A mean orbit cannot follow the Sun's pull on an irregular moon; this one does, for a few months either side of the day
|
|
49
|
+
* (`MOON_OSCULATING_DAYS`), and `catalogueMoonPosition` uses it there.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* import { findCatalogueMoon, type MoonOsculating } from "@johnmorrisdotca/wakusei-planets/moon-catalogue";
|
|
54
|
+
*
|
|
55
|
+
* const orbit: MoonOsculating | null = findCatalogueMoon("Himalia")!.osculating;
|
|
56
|
+
* console.log(orbit?.epochJd, Math.round(orbit?.a ?? 0), "km");
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export interface MoonOsculating {
|
|
60
|
+
epochJd: number;
|
|
61
|
+
a: number;
|
|
62
|
+
e: number;
|
|
63
|
+
i: number;
|
|
64
|
+
node: number;
|
|
65
|
+
w: number;
|
|
66
|
+
m: number;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The Julian date (TDB) of the day the osculating orbits are taken at (2026-12-01).
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* import { MOON_OSCULATING_EPOCH_JD } from "@johnmorrisdotca/wakusei-planets/moon-catalogue";
|
|
74
|
+
*
|
|
75
|
+
* console.log("osculating orbits taken at JD", MOON_OSCULATING_EPOCH_JD);
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export declare const MOON_OSCULATING_EPOCH_JD = 2461375.5;
|
|
79
|
+
/**
|
|
80
|
+
* The days either side of `MOON_OSCULATING_EPOCH_JD` inside which `catalogueMoonPosition` uses a moon's osculating orbit, and outside which it uses the mean orbit. Measured against Horizons on dates the orbit was not set
|
|
81
|
+
* from, the osculating orbit is within a degree of the moon for 95 moons in 100 and within 0.1 degrees for half of them over the 150 days (the worst, among Jupiter's moons, is about 7 degrees); the mean orbit of an irregular moon is tens of degrees off.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* import { MOON_OSCULATING_DAYS } from "@johnmorrisdotca/wakusei-planets/moon-catalogue";
|
|
86
|
+
*
|
|
87
|
+
* console.log("irregular moons follow Horizons for", MOON_OSCULATING_DAYS, "days either side");
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export declare const MOON_OSCULATING_DAYS = 150;
|
|
46
91
|
/**
|
|
47
92
|
* A moon's mean orbit: JPL's "Planetary Satellite Mean Elements" (the ellipse, how fast its periapsis and node turn, and the plane it is measured from), carried at those rates to 2026-01-01 and with the mean anomaly set
|
|
48
93
|
* so the moon is where JPL Horizons puts it that day, and its rate along the orbit fitted to where Horizons puts it over the next three months. The shape, the plane and the turning of the periapsis and node are JPL's; the
|
|
@@ -106,7 +151,7 @@ export interface MoonDiscovery {
|
|
|
106
151
|
}
|
|
107
152
|
/**
|
|
108
153
|
* Where a moon's size comes from: `measured` (JPL's "Planetary Satellite Physical Parameters", with its uncertainty), `sheet` (the radius on the moon's JPL Horizons data sheet) or `derived` (worked out here from the
|
|
109
|
-
* moon's
|
|
154
|
+
* moon's magnitude and an albedo: the sheet's albedo where it gives one, else `ASSUMED_ALBEDO`, by D = 10^(3.1236 - 0.5 log10(albedo) - 0.2 V), the formula of NASA/JPL's asteroid size estimator).
|
|
110
155
|
*
|
|
111
156
|
* @example
|
|
112
157
|
* ```ts
|
|
@@ -117,6 +162,43 @@ export interface MoonDiscovery {
|
|
|
117
162
|
* ```
|
|
118
163
|
*/
|
|
119
164
|
export type MoonSizeSource = "measured" | "sheet" | "derived";
|
|
165
|
+
/**
|
|
166
|
+
* Where a moon's magnitude comes from: `sheet` (the V(1,0) magnitude on its JPL Horizons data sheet) or `wikipedia` (the absolute magnitude of English Wikipedia's table of the moons of its planet, which takes the irregular
|
|
167
|
+
* moons' from the Minor Planet Center's Natural Satellites Ephemeris Service; read on `MOON_MAGNITUDES_READ`, the page is in `MOON_MAGNITUDE_PAGES`). A size worked out from a `wikipedia` magnitude is an estimate: it assumes the
|
|
168
|
+
* albedo `ASSUMED_ALBEDO`, and `radiusFrom` says `derived`.
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```ts
|
|
172
|
+
* import { findCatalogueMoon, type MoonMagnitudeSource } from "@johnmorrisdotca/wakusei-planets/moon-catalogue";
|
|
173
|
+
*
|
|
174
|
+
* const from: MoonMagnitudeSource | null = findCatalogueMoon("Ymir")!.magnitudeFrom;
|
|
175
|
+
* console.log(from);
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
export type MoonMagnitudeSource = "sheet" | "wikipedia";
|
|
179
|
+
/**
|
|
180
|
+
* The day the magnitudes marked `wikipedia` were read from English Wikipedia's tables (CC BY-SA 4.0): one request for each of the four pages.
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* ```ts
|
|
184
|
+
* import { MOON_MAGNITUDES_READ } from "@johnmorrisdotca/wakusei-planets/moon-catalogue";
|
|
185
|
+
*
|
|
186
|
+
* console.log("Wikipedia read on", MOON_MAGNITUDES_READ);
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
export declare const MOON_MAGNITUDES_READ = "2026-11-18";
|
|
190
|
+
/**
|
|
191
|
+
* The English Wikipedia page each host's `wikipedia` magnitudes were read from.
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```ts
|
|
195
|
+
* import { findCatalogueMoon, MOON_MAGNITUDE_PAGES } from "@johnmorrisdotca/wakusei-planets/moon-catalogue";
|
|
196
|
+
*
|
|
197
|
+
* const moon = findCatalogueMoon("Ymir")!;
|
|
198
|
+
* if (moon.magnitudeFrom === "wikipedia") console.log(MOON_MAGNITUDE_PAGES[moon.host]);
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
201
|
+
export declare const MOON_MAGNITUDE_PAGES: Readonly<Partial<Record<HostId, string>>>;
|
|
120
202
|
/**
|
|
121
203
|
* One moon of the catalogue. A number the sources do not give is `null`, never guessed.
|
|
122
204
|
*
|
|
@@ -153,6 +235,8 @@ export interface CatalogueMoon {
|
|
|
153
235
|
discovery: MoonDiscovery;
|
|
154
236
|
/** The mean orbit, or `null` when the source gives none. */
|
|
155
237
|
orbit: MoonOrbit | null;
|
|
238
|
+
/** The osculating orbit on `MOON_OSCULATING_EPOCH_JD`, for an irregular moon of a giant planet; `null` for the others. */
|
|
239
|
+
osculating: MoonOsculating | null;
|
|
156
240
|
/** Whether it goes round against its planet's turn (an inclination over 90 degrees), or `null` with no orbit. */
|
|
157
241
|
retrograde: boolean | null;
|
|
158
242
|
/** The dynamical group. */
|
|
@@ -165,8 +249,10 @@ export interface CatalogueMoon {
|
|
|
165
249
|
radiusFrom: MoonSizeSource | null;
|
|
166
250
|
/** The geometric albedo, where the Horizons sheet gives one. */
|
|
167
251
|
albedo: number | null;
|
|
168
|
-
/** The V(1,0) magnitude (as bright as it would be 1 au from the Sun and from us), where the Horizons sheet gives one. */
|
|
252
|
+
/** The V(1,0) magnitude (as bright as it would be 1 au from the Sun and from us), where the Horizons sheet gives one, else, for an irregular moon with no size, the absolute magnitude of English Wikipedia's table (see `magnitudeFrom`). */
|
|
169
253
|
magnitude: number | null;
|
|
254
|
+
/** Where `magnitude` comes from; `null` when there is none. */
|
|
255
|
+
magnitudeFrom: MoonMagnitudeSource | null;
|
|
170
256
|
/**
|
|
171
257
|
* How far `catalogueMoonPosition` was from JPL Horizons: the worst distance (km) and angle seen from the planet (degrees) on 2025-07-02, 2026-07-02 and 2027-07-02 (dates the orbit was not set from), and the worst angle
|
|
172
258
|
* decades away (1990, 2000 and 2040; `null` where Horizons has none of them). `null` when not measured.
|
package/dist/moon-catalogue.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// with how far that position was measured to be from JPL Horizons. The rows (scripts/make-moon-catalogue.py, src/data/moon-catalogue.ts) are imported by this entry point only, so a page that does not import
|
|
3
3
|
// `/moon-catalogue` does not carry them. Positions are from the planet's centre, in kilometres, in the J2000 ecliptic frame (the axes `moonVector` gives). Pure: no DOM, no clock reads, no three.js.
|
|
4
4
|
import { MOON_CATALOGUE_READ, MOON_CATALOGUE_ROWS } from "./data/moon-catalogue.js";
|
|
5
|
+
import { MOON_OSCULATING, MOON_OSCULATING_EPOCH_JD as OSCULATING_EPOCH_JD } from "./data/moon-osculating.js";
|
|
5
6
|
import { toTerrestrialTime } from "./clock.js";
|
|
6
7
|
import { kepler } from "./ephemeris.js";
|
|
7
8
|
import { cross, fromRaDec, RAD, toEcliptic } from "./vec.js";
|
|
@@ -20,6 +21,71 @@ const YEAR_DAYS = 365.25;
|
|
|
20
21
|
* ```
|
|
21
22
|
*/
|
|
22
23
|
export const MOON_GROUPS = ["inner", "major", "regular", "themisto", "himalia", "carpo", "valetudo", "ananke", "carme", "pasiphae", "inuit", "gallic", "norse", "prograde", "retrograde", "none"];
|
|
24
|
+
/**
|
|
25
|
+
* The Julian date (TDB) of the day the osculating orbits are taken at (2026-12-01).
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* import { MOON_OSCULATING_EPOCH_JD } from "@johnmorrisdotca/wakusei-planets/moon-catalogue";
|
|
30
|
+
*
|
|
31
|
+
* console.log("osculating orbits taken at JD", MOON_OSCULATING_EPOCH_JD);
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export const MOON_OSCULATING_EPOCH_JD = OSCULATING_EPOCH_JD;
|
|
35
|
+
/**
|
|
36
|
+
* The days either side of `MOON_OSCULATING_EPOCH_JD` inside which `catalogueMoonPosition` uses a moon's osculating orbit, and outside which it uses the mean orbit. Measured against Horizons on dates the orbit was not set
|
|
37
|
+
* from, the osculating orbit is within a degree of the moon for 95 moons in 100 and within 0.1 degrees for half of them over the 150 days (the worst, among Jupiter's moons, is about 7 degrees); the mean orbit of an irregular moon is tens of degrees off.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* import { MOON_OSCULATING_DAYS } from "@johnmorrisdotca/wakusei-planets/moon-catalogue";
|
|
42
|
+
*
|
|
43
|
+
* console.log("irregular moons follow Horizons for", MOON_OSCULATING_DAYS, "days either side");
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export const MOON_OSCULATING_DAYS = 150;
|
|
47
|
+
// the GM of the planet each osculating orbit goes round, km^3/s^2: the planet's system, from JPL's "Planetary Satellite Physical Parameters" (the same numbers the build script took the elements with)
|
|
48
|
+
const HOST_GM = { jupiter: 126_686_534.9, saturn: 37_931_207.8, uranus: 5_793_951.3, neptune: 6_835_099.5 };
|
|
49
|
+
// the whole numbers of data/moon-osculating.ts go to the irregular moons of the giant planets that have a mean orbit, in the order of the rows (the build script writes them in that order, and a test holds the two to each other)
|
|
50
|
+
const OSCULATING = new Map();
|
|
51
|
+
{
|
|
52
|
+
let at = 0;
|
|
53
|
+
for (const row of MOON_CATALOGUE_ROWS) {
|
|
54
|
+
if (row[9] === null || ["regular", "inner", "major", "none"].includes(row[18]) || HOST_GM[row[4]] === undefined)
|
|
55
|
+
continue;
|
|
56
|
+
const [a, e, i, node, w, m] = MOON_OSCULATING.slice(at, at + 6);
|
|
57
|
+
OSCULATING.set(row[0], { epochJd: OSCULATING_EPOCH_JD, a: a * 100, e: e / 1e4, i: i / 100, node: node / 100, w: w / 100, m: m / 100 });
|
|
58
|
+
at += 6;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The day the magnitudes marked `wikipedia` were read from English Wikipedia's tables (CC BY-SA 4.0): one request for each of the four pages.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* import { MOON_MAGNITUDES_READ } from "@johnmorrisdotca/wakusei-planets/moon-catalogue";
|
|
67
|
+
*
|
|
68
|
+
* console.log("Wikipedia read on", MOON_MAGNITUDES_READ);
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export const MOON_MAGNITUDES_READ = "2026-11-18";
|
|
72
|
+
/**
|
|
73
|
+
* The English Wikipedia page each host's `wikipedia` magnitudes were read from.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* import { findCatalogueMoon, MOON_MAGNITUDE_PAGES } from "@johnmorrisdotca/wakusei-planets/moon-catalogue";
|
|
78
|
+
*
|
|
79
|
+
* const moon = findCatalogueMoon("Ymir")!;
|
|
80
|
+
* if (moon.magnitudeFrom === "wikipedia") console.log(MOON_MAGNITUDE_PAGES[moon.host]);
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export const MOON_MAGNITUDE_PAGES = {
|
|
84
|
+
jupiter: "https://en.wikipedia.org/wiki/Moons_of_Jupiter",
|
|
85
|
+
saturn: "https://en.wikipedia.org/wiki/Moons_of_Saturn",
|
|
86
|
+
uranus: "https://en.wikipedia.org/wiki/Moons_of_Uranus",
|
|
87
|
+
neptune: "https://en.wikipedia.org/wiki/Moons_of_Neptune",
|
|
88
|
+
};
|
|
23
89
|
/**
|
|
24
90
|
* The albedo a `derived` size takes when the Horizons sheet gives none: 0.04, the albedo the sheet gives for Himalia, the largest of the irregular moons. The few other irregular moons with an albedo on their sheets have 0.03
|
|
25
91
|
* (Elara) to 0.081 (Phoebe), and Nereid 0.2; a darker moon is larger than the estimate and a brighter one smaller, so a derived radius is a guide to the size, not a measurement.
|
|
@@ -34,8 +100,9 @@ export const MOON_GROUPS = ["inner", "major", "regular", "themisto", "himalia",
|
|
|
34
100
|
export const ASSUMED_ALBEDO = 0.04;
|
|
35
101
|
const FRAMES = ["ecliptic", "equatorial", "laplace"];
|
|
36
102
|
const SIZE_FROM = ["measured", "sheet"];
|
|
103
|
+
const MAGNITUDE_FROM = ["sheet", "wikipedia"];
|
|
37
104
|
function moonOf(row) {
|
|
38
|
-
const [id, name, designation, number, host, code, year, by, reference, o, radius, sigma, from, albedo, magnitude, worstKm, worstDegrees, farDegrees, group, ja, confirmed] = row;
|
|
105
|
+
const [id, name, designation, number, host, code, year, by, reference, o, radius, sigma, from, albedo, magnitude, worstKm, worstDegrees, farDegrees, group, ja, confirmed, drawn, magnitudeSource] = row;
|
|
39
106
|
const orbit = o === null
|
|
40
107
|
? null
|
|
41
108
|
: {
|
|
@@ -73,6 +140,7 @@ function moonOf(row) {
|
|
|
73
140
|
confirmed: confirmed !== 0,
|
|
74
141
|
discovery: { year, by, reference },
|
|
75
142
|
orbit,
|
|
143
|
+
osculating: OSCULATING.get(id) ?? null,
|
|
76
144
|
retrograde: orbit === null ? null : orbit.i > 90,
|
|
77
145
|
group,
|
|
78
146
|
radiusKm,
|
|
@@ -80,9 +148,10 @@ function moonOf(row) {
|
|
|
80
148
|
radiusFrom,
|
|
81
149
|
albedo,
|
|
82
150
|
magnitude,
|
|
151
|
+
magnitudeFrom: magnitudeSource === null ? null : MAGNITUDE_FROM[magnitudeSource],
|
|
83
152
|
accuracy: worstKm === null || worstDegrees === null ? null : { worstKm, worstDegrees, farDegrees },
|
|
84
153
|
grade,
|
|
85
|
-
full:
|
|
154
|
+
full: drawn !== 0,
|
|
86
155
|
};
|
|
87
156
|
}
|
|
88
157
|
/**
|
|
@@ -194,6 +263,20 @@ function ratesOf(orbit) {
|
|
|
194
263
|
const dn = orbit.nodeYears ? (-Math.sign(ci) * 360) / (orbit.nodeYears * YEAR_DAYS) : 0;
|
|
195
264
|
return [360 / orbit.periodDays - dw - dn, dw, dn];
|
|
196
265
|
}
|
|
266
|
+
/** A place on an ellipse of semi-major axis `a` (km) and eccentricity `e`, inclination `i`, node and argument of periapsis `w` (degrees), at mean anomaly `meanAnomaly` (radians), in the frame of the pole (the J2000 ecliptic for `null`). */
|
|
267
|
+
function placed(a, e, i, nodeDeg, wDeg, meanAnomaly, pole) {
|
|
268
|
+
const w = wDeg * RAD;
|
|
269
|
+
const node = nodeDeg * RAD;
|
|
270
|
+
const E = kepler(meanAnomaly, e);
|
|
271
|
+
const x = a * (Math.cos(E) - e);
|
|
272
|
+
const y = a * Math.sqrt(1 - e * e) * Math.sin(E);
|
|
273
|
+
const [cw, sw, cn, sn, ci, si] = [Math.cos(w), Math.sin(w), Math.cos(node), Math.sin(node), Math.cos(i * RAD), Math.sin(i * RAD)];
|
|
274
|
+
const px = (cw * cn - sw * sn * ci) * x + (-sw * cn - cw * sn * ci) * y;
|
|
275
|
+
const py = (cw * sn + sw * cn * ci) * x + (-sw * sn + cw * cn * ci) * y;
|
|
276
|
+
const pz = sw * si * x + cw * si * y;
|
|
277
|
+
const [bx, by, bz] = basisOf(pole);
|
|
278
|
+
return [px * bx[0] + py * by[0] + pz * bz[0], px * bx[1] + py * by[1] + pz * bz[1], px * bx[2] + py * by[2] + pz * bz[2]];
|
|
279
|
+
}
|
|
197
280
|
/**
|
|
198
281
|
* Where a moon is at a moment, from its planet's centre, in kilometres, in the J2000 ecliptic frame (the axes of `moonVector`): its mean orbit, turned for the precession of its periapsis and node, solved by Kepler's
|
|
199
282
|
* equation. How close that is to the moon's real place near 2026 is the moon's `accuracy` and `grade`; decades away it drifts much further (`accuracy.farDegrees`). A moon the package draws in full is placed far better
|
|
@@ -218,17 +301,14 @@ export function catalogueMoonPosition(moon, when) {
|
|
|
218
301
|
const orbit = m.orbit;
|
|
219
302
|
if (orbit === null)
|
|
220
303
|
return undefined;
|
|
304
|
+
const jd = toTerrestrialTime(moment(when)) / DAY_MS + UNIX_JD;
|
|
305
|
+
const osc = m.osculating;
|
|
306
|
+
if (osc !== null && Math.abs(jd - osc.epochJd) <= MOON_OSCULATING_DAYS) {
|
|
307
|
+
// inside the window an irregular moon follows its osculating orbit: a plain two-body step from the day it was taken
|
|
308
|
+
const meanMotion = Math.sqrt(HOST_GM[m.host] / osc.a ** 3) * 86_400;
|
|
309
|
+
return placed(osc.a, osc.e, osc.i, osc.node, osc.w, osc.m * RAD + meanMotion * (jd - osc.epochJd), null);
|
|
310
|
+
}
|
|
221
311
|
const [n, dw, dn] = ratesOf(orbit);
|
|
222
|
-
const dt =
|
|
223
|
-
|
|
224
|
-
const node = (orbit.node + dn * dt) * RAD;
|
|
225
|
-
const E = kepler((orbit.m + n * dt) * RAD, orbit.e);
|
|
226
|
-
const x = orbit.a * (Math.cos(E) - orbit.e);
|
|
227
|
-
const y = orbit.a * Math.sqrt(1 - orbit.e * orbit.e) * Math.sin(E);
|
|
228
|
-
const [cw, sw, cn, sn, ci, si] = [Math.cos(w), Math.sin(w), Math.cos(node), Math.sin(node), Math.cos(orbit.i * RAD), Math.sin(orbit.i * RAD)];
|
|
229
|
-
const px = (cw * cn - sw * sn * ci) * x + (-sw * cn - cw * sn * ci) * y;
|
|
230
|
-
const py = (cw * sn + sw * cn * ci) * x + (-sw * sn + cw * cn * ci) * y;
|
|
231
|
-
const pz = sw * si * x + cw * si * y;
|
|
232
|
-
const [bx, by, bz] = basisOf(orbit.frame === "ecliptic" ? null : (orbit.pole ?? null));
|
|
233
|
-
return [px * bx[0] + py * by[0] + pz * bz[0], px * bx[1] + py * by[1] + pz * bz[1], px * bx[2] + py * by[2] + pz * bz[2]];
|
|
312
|
+
const dt = jd - orbit.epochJd;
|
|
313
|
+
return placed(orbit.a, orbit.e, orbit.i, orbit.node + dn * dt, orbit.w + dw * dt, (orbit.m + n * dt) * RAD, orbit.frame === "ecliptic" ? null : (orbit.pole ?? null));
|
|
234
314
|
}
|
package/dist/plan/element.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export interface PlanPick {
|
|
|
17
17
|
/**
|
|
18
18
|
* The `<wakusei-plan>` custom element: a small plan seen from above, in SVG, light enough for an inset of 200 to 280 pixels.
|
|
19
19
|
*
|
|
20
|
-
* Attributes: `system` (`sun`, the default, draws the solar system from above the ecliptic's north pole; a planet or dwarf planet with moons, such as `jupiter`, draws its moons from above its north pole), `mark` (the body the plan is about: its
|
|
20
|
+
* Attributes: `system` (`sun`, the default, draws the solar system from above the ecliptic's north pole; a planet or dwarf planet with moons, such as `jupiter`, draws its moons from above its north pole), `marks` (more ids to mark beside it, separated by commas or spaces: the favourites among the craft, each ringed and named; the solar-system plan only), `mark` (the body the plan is about: its
|
|
21
21
|
* id in any case, such as `mars`, `ceres`, `halley`, `io` or a craft such as `voyager1`; in the solar system a moon marks its planet. A craft's path, or the fitted table of a dwarf planet or minor body, is fetched the first time it is marked), `time` (an ISO date or milliseconds since 1970, and a bare number is always milliseconds, so `2026` is two seconds past the start of 1970 and not a year; the moment it is read when left out or `now`, and then it stands still:
|
|
22
22
|
* set `time` again to move it), `spacing` (`squeezed`, the default, puts each body at the logarithm of its distance so inner and outer both show; `true` is to scale), `names` (`off` hides every name but the marked body's), `lang` (`en` or `ja`;
|
|
23
23
|
* the page's `lang` when left out), `size` (pixels across, 240 by default; also `--wakusei-size`) and `theme` (`light` or `dark`; the page's colour scheme when left out). The colours are `--wakusei-plan-bg`, `-ink`, `-muted`, `-line`, `-sun`, `-dot` and `-mark`.
|
|
@@ -46,6 +46,12 @@ export declare class WakuseiPlan extends HTMLElement {
|
|
|
46
46
|
/** The moment shown: milliseconds since 1970, or `"now"` (the moment it draws). Setting it draws again. */
|
|
47
47
|
get time(): number | "now";
|
|
48
48
|
set time(value: number | "now");
|
|
49
|
+
/**
|
|
50
|
+
* More bodies marked beside `mark`, ringed and named like it: the favourites among the craft, say (the attribute `marks`, ids separated by commas or spaces). A craft's path is fetched the first time it is marked; an id that names nothing
|
|
51
|
+
* marks nothing. The solar-system plan only. Setting it draws again.
|
|
52
|
+
*/
|
|
53
|
+
get marks(): readonly string[];
|
|
54
|
+
set marks(value: readonly string[]);
|
|
49
55
|
connectedCallback(): void;
|
|
50
56
|
disconnectedCallback(): void;
|
|
51
57
|
attributeChangedCallback(name: string, old: string | null, value: string | null): void;
|
package/dist/plan/element.js
CHANGED
|
@@ -35,7 +35,7 @@ const off = (value) => value !== null && ["off", "0", "false", "no"].includes(va
|
|
|
35
35
|
/**
|
|
36
36
|
* The `<wakusei-plan>` custom element: a small plan seen from above, in SVG, light enough for an inset of 200 to 280 pixels.
|
|
37
37
|
*
|
|
38
|
-
* Attributes: `system` (`sun`, the default, draws the solar system from above the ecliptic's north pole; a planet or dwarf planet with moons, such as `jupiter`, draws its moons from above its north pole), `mark` (the body the plan is about: its
|
|
38
|
+
* Attributes: `system` (`sun`, the default, draws the solar system from above the ecliptic's north pole; a planet or dwarf planet with moons, such as `jupiter`, draws its moons from above its north pole), `marks` (more ids to mark beside it, separated by commas or spaces: the favourites among the craft, each ringed and named; the solar-system plan only), `mark` (the body the plan is about: its
|
|
39
39
|
* id in any case, such as `mars`, `ceres`, `halley`, `io` or a craft such as `voyager1`; in the solar system a moon marks its planet. A craft's path, or the fitted table of a dwarf planet or minor body, is fetched the first time it is marked), `time` (an ISO date or milliseconds since 1970, and a bare number is always milliseconds, so `2026` is two seconds past the start of 1970 and not a year; the moment it is read when left out or `now`, and then it stands still:
|
|
40
40
|
* set `time` again to move it), `spacing` (`squeezed`, the default, puts each body at the logarithm of its distance so inner and outer both show; `true` is to scale), `names` (`off` hides every name but the marked body's), `lang` (`en` or `ja`;
|
|
41
41
|
* the page's `lang` when left out), `size` (pixels across, 240 by default; also `--wakusei-size`) and `theme` (`light` or `dark`; the page's colour scheme when left out). The colours are `--wakusei-plan-bg`, `-ink`, `-muted`, `-line`, `-sun`, `-dot` and `-mark`.
|
|
@@ -54,7 +54,7 @@ const off = (value) => value !== null && ["off", "0", "false", "no"].includes(va
|
|
|
54
54
|
* ```
|
|
55
55
|
*/
|
|
56
56
|
export class WakuseiPlan extends HTMLElement {
|
|
57
|
-
static observedAttributes = ["system", "mark", "time", "spacing", "names", "lang", "size", "theme"];
|
|
57
|
+
static observedAttributes = ["system", "mark", "marks", "time", "spacing", "names", "lang", "size", "theme"];
|
|
58
58
|
#root;
|
|
59
59
|
#box;
|
|
60
60
|
#time = "now";
|
|
@@ -102,6 +102,16 @@ export class WakuseiPlan extends HTMLElement {
|
|
|
102
102
|
this.#time = value === "now" || !Number.isFinite(value) ? "now" : value;
|
|
103
103
|
this.#queue();
|
|
104
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* More bodies marked beside `mark`, ringed and named like it: the favourites among the craft, say (the attribute `marks`, ids separated by commas or spaces). A craft's path is fetched the first time it is marked; an id that names nothing
|
|
107
|
+
* marks nothing. The solar-system plan only. Setting it draws again.
|
|
108
|
+
*/
|
|
109
|
+
get marks() {
|
|
110
|
+
return this.#marks();
|
|
111
|
+
}
|
|
112
|
+
set marks(value) {
|
|
113
|
+
this.setAttribute("marks", (Array.isArray(value) ? value : []).join(","));
|
|
114
|
+
}
|
|
105
115
|
connectedCallback() {
|
|
106
116
|
if (this.hasAttribute("time"))
|
|
107
117
|
this.#time = READ_TIME(this.getAttribute("time"));
|
|
@@ -185,34 +195,41 @@ export class WakuseiPlan extends HTMLElement {
|
|
|
185
195
|
#mark() {
|
|
186
196
|
return this.getAttribute("mark")?.trim().toLowerCase() || undefined;
|
|
187
197
|
}
|
|
188
|
-
/** The
|
|
189
|
-
#
|
|
198
|
+
/** The ids in `marks`, in lower case, once each: the favourites, say. A list of ids separated by commas or spaces. */
|
|
199
|
+
#marks() {
|
|
200
|
+
return [...new Set((this.getAttribute("marks") ?? "").split(/[\s,]+/).map((id) => id.trim().toLowerCase()).filter((id) => id !== ""))];
|
|
201
|
+
}
|
|
202
|
+
/** The craft marked: the mark if it is one, and every craft in `marks`, once each. */
|
|
203
|
+
#craftsMarked() {
|
|
190
204
|
const mark = this.#mark();
|
|
191
|
-
|
|
205
|
+
const all = [...(mark === undefined ? [] : [mark]), ...this.#marks()];
|
|
206
|
+
return [...new Set(all)].filter((id) => SPACECRAFT_IDS.includes(id));
|
|
192
207
|
}
|
|
193
|
-
/** The
|
|
194
|
-
#extras(
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
208
|
+
/** The places of the craft marked, those whose paths have been fetched (each craft's the first time it is marked); the rest come as their paths do. */
|
|
209
|
+
#extras(ids, time) {
|
|
210
|
+
const out = [];
|
|
211
|
+
for (const id of ids) {
|
|
212
|
+
if (!this.#craftLoaded.has(id) || this.#craft === undefined) {
|
|
213
|
+
if (!this.#craftLoading.has(id)) {
|
|
214
|
+
this.#craftLoading.add(id);
|
|
215
|
+
void import("../spacecraft.js").then(async (module) => {
|
|
216
|
+
await module.loadSpacecraft(id);
|
|
217
|
+
this.#craft = module;
|
|
218
|
+
this.#craftLoaded.add(id);
|
|
219
|
+
this.#queue();
|
|
220
|
+
}, () => undefined);
|
|
221
|
+
}
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
try {
|
|
225
|
+
const km = this.#craft.spacecraftPosition(id, time);
|
|
226
|
+
out.push({ id, au: [km[0] / PLAN_AU_KM, km[1] / PLAN_AU_KM, km[2] / PLAN_AU_KM] });
|
|
227
|
+
}
|
|
228
|
+
catch {
|
|
229
|
+
// a craft with no place at this time is left out
|
|
206
230
|
}
|
|
207
|
-
return [];
|
|
208
|
-
}
|
|
209
|
-
try {
|
|
210
|
-
const km = this.#craft.spacecraftPosition(id, time);
|
|
211
|
-
return [{ id, au: [km[0] / PLAN_AU_KM, km[1] / PLAN_AU_KM, km[2] / PLAN_AU_KM] }];
|
|
212
|
-
}
|
|
213
|
-
catch {
|
|
214
|
-
return [];
|
|
215
231
|
}
|
|
232
|
+
return out;
|
|
216
233
|
}
|
|
217
234
|
/** A marked dwarf planet or minor body is drawn from its fitted table once that has been fetched; until then from the elements of one epoch. */
|
|
218
235
|
#tables(mark) {
|
|
@@ -235,9 +252,8 @@ export class WakuseiPlan extends HTMLElement {
|
|
|
235
252
|
const wanted = this.getAttribute("system") ?? "sun";
|
|
236
253
|
const system = PLAN_SYSTEMS.includes(wanted) ? wanted : "sun";
|
|
237
254
|
const spacing = this.getAttribute("spacing") === "true" ? "true" : "squeezed";
|
|
238
|
-
const craft = this.#craftMarked();
|
|
239
255
|
this.#tables(this.#mark());
|
|
240
|
-
const plan = planAt(time, { system, spacing, mark: this.#mark(), extras: system === "sun" ? this.#extras(
|
|
256
|
+
const plan = planAt(time, { system, spacing, mark: this.#mark(), marks: system === "sun" ? this.#marks() : [], extras: system === "sun" ? this.#extras(this.#craftsMarked(), time) : [] });
|
|
241
257
|
const held = this.#root.activeElement?.getAttribute("data-id");
|
|
242
258
|
this.#box.innerHTML = planSvg(plan, { size: this.#size, lang: this.#lang(), names: !off(this.getAttribute("names")), ...(measure === undefined ? {} : { measure }) });
|
|
243
259
|
if (held !== null && held !== undefined)
|
package/dist/plan/layout.d.ts
CHANGED
|
@@ -119,6 +119,8 @@ export interface Plan {
|
|
|
119
119
|
orbits: PlanOrbit[];
|
|
120
120
|
/** The id of the body marked, or `undefined`. */
|
|
121
121
|
marked: string | undefined;
|
|
122
|
+
/** Every id marked in the solar system: `marked` first, then `PlanOptions.marks` that name a body or an extra of the plan, in the order given, none twice. Empty when nothing is marked. */
|
|
123
|
+
marks: readonly string[];
|
|
122
124
|
}
|
|
123
125
|
/**
|
|
124
126
|
* A body the package has no position for, handed in by the page: a craft from `/spacecraft`, say.
|
|
@@ -158,6 +160,11 @@ export interface PlanOptions {
|
|
|
158
160
|
spacing?: PlanSpacing;
|
|
159
161
|
/** Bodies of your own, such as a craft's place. */
|
|
160
162
|
extras?: readonly PlanExtra[];
|
|
163
|
+
/**
|
|
164
|
+
* More bodies to mark beside `mark`, each ringed and named like it: the favourites among the craft handed in with `extras`, say. An id that is neither a body of the plan nor an extra marks nothing. In the solar system only (a moon system
|
|
165
|
+
* has one mark).
|
|
166
|
+
*/
|
|
167
|
+
marks?: readonly string[];
|
|
161
168
|
}
|
|
162
169
|
/**
|
|
163
170
|
* Where a distance goes on the plan, 0 at the middle and 1 at the edge. Squeezed is `ln(1 + d / inner) / ln(1 + extent / inner)`, which spreads the inner bodies a good deal and the outer ones a little; true is `d / extent`.
|
package/dist/plan/layout.js
CHANGED
|
@@ -201,11 +201,13 @@ function sunPlan(time, options, spacing) {
|
|
|
201
201
|
// the plan is a view from above, so a body's distance is its distance in the ecliptic plane: its height does not push the edge out
|
|
202
202
|
const farthest = Math.max(...raw.map((one) => Math.hypot(one.point[0], one.point[1])));
|
|
203
203
|
const extent = planSunExtent(farthest);
|
|
204
|
-
const
|
|
204
|
+
const present = new Set(raw.map((one) => one.id));
|
|
205
|
+
const marks = [...new Set([...(wanted === undefined ? [] : [wanted]), ...(options.marks ?? []).map((id) => id.trim().toLowerCase()).filter((id) => present.has(id) || id === "sun")])];
|
|
206
|
+
const dots = raw.map((one) => place(one.id, one.kind, one.point, extent, spacing, SUN_INNER, marks.includes(one.id)));
|
|
205
207
|
const orbits = ids
|
|
206
|
-
.map((id) => ({ id, marked: id
|
|
207
|
-
const centre = { id: "sun", kind: "star", x: 0, y: 0, distance: 0, marked:
|
|
208
|
-
return { system: "sun", time, spacing, unit: "au", extent, inner: SUN_INNER, centre, dots: dots.sort((a, b) => Number(a.marked) - Number(b.marked)), orbits: orbits.sort((a, b) => Number(a.marked) - Number(b.marked)), marked: wanted };
|
|
208
|
+
.map((id) => ({ id, marked: marks.includes(id), points: sunOrbit(id, time).map((p) => squeeze(p, extent, spacing, SUN_INNER)) }));
|
|
209
|
+
const centre = { id: "sun", kind: "star", x: 0, y: 0, distance: 0, marked: marks.includes("sun"), beyond: false };
|
|
210
|
+
return { system: "sun", time, spacing, unit: "au", extent, inner: SUN_INNER, centre, dots: dots.sort((a, b) => Number(a.marked) - Number(b.marked)), orbits: orbits.sort((a, b) => Number(a.marked) - Number(b.marked)), marked: wanted, marks };
|
|
209
211
|
}
|
|
210
212
|
function moonPlan(time, host, options, spacing) {
|
|
211
213
|
const moons = MOONS_OF[host];
|
|
@@ -214,7 +216,7 @@ function moonPlan(time, host, options, spacing) {
|
|
|
214
216
|
const dots = moons.map((id) => place(id, "moon", overPole(host, id, time), extent, spacing, MOON_INNER, id === wanted));
|
|
215
217
|
const orbits = moons.map((id) => ({ id, marked: id === wanted, points: moonOrbit(host, id, time).map((p) => squeeze(p, extent, spacing, MOON_INNER)) }));
|
|
216
218
|
const centre = { id: host, kind: BODIES[host].kind, x: 0, y: 0, distance: 0, marked: wanted === host, beyond: false };
|
|
217
|
-
return { system: host, time, spacing, unit: "radii", extent, inner: MOON_INNER, centre, dots: dots.sort((a, b) => Number(a.marked) - Number(b.marked)), orbits: orbits.sort((a, b) => Number(a.marked) - Number(b.marked)), marked: wanted };
|
|
219
|
+
return { system: host, time, spacing, unit: "radii", extent, inner: MOON_INNER, centre, dots: dots.sort((a, b) => Number(a.marked) - Number(b.marked)), orbits: orbits.sort((a, b) => Number(a.marked) - Number(b.marked)), marked: wanted, marks: wanted === undefined ? [] : [wanted] };
|
|
218
220
|
}
|
|
219
221
|
/**
|
|
220
222
|
* Kilometres in an astronomical unit, for turning a craft's place from `/spacecraft` (kilometres) into the astronomical units `PlanExtra` takes.
|
package/dist/plan/svg.js
CHANGED
|
@@ -70,7 +70,8 @@ const reachOf = (plan, lang) => {
|
|
|
70
70
|
*/
|
|
71
71
|
export function planText(plan, lang = "en") {
|
|
72
72
|
const words = WORDS[lang];
|
|
73
|
-
|
|
73
|
+
// every id marked, the plan's own mark first: "Voyager 1, Voyager 2 marked"
|
|
74
|
+
const marked = plan.marks.length === 0 ? undefined : plan.marks.map((id) => nameOf(id, lang)).join(lang === "ja" ? "、" : ", ");
|
|
74
75
|
return {
|
|
75
76
|
label: plan.system === "sun" ? words.sun(marked) : words.moons(nameOf(plan.system, lang), marked),
|
|
76
77
|
scale: words[plan.spacing === "true" ? "true" : "squeezed"](reachOf(plan, lang)),
|
package/dist/space/element.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { type BodyId } from "../facts.ts";
|
|
|
4
4
|
import { type HelpPlace } from "./arrows.ts";
|
|
5
5
|
import { type SpaceKind } from "./bodies.ts";
|
|
6
6
|
import { type Sight, type SightEdge } from "./sight.ts";
|
|
7
|
+
import { type KeepOut } from "./labels.ts";
|
|
7
8
|
import { type NameLabelOptions } from "../scene/name-label.ts";
|
|
8
9
|
import type { Credit, DataSource } from "../data-door.ts";
|
|
9
10
|
import { type DoorHost } from "../door/host.ts";
|
|
@@ -630,6 +631,29 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
630
631
|
/** The words shown beside each body, for a page in another language (`{ mars: "火星" }`). A body left out keeps its name in the element's `lang`. */
|
|
631
632
|
get bodyNames(): Partial<Record<string, string>>;
|
|
632
633
|
set bodyNames(value: Partial<Record<string, string>>);
|
|
634
|
+
/**
|
|
635
|
+
* The short words written beside a craft's dot when its full name is long (`{ juice: { en: "JUICE", ja: "ジュース" }, webb: "Webb" }`): a text for every language, or an object with the `en` and `ja` words. A craft left out is written in full. The craft's
|
|
636
|
+
* name for a card, a press, an event and a screen reader stays the full one; only the written label is short. The package ships none: a page hands the table it wants (MODULES-1535).
|
|
637
|
+
*/
|
|
638
|
+
get labelShort(): Readonly<Record<string, string | {
|
|
639
|
+
en?: string;
|
|
640
|
+
ja?: string;
|
|
641
|
+
}>>;
|
|
642
|
+
set labelShort(value: Readonly<Record<string, string | {
|
|
643
|
+
en?: string;
|
|
644
|
+
ja?: string;
|
|
645
|
+
}>>);
|
|
646
|
+
/**
|
|
647
|
+
* The rectangles of the view the names are kept out of, in the element's own box in CSS pixels (`[{ x, y, w, h }]`): the page's bar, its notices, its strip. A name that would lie under one goes round its dot or is left out; the dot stays.
|
|
648
|
+
* Craft names move round their dot first; every name respects them. An empty list (the default) keeps nothing out.
|
|
649
|
+
*/
|
|
650
|
+
get keepOut(): readonly KeepOut[];
|
|
651
|
+
set keepOut(value: readonly KeepOut[]);
|
|
652
|
+
/**
|
|
653
|
+
* The ids of the craft the page favourites: their names come before the other craft's when two touch (the craft chosen comes first of all). A body's name always comes before any craft's.
|
|
654
|
+
*/
|
|
655
|
+
get favourites(): readonly string[];
|
|
656
|
+
set favourites(value: readonly string[]);
|
|
633
657
|
/** What a screen reader hears after a body's name: "choose to look at it" by default, or the page's own words. */
|
|
634
658
|
get bodyHint(): string;
|
|
635
659
|
set bodyHint(value: string);
|