@johnmorrisdotca/wakusei-planets 0.63.0 → 0.64.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 +27 -0
- package/README.md +4 -3
- package/dist/asteroids.d.ts +15 -1
- package/dist/asteroids.js +28 -0
- package/dist/door/made.d.ts +4 -0
- package/dist/door/made.js +10 -0
- package/dist/door/own.d.ts +1 -4
- package/dist/door/own.js +1 -9
- package/dist/element.js +19 -22
- package/dist/scene/tumble.d.ts +13 -0
- package/dist/scene/tumble.js +34 -0
- package/dist/sky.d.ts +561 -0
- package/dist/sky.js +522 -0
- package/dist/space/asteroid-ids.d.ts +8 -0
- package/dist/space/asteroid-ids.js +19 -0
- package/dist/space/element.d.ts +63 -6
- package/dist/space/element.js +208 -26
- package/dist/space/scene.d.ts +32 -0
- package/dist/space/scene.js +36 -2
- package/dist/surface/element.d.ts +1 -1
- package/dist/surface/element.js +4 -2
- package/package.json +10 -1
package/dist/sky.d.ts
ADDED
|
@@ -0,0 +1,561 @@
|
|
|
1
|
+
import type { SkyBodyId } from "./sky-bodies.ts";
|
|
2
|
+
import type { Observer } from "./sky/types.ts";
|
|
3
|
+
import { type When } from "./when.ts";
|
|
4
|
+
/**
|
|
5
|
+
* The four moments of a year when the Sun's apparent ecliptic longitude is 0, 90, 180 and 270 degrees, as `Date`s (UTC). The seasons of the northern hemisphere start at the March equinox (spring) and the December solstice (winter).
|
|
6
|
+
*
|
|
7
|
+
* @experimental
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { seasons, type SkySeasons } from "@johnmorrisdotca/wakusei-planets/sky";
|
|
11
|
+
*
|
|
12
|
+
* const s: SkySeasons = seasons(2026);
|
|
13
|
+
* console.log(s.marchEquinox instanceof Date, s.marchEquinox < s.juneSolstice);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export interface SkySeasons {
|
|
17
|
+
/** The Sun crosses the celestial equator going north: ecliptic longitude 0. */
|
|
18
|
+
marchEquinox: Date;
|
|
19
|
+
/** The Sun is farthest north: ecliptic longitude 90. */
|
|
20
|
+
juneSolstice: Date;
|
|
21
|
+
/** The Sun crosses the celestial equator going south: ecliptic longitude 180. */
|
|
22
|
+
septemberEquinox: Date;
|
|
23
|
+
/** The Sun is farthest south: ecliptic longitude 270. */
|
|
24
|
+
decemberSolstice: Date;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The equinoxes and solstices of a calendar year (UTC), found by astronomy-engine. The year is an integer; anything else throws a `RangeError` naming it. The times are good to about a minute against the USNO table
|
|
28
|
+
* for 1900 to 2050 (the accuracy guide has the measured figures); the moments are UT, as a `Date` counts them.
|
|
29
|
+
*
|
|
30
|
+
* @param year - A calendar year, an integer (UTC).
|
|
31
|
+
* @returns The four moments, in order.
|
|
32
|
+
* @experimental
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* import { seasons } from "@johnmorrisdotca/wakusei-planets/sky";
|
|
36
|
+
*
|
|
37
|
+
* const { marchEquinox, decemberSolstice } = seasons(2026);
|
|
38
|
+
* console.log(marchEquinox.toISOString(), decemberSolstice.toISOString());
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare function seasons(year: number): SkySeasons;
|
|
42
|
+
/**
|
|
43
|
+
* The four phases of the Moon's cycle: the Moon at ecliptic longitude 0, 90, 180 and 270 degrees from the Sun, seen from Earth.
|
|
44
|
+
*
|
|
45
|
+
* @experimental
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* import { type MoonPhaseName } from "@johnmorrisdotca/wakusei-planets/sky";
|
|
49
|
+
*
|
|
50
|
+
* const phase: MoonPhaseName = "firstQuarter";
|
|
51
|
+
* console.log(phase);
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export type MoonPhaseName = "new" | "firstQuarter" | "full" | "lastQuarter";
|
|
55
|
+
/**
|
|
56
|
+
* One phase of the Moon at the moment it happens.
|
|
57
|
+
*
|
|
58
|
+
* @experimental
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* import { moonPhases, type MoonPhaseEvent } from "@johnmorrisdotca/wakusei-planets/sky";
|
|
62
|
+
*
|
|
63
|
+
* const first: MoonPhaseEvent = moonPhases(Date.UTC(2026, 10, 1), Date.UTC(2026, 10, 30))[0]!;
|
|
64
|
+
* console.log(first.phase, first.time.toISOString());
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export interface MoonPhaseEvent {
|
|
68
|
+
phase: MoonPhaseName;
|
|
69
|
+
time: Date;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Every new, first quarter, full and last quarter Moon from `from` (included) to `to` (not included), in order, as `Date`s. `from` and `to` are a `Date` or milliseconds; an end before the start throws a `RangeError`.
|
|
73
|
+
*
|
|
74
|
+
* @param from - The start of the interval, included.
|
|
75
|
+
* @param to - The end of the interval, not included.
|
|
76
|
+
* @returns The phases in time order; empty when the interval holds none.
|
|
77
|
+
* @experimental
|
|
78
|
+
* @example
|
|
79
|
+
* ```ts
|
|
80
|
+
* import { moonPhases } from "@johnmorrisdotca/wakusei-planets/sky";
|
|
81
|
+
*
|
|
82
|
+
* const november = moonPhases(Date.UTC(2026, 10, 1), Date.UTC(2026, 11, 1));
|
|
83
|
+
* console.log(november.map((event) => `${event.phase} ${event.time.toISOString().slice(0, 10)}`).join(", "));
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export declare function moonPhases(from: When, to: When): MoonPhaseEvent[];
|
|
87
|
+
/**
|
|
88
|
+
* The next time the Moon is in `phase` at or after `from`, as a `Date`, or `null` when it does not happen within `within.days` (35 days when not given, which always holds one of each phase).
|
|
89
|
+
*
|
|
90
|
+
* @param from - Where to start looking, included.
|
|
91
|
+
* @param options - `phase` is required; `within.days` bounds the search (a positive number).
|
|
92
|
+
* @returns The moment, or `null` when none falls inside the window.
|
|
93
|
+
* @experimental
|
|
94
|
+
* @example
|
|
95
|
+
* ```ts
|
|
96
|
+
* import { nextMoonPhase } from "@johnmorrisdotca/wakusei-planets/sky";
|
|
97
|
+
*
|
|
98
|
+
* const full = nextMoonPhase(Date.UTC(2026, 10, 7), { phase: "full" });
|
|
99
|
+
* console.log(full?.toISOString());
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
export declare function nextMoonPhase(from: When, options: {
|
|
103
|
+
phase: MoonPhaseName;
|
|
104
|
+
within?: {
|
|
105
|
+
days: number;
|
|
106
|
+
};
|
|
107
|
+
}): Date | null;
|
|
108
|
+
/**
|
|
109
|
+
* One eclipse of the Sun or the Moon: which, what kind, the moment of greatest eclipse (UT, as a `Date`) and, for a solar eclipse that has one, the fraction of the Sun's disc covered at that moment (`obscuration`, 0 to 1).
|
|
110
|
+
* A lunar eclipse is `"penumbral"`, `"partial"` or `"total"` and has its umbral `magnitude`; a solar one `"partial"`, `"annular"` or `"total"` (astronomy-engine calls a hybrid eclipse by the kind at its greatest moment).
|
|
111
|
+
*
|
|
112
|
+
* @experimental
|
|
113
|
+
* @example
|
|
114
|
+
* ```ts
|
|
115
|
+
* import { findEclipses, type SkyEclipse } from "@johnmorrisdotca/wakusei-planets/sky";
|
|
116
|
+
*
|
|
117
|
+
* const first: SkyEclipse = findEclipses(Date.UTC(2026, 0, 1), Date.UTC(2027, 0, 1))[0]!;
|
|
118
|
+
* console.log(first.type, first.kind, first.peak.toISOString());
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
export interface SkyEclipse {
|
|
122
|
+
type: "solar" | "lunar";
|
|
123
|
+
kind: "penumbral" | "partial" | "annular" | "total";
|
|
124
|
+
peak: Date;
|
|
125
|
+
obscuration?: number;
|
|
126
|
+
/**
|
|
127
|
+
* Lunar eclipses only: the umbral magnitude at greatest eclipse, as NASA's tables give it: the fraction of the Moon's diameter inside the Earth's umbra (0 when the Moon's edge only touches the umbra, 1 when the Moon's disc just fits in it, more than 1 for a deep total eclipse),
|
|
128
|
+
* and negative for a penumbral eclipse, where the umbra misses the Moon. The umbra is the engine's: the Earth's radius with 88 km of atmosphere.
|
|
129
|
+
*/
|
|
130
|
+
magnitude?: number;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Every solar and lunar eclipse whose greatest moment falls from `from` (included) to `to` (not included), in time order. A solar eclipse is listed if it is seen anywhere on Earth. An end before the start throws a `RangeError`.
|
|
134
|
+
*
|
|
135
|
+
* @param from - The start of the interval, included.
|
|
136
|
+
* @param to - The end of the interval, not included.
|
|
137
|
+
* @returns The eclipses in time order; empty when the interval holds none.
|
|
138
|
+
* @experimental
|
|
139
|
+
* @example
|
|
140
|
+
* ```ts
|
|
141
|
+
* import { findEclipses } from "@johnmorrisdotca/wakusei-planets/sky";
|
|
142
|
+
*
|
|
143
|
+
* for (const eclipse of findEclipses(Date.UTC(2026, 0, 1), Date.UTC(2027, 0, 1))) console.log(eclipse.type, eclipse.kind, eclipse.peak.toISOString().slice(0, 10));
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
export declare function findEclipses(from: When, to: When): SkyEclipse[];
|
|
147
|
+
/**
|
|
148
|
+
* The options of the rise, set and transit searches: where to stand and how far to look.
|
|
149
|
+
*
|
|
150
|
+
* @experimental
|
|
151
|
+
* @example
|
|
152
|
+
* ```ts
|
|
153
|
+
* import { nextRise, type SkyHorizonOptions } from "@johnmorrisdotca/wakusei-planets/sky";
|
|
154
|
+
*
|
|
155
|
+
* const options: SkyHorizonOptions = { observer: { latitude: 49.3, longitude: -123.1, heightM: 0 }, within: { days: 1 } };
|
|
156
|
+
* console.log(nextRise("venus", Date.UTC(2026, 10, 8), options) instanceof Date);
|
|
157
|
+
* ```
|
|
158
|
+
*/
|
|
159
|
+
export interface SkyHorizonOptions {
|
|
160
|
+
/** Degrees north and east, metres above the ellipsoid (0 when not given). */
|
|
161
|
+
observer: Observer;
|
|
162
|
+
/** How far to look from `from`: `{ days }`, 2 when not given. The start is included and the end is not. */
|
|
163
|
+
within?: {
|
|
164
|
+
days: number;
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* The next time a body rises for an observer, at or after `from`, as a `Date`, or `null` when it does not rise within `within.days` (2 when not given; at a pole, or for a body that stays up or down, there is none).
|
|
169
|
+
* The Sun and the Moon rise when their upper limb touches a horizon lowered by 34 arc-minutes of refraction, the planets when their centre does; the height of the observer lowers it further.
|
|
170
|
+
*
|
|
171
|
+
* @param body - A body of this package: the Sun, the Moon or a planet (`"mars"`).
|
|
172
|
+
* @param from - Where to start looking, included (an event within a quarter of a second before it counts as at it: the search settles to about 0.1 s).
|
|
173
|
+
* @param options - The observer, and how far to look.
|
|
174
|
+
* @returns The moment, or `null` when there is none inside the window.
|
|
175
|
+
* @experimental
|
|
176
|
+
* @example
|
|
177
|
+
* ```ts
|
|
178
|
+
* import { nextRise } from "@johnmorrisdotca/wakusei-planets/sky";
|
|
179
|
+
*
|
|
180
|
+
* const tokyo = { latitude: 35.6895, longitude: 139.6917, heightM: 0 };
|
|
181
|
+
* console.log(nextRise("mars", Date.UTC(2026, 10, 8), { observer: tokyo })?.toISOString());
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
export declare function nextRise(body: SkyBodyId, from: When, options: SkyHorizonOptions): Date | null;
|
|
185
|
+
/**
|
|
186
|
+
* The next time a body sets for an observer, at or after `from`, as a `Date`, or `null` when it does not set within `within.days` (2 when not given). The horizon is the same as for `nextRise`.
|
|
187
|
+
*
|
|
188
|
+
* @param body - A body of this package: the Sun, the Moon or a planet.
|
|
189
|
+
* @param from - Where to start looking, included.
|
|
190
|
+
* @param options - The observer, and how far to look.
|
|
191
|
+
* @returns The moment, or `null` when there is none inside the window.
|
|
192
|
+
* @experimental
|
|
193
|
+
* @example
|
|
194
|
+
* ```ts
|
|
195
|
+
* import { nextSet } from "@johnmorrisdotca/wakusei-planets/sky";
|
|
196
|
+
*
|
|
197
|
+
* const tokyo = { latitude: 35.6895, longitude: 139.6917, heightM: 0 };
|
|
198
|
+
* console.log(nextSet("venus", Date.UTC(2026, 10, 8), { observer: tokyo })?.toISOString());
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
201
|
+
export declare function nextSet(body: SkyBodyId, from: When, options: SkyHorizonOptions): Date | null;
|
|
202
|
+
/**
|
|
203
|
+
* The next time a body crosses the observer's meridian (its highest point in the sky, hour angle 0), at or after `from`, as a `Date`, or `null` when it does not within `within.days` (2 when not given).
|
|
204
|
+
*
|
|
205
|
+
* @param body - A body of this package: the Sun, the Moon or a planet.
|
|
206
|
+
* @param from - Where to start looking, included.
|
|
207
|
+
* @param options - The observer, and how far to look.
|
|
208
|
+
* @returns The moment, or `null` when there is none inside the window.
|
|
209
|
+
* @experimental
|
|
210
|
+
* @example
|
|
211
|
+
* ```ts
|
|
212
|
+
* import { nextTransit } from "@johnmorrisdotca/wakusei-planets/sky";
|
|
213
|
+
*
|
|
214
|
+
* const tokyo = { latitude: 35.6895, longitude: 139.6917, heightM: 0 };
|
|
215
|
+
* console.log(nextTransit("jupiter", Date.UTC(2026, 10, 8), { observer: tokyo })?.toISOString());
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
218
|
+
export declare function nextTransit(body: SkyBodyId, from: When, options: SkyHorizonOptions): Date | null;
|
|
219
|
+
/**
|
|
220
|
+
* The Moon's libration: how far the Moon's disc is turned from its mean Earth-facing position, as seen from the centre of the Earth, with the Moon's distance and size. `longitude` is the libration in longitude (positive when the Moon's east limb is turned toward Earth) and `latitude` the libration in latitude (positive
|
|
221
|
+
* when its north pole is tipped toward Earth), both in degrees, as astronomy-engine gives them (optical libration; the physical libration of up to 0.04 degrees is not added).
|
|
222
|
+
*
|
|
223
|
+
* @experimental
|
|
224
|
+
* @example
|
|
225
|
+
* ```ts
|
|
226
|
+
* import { moonLibration, type MoonLibration } from "@johnmorrisdotca/wakusei-planets/sky";
|
|
227
|
+
*
|
|
228
|
+
* const l: MoonLibration = moonLibration(Date.UTC(2026, 10, 7, 12));
|
|
229
|
+
* console.log(Math.abs(l.longitude) < 8, Math.abs(l.latitude) < 7, l.distanceKm > 356000);
|
|
230
|
+
* ```
|
|
231
|
+
*/
|
|
232
|
+
export interface MoonLibration {
|
|
233
|
+
longitude: number;
|
|
234
|
+
latitude: number;
|
|
235
|
+
distanceKm: number;
|
|
236
|
+
angularDiameter: number;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* The Moon's libration at a moment, as seen from the centre of the Earth.
|
|
240
|
+
*
|
|
241
|
+
* @param when - A `Date` or milliseconds since 1970 (UTC).
|
|
242
|
+
* @returns The libration in longitude and latitude, the Moon's distance in kilometres and its angular diameter in degrees.
|
|
243
|
+
* @experimental
|
|
244
|
+
* @example
|
|
245
|
+
* ```ts
|
|
246
|
+
* import { moonLibration } from "@johnmorrisdotca/wakusei-planets/sky";
|
|
247
|
+
*
|
|
248
|
+
* const { longitude, latitude } = moonLibration(Date.UTC(2026, 10, 7, 12));
|
|
249
|
+
* console.log(longitude.toFixed(1), latitude.toFixed(1));
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
252
|
+
export declare function moonLibration(when: When): MoonLibration;
|
|
253
|
+
/**
|
|
254
|
+
* One closest or farthest point of the Moon's orbit: the kind, the moment and the distance between the centres of the Earth and the Moon.
|
|
255
|
+
*
|
|
256
|
+
* @experimental
|
|
257
|
+
* @example
|
|
258
|
+
* ```ts
|
|
259
|
+
* import { lunarApsides, type LunarApsis } from "@johnmorrisdotca/wakusei-planets/sky";
|
|
260
|
+
*
|
|
261
|
+
* const first: LunarApsis = lunarApsides(Date.UTC(2026, 10, 1), Date.UTC(2026, 11, 1))[0]!;
|
|
262
|
+
* console.log(first.kind, Math.round(first.distanceKm));
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
265
|
+
export interface LunarApsis {
|
|
266
|
+
kind: "perigee" | "apogee";
|
|
267
|
+
time: Date;
|
|
268
|
+
distanceKm: number;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Every perigee and apogee of the Moon from `from` (included; the search settles to about 0.1 s, so one within a quarter of a second before it counts) to `to` (not included), in time order. An end before the start throws a `RangeError`.
|
|
272
|
+
*
|
|
273
|
+
* @param from - The start of the interval, included.
|
|
274
|
+
* @param to - The end of the interval, not included.
|
|
275
|
+
* @returns The apsides in time order; empty when the interval holds none.
|
|
276
|
+
* @experimental
|
|
277
|
+
* @example
|
|
278
|
+
* ```ts
|
|
279
|
+
* import { lunarApsides } from "@johnmorrisdotca/wakusei-planets/sky";
|
|
280
|
+
*
|
|
281
|
+
* for (const apsis of lunarApsides(Date.UTC(2026, 10, 1), Date.UTC(2026, 11, 1))) console.log(apsis.kind, apsis.time.toISOString(), Math.round(apsis.distanceKm));
|
|
282
|
+
* ```
|
|
283
|
+
*/
|
|
284
|
+
export declare function lunarApsides(from: When, to: When): LunarApsis[];
|
|
285
|
+
/**
|
|
286
|
+
* One crossing of the ecliptic by the Moon's centre: going north (`"ascending"`) or south (`"descending"`).
|
|
287
|
+
*
|
|
288
|
+
* @experimental
|
|
289
|
+
* @example
|
|
290
|
+
* ```ts
|
|
291
|
+
* import { lunarNodes, type LunarNode } from "@johnmorrisdotca/wakusei-planets/sky";
|
|
292
|
+
*
|
|
293
|
+
* const first: LunarNode = lunarNodes(Date.UTC(2026, 10, 1), Date.UTC(2026, 11, 1))[0]!;
|
|
294
|
+
* console.log(first.kind, first.time.toISOString());
|
|
295
|
+
* ```
|
|
296
|
+
*/
|
|
297
|
+
export interface LunarNode {
|
|
298
|
+
kind: "ascending" | "descending";
|
|
299
|
+
time: Date;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Every time the Moon's centre crosses the ecliptic plane from `from` (included; the search settles to about 0.1 s, so one within a quarter of a second before it counts) to `to` (not included), in time order. An end before the start throws a `RangeError`.
|
|
303
|
+
*
|
|
304
|
+
* @param from - The start of the interval, included.
|
|
305
|
+
* @param to - The end of the interval, not included.
|
|
306
|
+
* @returns The crossings in time order; empty when the interval holds none.
|
|
307
|
+
* @experimental
|
|
308
|
+
* @example
|
|
309
|
+
* ```ts
|
|
310
|
+
* import { lunarNodes } from "@johnmorrisdotca/wakusei-planets/sky";
|
|
311
|
+
*
|
|
312
|
+
* for (const node of lunarNodes(Date.UTC(2026, 10, 1), Date.UTC(2026, 11, 1))) console.log(node.kind, node.time.toISOString());
|
|
313
|
+
* ```
|
|
314
|
+
*/
|
|
315
|
+
export declare function lunarNodes(from: When, to: When): LunarNode[];
|
|
316
|
+
/**
|
|
317
|
+
* The greatest elongation of Mercury or Venus: the moment, the angle between the planet and the Sun as seen from Earth in degrees, and which side of the Sun it is on (`"east"`: an evening star, `"west"`: a morning star).
|
|
318
|
+
*
|
|
319
|
+
* @experimental
|
|
320
|
+
* @example
|
|
321
|
+
* ```ts
|
|
322
|
+
* import { nextGreatestElongation, type GreatestElongation } from "@johnmorrisdotca/wakusei-planets/sky";
|
|
323
|
+
*
|
|
324
|
+
* const e: GreatestElongation = nextGreatestElongation("venus", Date.UTC(2026, 0, 1));
|
|
325
|
+
* console.log(e.side, e.elongation.toFixed(0));
|
|
326
|
+
* ```
|
|
327
|
+
*/
|
|
328
|
+
export interface GreatestElongation {
|
|
329
|
+
time: Date;
|
|
330
|
+
elongation: number;
|
|
331
|
+
side: "east" | "west";
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* The next greatest elongation of Mercury or Venus after `from`. Any other body throws a `RangeError` (a body outside Earth's orbit has no greatest elongation).
|
|
335
|
+
*
|
|
336
|
+
* @param body - `"mercury"` or `"venus"`.
|
|
337
|
+
* @param from - Where to start looking.
|
|
338
|
+
* @returns The moment, the elongation in degrees and the side of the Sun.
|
|
339
|
+
* @experimental
|
|
340
|
+
* @example
|
|
341
|
+
* ```ts
|
|
342
|
+
* import { nextGreatestElongation } from "@johnmorrisdotca/wakusei-planets/sky";
|
|
343
|
+
*
|
|
344
|
+
* const mercury = nextGreatestElongation("mercury", Date.UTC(2026, 0, 1));
|
|
345
|
+
* console.log(mercury.time.toISOString(), mercury.side);
|
|
346
|
+
* ```
|
|
347
|
+
*/
|
|
348
|
+
export declare function nextGreatestElongation(body: "mercury" | "venus", from: When): GreatestElongation;
|
|
349
|
+
/**
|
|
350
|
+
* The day's rise, transit and set of a body for an observer, over one calendar day of a time zone. `horizon` says what a missing rise or set means: `"crosses"` when the body rises or sets that day, `"above"` when it stays above the horizon all day and `"below"` when it stays below.
|
|
351
|
+
*
|
|
352
|
+
* @experimental
|
|
353
|
+
* @example
|
|
354
|
+
* ```ts
|
|
355
|
+
* import { riseSetTimes, type SkyRiseSet } from "@johnmorrisdotca/wakusei-planets/sky";
|
|
356
|
+
*
|
|
357
|
+
* const day: SkyRiseSet = riseSetTimes("sun", Date.UTC(2026, 5, 21), { observer: { latitude: 89, longitude: 0 }, timeZone: "UTC" });
|
|
358
|
+
* console.log(day.horizon, day.rise, day.set);
|
|
359
|
+
* ```
|
|
360
|
+
*/
|
|
361
|
+
export interface SkyRiseSet {
|
|
362
|
+
/** The first rise inside the day, or `null` when there is none. */
|
|
363
|
+
rise: Date | null;
|
|
364
|
+
/** The first meridian crossing inside the day, or `null` when there is none. */
|
|
365
|
+
transit: Date | null;
|
|
366
|
+
/** The first set inside the day, or `null` when there is none. */
|
|
367
|
+
set: Date | null;
|
|
368
|
+
/** `"crosses"` when the body rises or sets inside the day; otherwise `"above"` or `"below"`, by the body's height at the middle of the day. */
|
|
369
|
+
horizon: "crosses" | "above" | "below";
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* The options of `riseSetTimes`: where to stand and which time zone's calendar day to take.
|
|
373
|
+
*
|
|
374
|
+
* @experimental
|
|
375
|
+
* @example
|
|
376
|
+
* ```ts
|
|
377
|
+
* import { riseSetTimes, type SkyRiseSetOptions } from "@johnmorrisdotca/wakusei-planets/sky";
|
|
378
|
+
*
|
|
379
|
+
* const options: SkyRiseSetOptions = { observer: { latitude: 35.6895, longitude: 139.6917 }, timeZone: "Asia/Tokyo" };
|
|
380
|
+
* console.log(riseSetTimes("moon", Date.UTC(2026, 10, 8), options).horizon);
|
|
381
|
+
* ```
|
|
382
|
+
*/
|
|
383
|
+
export interface SkyRiseSetOptions {
|
|
384
|
+
/** Degrees north and east, metres above the ellipsoid (0 when not given). */
|
|
385
|
+
observer: Observer;
|
|
386
|
+
/** An IANA time zone name (`"Asia/Tokyo"`, `"America/New_York"`, `"UTC"`). Required: a calendar day has no meaning without one. */
|
|
387
|
+
timeZone: string;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* The rise, meridian crossing and set of a body over one calendar day of a time zone, for an observer. `date` is any moment of the day wanted (a `Date` or milliseconds); the day is the one in `timeZone` that holds it, from local midnight to the next, so a day
|
|
391
|
+
* when the clocks change is 23 or 25 hours long. `timeZone` is required: a missing, empty or unknown name throws a `RangeError` naming it. The horizon is `nextRise`'s. An event is `null` when it does not happen inside the day (the Moon has no rise on one day in about 29), and
|
|
392
|
+
* `horizon` tells a body that is up all day (`"above"`, the Sun at a pole in midsummer) or down all day (`"below"`) from one that crosses the horizon.
|
|
393
|
+
*
|
|
394
|
+
* @param body - A body of this package: the Sun, the Moon or a planet.
|
|
395
|
+
* @param date - Any moment inside the day wanted.
|
|
396
|
+
* @param options - The observer and the IANA time zone.
|
|
397
|
+
* @returns The three events as `Date`s or `null`, and the horizon state.
|
|
398
|
+
* @experimental
|
|
399
|
+
* @example
|
|
400
|
+
* ```ts
|
|
401
|
+
* import { riseSetTimes } from "@johnmorrisdotca/wakusei-planets/sky";
|
|
402
|
+
*
|
|
403
|
+
* // Sunrise and sunset in New York on 1 November 2026, the day the clocks go back (a 25-hour day).
|
|
404
|
+
* const day = riseSetTimes("sun", Date.UTC(2026, 10, 1, 12), { observer: { latitude: 40.7128, longitude: -74.006 }, timeZone: "America/New_York" });
|
|
405
|
+
* console.log(day.rise?.toISOString(), day.set?.toISOString(), day.horizon);
|
|
406
|
+
* ```
|
|
407
|
+
*/
|
|
408
|
+
export declare function riseSetTimes(body: SkyBodyId, date: When, options: SkyRiseSetOptions): SkyRiseSet;
|
|
409
|
+
/**
|
|
410
|
+
* Which alignment of a body with the Sun, by ecliptic longitude as seen from the Earth: `"conjunction"` (same longitude), `"opposition"` (180 degrees apart) or `"quadrature"` (90 degrees, east or west). Not the closest approach of two bodies in the sky, which `/nearest` finds.
|
|
411
|
+
*
|
|
412
|
+
* @experimental
|
|
413
|
+
* @example
|
|
414
|
+
* ```ts
|
|
415
|
+
* import { type AlignmentKind } from "@johnmorrisdotca/wakusei-planets/sky";
|
|
416
|
+
*
|
|
417
|
+
* const kind: AlignmentKind = "opposition";
|
|
418
|
+
* console.log(kind);
|
|
419
|
+
* ```
|
|
420
|
+
*/
|
|
421
|
+
export type AlignmentKind = "conjunction" | "opposition" | "quadrature";
|
|
422
|
+
/**
|
|
423
|
+
* One alignment of a body with the Sun by ecliptic longitude.
|
|
424
|
+
*
|
|
425
|
+
* @experimental
|
|
426
|
+
* @example
|
|
427
|
+
* ```ts
|
|
428
|
+
* import { nextAlignment, type SkyAlignment } from "@johnmorrisdotca/wakusei-planets/sky";
|
|
429
|
+
*
|
|
430
|
+
* const a: SkyAlignment | null = nextAlignment("mars", Date.UTC(2026, 0, 1), { kind: "opposition" });
|
|
431
|
+
* console.log(a?.time.toISOString(), a?.side, a?.inferior);
|
|
432
|
+
* ```
|
|
433
|
+
*/
|
|
434
|
+
export interface SkyAlignment {
|
|
435
|
+
time: Date;
|
|
436
|
+
kind: AlignmentKind;
|
|
437
|
+
/** For a quadrature: `"east"` when the body is 90 degrees east of the Sun (an evening sight), `"west"` when 90 degrees west; `null` for the others. */
|
|
438
|
+
side: "east" | "west" | null;
|
|
439
|
+
/** For a conjunction of Mercury or Venus: `true` when the planet passes between the Earth and the Sun (inferior), `false` when it passes behind the Sun (superior); `null` otherwise. */
|
|
440
|
+
inferior: boolean | null;
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* The next time a body is in conjunction with the Sun, opposite it or at quadrature, by ecliptic longitude as seen from the Earth (the longitudes of the body and the Sun differ by 0, 180 or 90 or 270 degrees, the apparent ones, as the Astronomical Almanac and Horizons give them), at or after `from` (an event within a quarter of a second before it counts as at it), or `null` when none falls inside `within.days`
|
|
444
|
+
* (850 days when not given, enough for the slowest planet's cycle). It is the longitude alignment, which is why it is named so: it is not the closest approach of two bodies in the sky (`/nearest`). A planet at opposition is on the meridian at midnight, and its time is not quite
|
|
445
|
+
* that of its closest approach to the Earth or its brightest moment.
|
|
446
|
+
* Mercury and Venus have conjunctions only (inferior and superior, told apart by `inferior`); asking either for an opposition or a quadrature, or asking for the Sun, throws a `RangeError`, since they never happen. For the Moon, a conjunction is the new Moon, an opposition the full Moon and a quadrature a first or last quarter.
|
|
447
|
+
*
|
|
448
|
+
* @param body - A body of this package except the Sun.
|
|
449
|
+
* @param from - Where to start looking, included.
|
|
450
|
+
* @param options - `kind` is required; `within.days` bounds the search (a positive number).
|
|
451
|
+
* @returns The moment with the kind, or `null` when none falls inside the window.
|
|
452
|
+
* @experimental
|
|
453
|
+
* @example
|
|
454
|
+
* ```ts
|
|
455
|
+
* import { nextAlignment } from "@johnmorrisdotca/wakusei-planets/sky";
|
|
456
|
+
*
|
|
457
|
+
* const opposition = nextAlignment("jupiter", Date.UTC(2026, 0, 1), { kind: "opposition" });
|
|
458
|
+
* console.log(opposition?.time.toISOString());
|
|
459
|
+
* ```
|
|
460
|
+
*/
|
|
461
|
+
export declare function nextAlignment(body: SkyBodyId, from: When, options: {
|
|
462
|
+
kind: AlignmentKind;
|
|
463
|
+
within?: {
|
|
464
|
+
days: number;
|
|
465
|
+
};
|
|
466
|
+
}): SkyAlignment | null;
|
|
467
|
+
/**
|
|
468
|
+
* The brightest the planet gets, and when.
|
|
469
|
+
*
|
|
470
|
+
* @experimental
|
|
471
|
+
* @example
|
|
472
|
+
* ```ts
|
|
473
|
+
* import { nextPeakMagnitude, type PeakMagnitude } from "@johnmorrisdotca/wakusei-planets/sky";
|
|
474
|
+
*
|
|
475
|
+
* const peak: PeakMagnitude = nextPeakMagnitude("venus", Date.UTC(2026, 0, 1));
|
|
476
|
+
* console.log(peak.time.toISOString(), peak.magnitude.toFixed(2));
|
|
477
|
+
* ```
|
|
478
|
+
*/
|
|
479
|
+
export interface PeakMagnitude {
|
|
480
|
+
time: Date;
|
|
481
|
+
/** The visual magnitude at that moment (a more negative number is brighter). */
|
|
482
|
+
magnitude: number;
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* The next time Venus is at its brightest as seen from the Earth, after `from`: the moment and its magnitude. Only Venus is supported, because astronomy-engine supports only Venus: Mercury's brightest moment is at superior conjunction, when it cannot be seen, and any other body throws a `RangeError`
|
|
486
|
+
* that says where to look. The other planets are brightest very near their opposition (`nextAlignment`), and the Moon near the full Moon (`nextMoonPhase`); their magnitudes at any moment are in `skyBody()`.
|
|
487
|
+
*
|
|
488
|
+
* @param body - `"venus"`.
|
|
489
|
+
* @param from - Where to start looking.
|
|
490
|
+
* @returns The moment and the magnitude.
|
|
491
|
+
* @experimental
|
|
492
|
+
* @example
|
|
493
|
+
* ```ts
|
|
494
|
+
* import { nextPeakMagnitude } from "@johnmorrisdotca/wakusei-planets/sky";
|
|
495
|
+
*
|
|
496
|
+
* const { time, magnitude } = nextPeakMagnitude("venus", Date.UTC(2026, 0, 1));
|
|
497
|
+
* console.log(time.toISOString(), magnitude.toFixed(2));
|
|
498
|
+
* ```
|
|
499
|
+
*/
|
|
500
|
+
export declare function nextPeakMagnitude(body: "venus", from: When): PeakMagnitude;
|
|
501
|
+
/**
|
|
502
|
+
* One moment of a local solar eclipse: when, and how high the Sun's centre stands then (degrees above the horizon, negative below it; the Sun's centre, with the refraction of the standard atmosphere as astronomy-engine applies it).
|
|
503
|
+
*
|
|
504
|
+
* @experimental
|
|
505
|
+
* @example
|
|
506
|
+
* ```ts
|
|
507
|
+
* import { type EclipseContact } from "@johnmorrisdotca/wakusei-planets/sky";
|
|
508
|
+
*
|
|
509
|
+
* const contact: EclipseContact = { time: new Date(0), altitude: 12 };
|
|
510
|
+
* console.log(contact.altitude > 0 ? "Sun up" : "Sun down");
|
|
511
|
+
* ```
|
|
512
|
+
*/
|
|
513
|
+
export interface EclipseContact {
|
|
514
|
+
time: Date;
|
|
515
|
+
altitude: number;
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* A solar eclipse as one observer sees it. The contacts are NASA's: `partialBegin` is the first contact (C1), `centralBegin` the second (C2, totality or the ring begins), `peak` the greatest eclipse, `centralEnd` the third (C3) and `partialEnd` the fourth (C4).
|
|
519
|
+
* A partial eclipse has no `centralBegin` or `centralEnd`. Any of them can fall with the Sun below the horizon: read the altitude.
|
|
520
|
+
*
|
|
521
|
+
* @experimental
|
|
522
|
+
* @example
|
|
523
|
+
* ```ts
|
|
524
|
+
* import { localSolarEclipse, type LocalSolarEclipse } from "@johnmorrisdotca/wakusei-planets/sky";
|
|
525
|
+
*
|
|
526
|
+
* const e: LocalSolarEclipse | null = localSolarEclipse(Date.UTC(2026, 0, 1), { observer: { latitude: 41.7, longitude: -2.5 } });
|
|
527
|
+
* console.log(e?.kind, e?.peak.time.toISOString(), e?.peak.altitude.toFixed(1));
|
|
528
|
+
* ```
|
|
529
|
+
*/
|
|
530
|
+
export interface LocalSolarEclipse {
|
|
531
|
+
kind: "partial" | "annular" | "total";
|
|
532
|
+
/** The fraction of the Sun's disc covered at the peak, 0 to 1 (exactly 1 for a total eclipse). */
|
|
533
|
+
obscuration: number;
|
|
534
|
+
partialBegin: EclipseContact;
|
|
535
|
+
centralBegin: EclipseContact | null;
|
|
536
|
+
peak: EclipseContact;
|
|
537
|
+
centralEnd: EclipseContact | null;
|
|
538
|
+
partialEnd: EclipseContact;
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* The next solar eclipse an observer can see at least partly in the sky's geometry (the Sun may be below the horizon for part of it, or all of it: read the altitudes), at or after `from`, with the times of its contacts and the Sun's altitude at each. `null` when none falls
|
|
542
|
+
* inside `within.days` (1826 days, five years, when not given). The altitude is the Sun's centre with standard refraction, and the contacts are for the observer's height.
|
|
543
|
+
*
|
|
544
|
+
* @param from - Where to start looking, included (an eclipse whose greatest moment is before it is not found).
|
|
545
|
+
* @param options - The observer (degrees north and east, metres), and `within.days`.
|
|
546
|
+
* @returns The eclipse or `null`.
|
|
547
|
+
* @experimental
|
|
548
|
+
* @example
|
|
549
|
+
* ```ts
|
|
550
|
+
* import { localSolarEclipse } from "@johnmorrisdotca/wakusei-planets/sky";
|
|
551
|
+
*
|
|
552
|
+
* const eclipse = localSolarEclipse(Date.UTC(2026, 6, 1), { observer: { latitude: 41.6, longitude: -4.7, heightM: 700 } });
|
|
553
|
+
* console.log(eclipse?.kind, eclipse?.partialBegin.time.toISOString(), eclipse?.partialEnd.time.toISOString());
|
|
554
|
+
* ```
|
|
555
|
+
*/
|
|
556
|
+
export declare function localSolarEclipse(from: When, options: {
|
|
557
|
+
observer: Observer;
|
|
558
|
+
within?: {
|
|
559
|
+
days: number;
|
|
560
|
+
};
|
|
561
|
+
}): LocalSolarEclipse | null;
|