@johnmorrisdotca/wakusei-planets 0.19.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/NOTICE.md +14 -3
- package/README.md +39 -6
- package/dist/bodies/earth.js +13 -5
- package/dist/calendar.d.ts +119 -0
- package/dist/calendar.js +155 -0
- package/dist/clock.d.ts +244 -0
- package/dist/clock.js +325 -0
- package/dist/coordinates.d.ts +172 -0
- package/dist/coordinates.js +170 -0
- package/dist/craft/cassini.d.ts +1 -0
- package/dist/craft/cassini.js +1131 -0
- package/dist/craft/galileo.d.ts +1 -0
- package/dist/craft/galileo.js +224 -0
- package/dist/craft/juno.d.ts +1 -0
- package/dist/craft/juno.js +640 -0
- package/dist/craft/newhorizons.d.ts +1 -0
- package/dist/craft/newhorizons.js +18 -0
- package/dist/craft/parker.d.ts +1 -0
- package/dist/craft/parker.js +221 -0
- package/dist/craft/pioneer10.d.ts +1 -0
- package/dist/craft/pioneer10.js +24 -0
- package/dist/craft/pioneer11.d.ts +1 -0
- package/dist/craft/pioneer11.js +34 -0
- package/dist/craft/voyager1.d.ts +1 -0
- package/dist/craft/voyager1.js +28 -0
- package/dist/craft/voyager2.d.ts +1 -0
- package/dist/craft/voyager2.js +43 -0
- package/dist/craft/webb.d.ts +1 -0
- package/dist/craft/webb.js +28 -0
- package/dist/data/craft.d.ts +23 -0
- package/dist/data/craft.js +53 -0
- package/dist/data/lunar.d.ts +4 -0
- package/dist/data/lunar.js +548 -0
- package/dist/data/pluto.d.ts +6 -0
- package/dist/data/pluto.js +29 -0
- package/dist/data/stars.d.ts +4 -0
- package/dist/data/stars.js +5088 -0
- package/dist/data/tables.d.ts +41 -0
- package/dist/data/tables.js +37 -0
- package/dist/data/vsop.d.ts +19 -1
- package/dist/data/vsop.js +25 -8
- package/dist/element.d.ts +2 -23
- package/dist/element.js +75 -110
- package/dist/ephemeris.d.ts +22 -14
- package/dist/ephemeris.js +106 -58
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/mars.d.ts +41 -0
- package/dist/mars.js +52 -0
- package/dist/portrait/element.d.ts +1 -0
- package/dist/portrait/element.js +27 -39
- package/dist/scales.d.ts +46 -0
- package/dist/scales.js +75 -0
- package/dist/scene/basis.d.ts +3 -0
- package/dist/scene/basis.js +4 -0
- package/dist/scene/body.d.ts +2 -4
- package/dist/scene/body.js +55 -67
- package/dist/scene/fallback.d.ts +4 -0
- package/dist/scene/fallback.js +5 -0
- package/dist/scene/painter.js +10 -23
- package/dist/scene/store.d.ts +2 -2
- package/dist/scene/textures.d.ts +30 -0
- package/dist/scene/textures.js +47 -0
- package/dist/sidereal.d.ts +70 -0
- package/dist/sidereal.js +94 -0
- package/dist/sky/engine.d.ts +37 -0
- package/dist/sky/engine.js +116 -0
- package/dist/sky/events.d.ts +37 -0
- package/dist/sky/events.js +133 -0
- package/dist/sky/frames.d.ts +3 -0
- package/dist/sky/frames.js +26 -0
- package/dist/sky/types.d.ts +20 -0
- package/dist/sky/types.js +1 -0
- package/dist/space/aim.d.ts +18 -0
- package/dist/space/aim.js +28 -0
- package/dist/space/element.d.ts +212 -0
- package/dist/space/element.js +524 -0
- package/dist/space/frame.d.ts +152 -0
- package/dist/space/frame.js +169 -0
- package/dist/space/index.d.ts +4 -0
- package/dist/space/index.js +5 -0
- package/dist/space/ride.d.ts +89 -0
- package/dist/space/ride.js +58 -0
- package/dist/space/scale.d.ts +126 -0
- package/dist/space/scale.js +139 -0
- package/dist/space/scene.d.ts +189 -0
- package/dist/space/scene.js +422 -0
- package/dist/spacecraft-facts.d.ts +114 -0
- package/dist/spacecraft-facts.js +215 -0
- package/dist/spacecraft.d.ts +134 -0
- package/dist/spacecraft.js +198 -0
- package/dist/stars.d.ts +160 -0
- package/dist/stars.js +193 -0
- package/dist/suncalc-legacy.d.ts +187 -0
- package/dist/suncalc-legacy.js +168 -0
- package/dist/suncalc.d.ts +209 -0
- package/dist/suncalc.js +167 -0
- package/dist/tables/all.d.ts +2 -0
- package/dist/tables/all.js +2 -0
- package/dist/tables/ceres.d.ts +1 -0
- package/dist/tables/ceres.js +57 -0
- package/dist/tables/dwarfs.d.ts +1 -0
- package/dist/tables/dwarfs.js +59 -0
- package/dist/theory.d.ts +20 -0
- package/dist/theory.js +98 -0
- package/dist/time.d.ts +6 -108
- package/dist/time.js +7 -180
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/when.d.ts +16 -0
- package/dist/when.js +13 -0
- package/package.json +95 -4
package/dist/scene/painter.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import "../bodies/all.js";
|
|
2
2
|
import { BODIES, MOONS_OF } from "../facts.js";
|
|
3
|
-
import {
|
|
3
|
+
import { writeBasis } from "./basis.js";
|
|
4
|
+
import { TEXTURE_BASE, TEXTURE_FAR_BASE, slash, loadImage } from "./textures.js";
|
|
4
5
|
import { cross } from "../vec.js";
|
|
5
6
|
import { bodyFragment, GLOW_FRAGMENT, GLOW_VERTEX, PAINTED_SURFACE, RING_FRAGMENT_WORLD, RING_VERTEX_WORLD, VERTEX_WORLD } from "./glsl.js";
|
|
7
|
+
import { fallbackLook } from "./fallback.js";
|
|
6
8
|
import { lookOf } from "./look.js";
|
|
7
9
|
import { moonOffset, orientation } from "./orient.js";
|
|
8
10
|
import { ringStrip } from "./rings.js";
|
|
@@ -19,9 +21,6 @@ export { moonOffset, orientation };
|
|
|
19
21
|
* ```
|
|
20
22
|
*/
|
|
21
23
|
export const LOOKS = ["realistic", "painted"];
|
|
22
|
-
const TEXTURE_BASE = `https://cdn.jsdelivr.net/npm/@johnmorrisdotca/wakusei-planets@${VERSION}/dist/textures/`;
|
|
23
|
-
const TEXTURE_FAR_BASE = `https://cdn.jsdelivr.net/gh/johnmorrisdotca/wakusei-planets@v${VERSION}/textures/`;
|
|
24
|
-
const slash = (base) => (base.endsWith("/") ? base : `${base}/`);
|
|
25
24
|
const titled = (id) => id.charAt(0).toUpperCase() + id.slice(1);
|
|
26
25
|
const pools = new WeakMap();
|
|
27
26
|
function acquire(three, key, make) {
|
|
@@ -49,10 +48,6 @@ function acquire(three, key, make) {
|
|
|
49
48
|
},
|
|
50
49
|
};
|
|
51
50
|
}
|
|
52
|
-
const fallbackLook = (id) => {
|
|
53
|
-
const c = [1, 3, 5].map((i) => (parseInt(BODIES[id].colour.slice(i, i + 2), 16) / 255).toFixed(3)).join(", ");
|
|
54
|
-
return { id, surface: `vec4 surface(vec3 p) { float n = fbm(p * 5.0); return vec4(vec3(${c}) * (0.85 + 0.3 * n), 0.0); }` };
|
|
55
|
-
};
|
|
56
51
|
/** The name of a body as the painter takes it: any case, `Sun`, a planet or Pluto, or a moon such as `Io`. */
|
|
57
52
|
function idOf(name) {
|
|
58
53
|
const id = name.toLowerCase();
|
|
@@ -66,7 +61,7 @@ const moonsOf = (planet) => {
|
|
|
66
61
|
};
|
|
67
62
|
function paint(T, id, context, bases) {
|
|
68
63
|
const facts = BODIES[id];
|
|
69
|
-
const look = lookOf(id) ?? fallbackLook(
|
|
64
|
+
const look = lookOf(id) ?? fallbackLook(facts);
|
|
70
65
|
const wantPainted = (context.look === "painted" || look.mapped === true) && look.painted !== undefined;
|
|
71
66
|
const ratio = context.ratio ?? 1;
|
|
72
67
|
const maxWidth = context.maxTexture ?? 2048;
|
|
@@ -106,7 +101,7 @@ function paint(T, id, context, bases) {
|
|
|
106
101
|
};
|
|
107
102
|
const shader = material(false);
|
|
108
103
|
const paintedMaterial = wantPainted ? material(true) : undefined;
|
|
109
|
-
const materials =
|
|
104
|
+
const materials = paintedMaterial ? [shader, paintedMaterial] : [shader];
|
|
110
105
|
const mesh = new T.Mesh(sphere.value, shader);
|
|
111
106
|
mesh.matrixAutoUpdate = false;
|
|
112
107
|
group.add(mesh);
|
|
@@ -117,11 +112,6 @@ function paint(T, id, context, bases) {
|
|
|
117
112
|
let ringInner = 1;
|
|
118
113
|
let ringOuter = 2;
|
|
119
114
|
const table = look.emissive === true ? null : ringStrip(facts, 1024);
|
|
120
|
-
const loadImage = (url) => new Promise((resolve, reject) => {
|
|
121
|
-
const loader = new T.TextureLoader();
|
|
122
|
-
loader.setCrossOrigin("anonymous");
|
|
123
|
-
loader.load(url, resolve, undefined, (e) => reject(e instanceof Error ? e : new Error("texture failed")));
|
|
124
|
-
});
|
|
125
115
|
let gone = false;
|
|
126
116
|
if (table !== null) {
|
|
127
117
|
ringInner = table.inner;
|
|
@@ -150,7 +140,7 @@ function paint(T, id, context, bases) {
|
|
|
150
140
|
group.add(ringMesh);
|
|
151
141
|
const photo = wantPainted ? look.painted?.rings : undefined;
|
|
152
142
|
if (photo !== undefined) {
|
|
153
|
-
void loadImage(`${bases.near}${photo.map}-${photo.width}.webp`).then((t) => {
|
|
143
|
+
void loadImage(T, `${bases.near}${photo.map}-${photo.width}.webp`).then((t) => {
|
|
154
144
|
if (gone) {
|
|
155
145
|
t.dispose();
|
|
156
146
|
return;
|
|
@@ -217,7 +207,7 @@ function paint(T, id, context, bases) {
|
|
|
217
207
|
redraw();
|
|
218
208
|
};
|
|
219
209
|
if (wantPainted && paintedMaterial !== undefined && widths[0] !== undefined) {
|
|
220
|
-
void loadImage(urlOf(widths[0])).then((t) => {
|
|
210
|
+
void loadImage(T, urlOf(widths[0])).then((t) => {
|
|
221
211
|
if (gone) {
|
|
222
212
|
t.dispose();
|
|
223
213
|
return;
|
|
@@ -237,7 +227,7 @@ function paint(T, id, context, bases) {
|
|
|
237
227
|
if (next > sharpWidth && next > widths[0] && !tried.has(next)) {
|
|
238
228
|
tried.add(next);
|
|
239
229
|
loading = true;
|
|
240
|
-
void loadImage(urlOf(next)).then((t) => {
|
|
230
|
+
void loadImage(T, urlOf(next)).then((t) => {
|
|
241
231
|
loading = false;
|
|
242
232
|
if (gone) {
|
|
243
233
|
t.dispose();
|
|
@@ -273,9 +263,6 @@ function paint(T, id, context, bases) {
|
|
|
273
263
|
const scaleX = axes ? axes[1] / facts.radiusKm : 1;
|
|
274
264
|
const scaleY = axes ? axes[2] / facts.radiusKm : 1 - facts.flattening;
|
|
275
265
|
const scaleZ = axes ? axes[0] / facts.radiusKm : 1;
|
|
276
|
-
const basis = (object, x, y, z, sx = 1, sy = 1, sz = 1) => {
|
|
277
|
-
object.matrix.makeBasis(new T.Vector3(x[0] * sx, x[1] * sx, x[2] * sx), new T.Vector3(y[0] * sy, y[1] * sy, y[2] * sy), new T.Vector3(z[0] * sz, z[1] * sz, z[2] * sz));
|
|
278
|
-
};
|
|
279
266
|
const light = new T.Vector3();
|
|
280
267
|
const poleVec = new T.Vector3();
|
|
281
268
|
return {
|
|
@@ -287,9 +274,9 @@ function paint(T, id, context, bases) {
|
|
|
287
274
|
if (look.emissive !== true) {
|
|
288
275
|
const { pole, meridian } = info.pose ?? orientation(id, info.ms);
|
|
289
276
|
const east = cross(pole, meridian);
|
|
290
|
-
|
|
277
|
+
writeBasis(mesh.matrix, east, pole, meridian, scaleX, scaleY, scaleZ);
|
|
291
278
|
if (ringMesh !== undefined)
|
|
292
|
-
|
|
279
|
+
writeBasis(ringMesh.matrix, meridian, east, pole);
|
|
293
280
|
poleVec.set(pole[0], pole[1], pole[2]);
|
|
294
281
|
}
|
|
295
282
|
const occluders = info.occluders ?? [];
|
package/dist/scene/store.d.ts
CHANGED
|
@@ -2,11 +2,11 @@ import type { BodyId } from "../facts.ts";
|
|
|
2
2
|
import type { BodyLook } from "./look.ts";
|
|
3
3
|
/** A body whose line look another package's element draws (the Earth, by chikyu-earth) instead of this one: the element asks it for what to show. The shaded and painted looks are always this package's. */
|
|
4
4
|
export interface Delegate {
|
|
5
|
-
/** The line look: an element for the body, centred on a longitude and latitude (`"lon,lat"`). */
|
|
5
|
+
/** The line look: an element for the body, centred on a longitude and latitude (`"lon,lat"`), or null when the other package is not on the page and this one draws its own. */
|
|
6
6
|
line(options: {
|
|
7
7
|
center: string;
|
|
8
8
|
size: number;
|
|
9
|
-
}): Promise<HTMLElement>;
|
|
9
|
+
}): Promise<HTMLElement | null>;
|
|
10
10
|
}
|
|
11
11
|
export declare const looks: Map<BodyId, BodyLook>, waiting: Set<() => void>, delegates: Map<BodyId, Delegate>;
|
|
12
12
|
/** Call `wake` whenever a look is registered; returns a function that stops it. */
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type * as THREE from "three";
|
|
2
|
+
/**
|
|
3
|
+
* The default home of the surface pictures: the files of this exact version on jsDelivr. Set `texture-base` on an element to serve them yourself.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts no-run
|
|
7
|
+
* import { TEXTURE_BASE } from "@johnmorrisdotca/wakusei-planets/element";
|
|
8
|
+
*
|
|
9
|
+
* console.log(TEXTURE_BASE);
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare const TEXTURE_BASE = "https://cdn.jsdelivr.net/npm/@johnmorrisdotca/wakusei-planets@0.21.0/dist/textures/";
|
|
13
|
+
/**
|
|
14
|
+
* Where the sharpest surface pictures are: the files of this exact version in the repository, on jsDelivr's GitHub address. The npm package holds only the two smaller widths, so a page that
|
|
15
|
+
* never zooms in never fetches them. Set `texture-far-base` on an element to serve them yourself.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts no-run
|
|
19
|
+
* import { TEXTURE_FAR_BASE } from "@johnmorrisdotca/wakusei-planets/element";
|
|
20
|
+
*
|
|
21
|
+
* console.log(TEXTURE_FAR_BASE);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare const TEXTURE_FAR_BASE = "https://cdn.jsdelivr.net/gh/johnmorrisdotca/wakusei-planets@v0.21.0/textures/";
|
|
25
|
+
export declare const slash: (base: string) => string;
|
|
26
|
+
export declare function texturePaths(element: Element): {
|
|
27
|
+
textureBase(): string;
|
|
28
|
+
farBase(): string;
|
|
29
|
+
};
|
|
30
|
+
export declare function loadImage(three: Pick<typeof THREE, "TextureLoader">, url: string): Promise<THREE.Texture>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { VERSION } from "../version.js";
|
|
2
|
+
/**
|
|
3
|
+
* The default home of the surface pictures: the files of this exact version on jsDelivr. Set `texture-base` on an element to serve them yourself.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts no-run
|
|
7
|
+
* import { TEXTURE_BASE } from "@johnmorrisdotca/wakusei-planets/element";
|
|
8
|
+
*
|
|
9
|
+
* console.log(TEXTURE_BASE);
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export const TEXTURE_BASE = `https://cdn.jsdelivr.net/npm/@johnmorrisdotca/wakusei-planets@${VERSION}/dist/textures/`;
|
|
13
|
+
/**
|
|
14
|
+
* Where the sharpest surface pictures are: the files of this exact version in the repository, on jsDelivr's GitHub address. The npm package holds only the two smaller widths, so a page that
|
|
15
|
+
* never zooms in never fetches them. Set `texture-far-base` on an element to serve them yourself.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts no-run
|
|
19
|
+
* import { TEXTURE_FAR_BASE } from "@johnmorrisdotca/wakusei-planets/element";
|
|
20
|
+
*
|
|
21
|
+
* console.log(TEXTURE_FAR_BASE);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export const TEXTURE_FAR_BASE = `https://cdn.jsdelivr.net/gh/johnmorrisdotca/wakusei-planets@v${VERSION}/textures/`;
|
|
25
|
+
export const slash = (base) => (base.endsWith("/") ? base : `${base}/`);
|
|
26
|
+
export function texturePaths(element) {
|
|
27
|
+
const textureBase = () => {
|
|
28
|
+
const own = element.getAttribute("texture-base");
|
|
29
|
+
return own === null || own === "" ? TEXTURE_BASE : slash(own);
|
|
30
|
+
};
|
|
31
|
+
return {
|
|
32
|
+
textureBase,
|
|
33
|
+
farBase: () => {
|
|
34
|
+
const own = element.getAttribute("texture-far-base");
|
|
35
|
+
if (own !== null && own !== "")
|
|
36
|
+
return slash(own);
|
|
37
|
+
return element.hasAttribute("texture-base") ? textureBase() : TEXTURE_FAR_BASE;
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export function loadImage(three, url) {
|
|
42
|
+
return new Promise((resolve, reject) => {
|
|
43
|
+
const loader = new three.TextureLoader();
|
|
44
|
+
loader.setCrossOrigin("anonymous");
|
|
45
|
+
loader.load(url, resolve, undefined, (error) => reject(error instanceof Error ? error : new Error("texture failed")));
|
|
46
|
+
});
|
|
47
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type When } from "./when.ts";
|
|
2
|
+
/** IAU 1980 mean obliquity, in arcseconds, at TT Julian centuries from J2000. */
|
|
3
|
+
export declare const meanObliquityArcseconds: (T: number) => number;
|
|
4
|
+
/** Unwrapped IAU 1982 Greenwich mean sidereal angle, in degrees, at UT1 days from J2000. */
|
|
5
|
+
export declare function meanSiderealDegrees(days: number): number;
|
|
6
|
+
/** Nutation in longitude and in obliquity, and the mean obliquity of date, in radians, at `T` Julian centuries of terrestrial time from J2000 (Meeus ch. 22, accurate to 0.5 arc-seconds). */
|
|
7
|
+
export declare function nutation(T: number): {
|
|
8
|
+
longitude: number;
|
|
9
|
+
obliquity: number;
|
|
10
|
+
meanObliquity: number;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* The Greenwich mean sidereal time in degrees, 0 to 360 (divide by 15 for hours).
|
|
14
|
+
* @param when - A `Date` or milliseconds since 1970 (UTC).
|
|
15
|
+
* @param dut1 - UT1 minus UTC in seconds, from the IERS; default 0 (within 0.9 s).
|
|
16
|
+
* @returns Degrees.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { greenwichMeanSiderealTime } from "@johnmorrisdotca/wakusei-planets/time";
|
|
21
|
+
*
|
|
22
|
+
* console.log((greenwichMeanSiderealTime(Date.UTC(1987, 3, 10)) / 15).toFixed(4));
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function greenwichMeanSiderealTime(when: When, dut1?: number): number;
|
|
26
|
+
/**
|
|
27
|
+
* The equation of the equinoxes in degrees: the nutation in longitude times the cosine of the obliquity, what apparent sidereal time has over mean (about 1 second of time at most).
|
|
28
|
+
* @param when - A `Date` or milliseconds since 1970 (UTC).
|
|
29
|
+
* @returns Degrees, between about -0.0013 and 0.0013.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* import { equationOfTheEquinoxes } from "@johnmorrisdotca/wakusei-planets/time";
|
|
34
|
+
*
|
|
35
|
+
* console.log((equationOfTheEquinoxes(Date.UTC(1987, 3, 10)) * 240).toFixed(4));
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function equationOfTheEquinoxes(when: When): number;
|
|
39
|
+
/**
|
|
40
|
+
* The Greenwich apparent sidereal time in degrees, 0 to 360: the mean time with the equation of the equinoxes added, which is what the hour angle of a body is measured against.
|
|
41
|
+
* @param when - A `Date` or milliseconds since 1970 (UTC).
|
|
42
|
+
* @param dut1 - UT1 minus UTC in seconds, from the IERS; default 0.
|
|
43
|
+
* @returns Degrees.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* import { greenwichApparentSiderealTime } from "@johnmorrisdotca/wakusei-planets/time";
|
|
48
|
+
*
|
|
49
|
+
* console.log((greenwichApparentSiderealTime(Date.UTC(1987, 3, 10)) / 15).toFixed(4));
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare function greenwichApparentSiderealTime(when: When, dut1?: number): number;
|
|
53
|
+
/**
|
|
54
|
+
* The local sidereal time in degrees, 0 to 360, at a longitude east of Greenwich (west negative): the right ascension on the meridian.
|
|
55
|
+
* @param when - A `Date` or milliseconds since 1970 (UTC).
|
|
56
|
+
* @param longitude - Degrees east.
|
|
57
|
+
* @param options - `apparent` (default `true`: with the equation of the equinoxes) and `dut1`, UT1 minus UTC in seconds.
|
|
58
|
+
* @returns Degrees.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* import { localSiderealTime } from "@johnmorrisdotca/wakusei-planets/time";
|
|
63
|
+
*
|
|
64
|
+
* console.log(localSiderealTime(Date.UTC(2026, 10, 7, 12), -123.1).toFixed(2));
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare function localSiderealTime(when: When, longitude: number, options?: {
|
|
68
|
+
apparent?: boolean;
|
|
69
|
+
dut1?: number;
|
|
70
|
+
}): number;
|
package/dist/sidereal.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// Sidereal time: the Earth's turn against the stars. Greenwich mean sidereal time (IAU 1982, Meeus ch. 12) from UT1, the equation of the equinoxes from the nutation (IAU 1980, its largest terms, 0.5 arc-seconds),
|
|
2
|
+
// the apparent time that adds it, and the local time at a longitude. Angles are degrees, 0 to 360 (15 degrees an hour). UT1 is UTC unless `dut1` is given, which is within 0.9 s of the Earth's turn (0.004 degrees). Pure: no DOM, no three.js.
|
|
3
|
+
import { J2000_JD, julianCenturies, toJulianDate } from "./clock.js";
|
|
4
|
+
import { moment } from "./when.js";
|
|
5
|
+
const RAD = Math.PI / 180;
|
|
6
|
+
const ARCSEC = Math.PI / 648000;
|
|
7
|
+
/** IAU 1980 mean obliquity, in arcseconds, at TT Julian centuries from J2000. */
|
|
8
|
+
export const meanObliquityArcseconds = (T) => 84381.448 - 46.815 * T - 0.00059 * T * T + 0.001813 * T * T * T;
|
|
9
|
+
/** Unwrapped IAU 1982 Greenwich mean sidereal angle, in degrees, at UT1 days from J2000. */
|
|
10
|
+
export function meanSiderealDegrees(days) {
|
|
11
|
+
const T = days / 36525;
|
|
12
|
+
return 280.46061837 + 360.98564736629 * days + 0.000387933 * T * T - (T * T * T) / 38710000;
|
|
13
|
+
}
|
|
14
|
+
/** Nutation in longitude and in obliquity, and the mean obliquity of date, in radians, at `T` Julian centuries of terrestrial time from J2000 (Meeus ch. 22, accurate to 0.5 arc-seconds). */
|
|
15
|
+
export function nutation(T) {
|
|
16
|
+
const omega = (125.04452 - 1934.136261 * T) * RAD;
|
|
17
|
+
const twiceSunLongitude = (560.933 + 72001.5396 * T) * RAD;
|
|
18
|
+
const twiceMoonLongitude = (436.633 + 962535.7626 * T) * RAD;
|
|
19
|
+
const longitude = (-17.2 * Math.sin(omega) - 1.32 * Math.sin(twiceSunLongitude) - 0.23 * Math.sin(twiceMoonLongitude) + 0.21 * Math.sin(2 * omega)) * ARCSEC;
|
|
20
|
+
const obliquity = (9.2 * Math.cos(omega) + 0.57 * Math.cos(twiceSunLongitude) + 0.1 * Math.cos(twiceMoonLongitude) - 0.09 * Math.cos(2 * omega)) * ARCSEC;
|
|
21
|
+
const meanObliquity = meanObliquityArcseconds(T) * ARCSEC;
|
|
22
|
+
return { longitude, obliquity, meanObliquity };
|
|
23
|
+
}
|
|
24
|
+
const wrap = (degrees) => ((degrees % 360) + 360) % 360;
|
|
25
|
+
/**
|
|
26
|
+
* The Greenwich mean sidereal time in degrees, 0 to 360 (divide by 15 for hours).
|
|
27
|
+
* @param when - A `Date` or milliseconds since 1970 (UTC).
|
|
28
|
+
* @param dut1 - UT1 minus UTC in seconds, from the IERS; default 0 (within 0.9 s).
|
|
29
|
+
* @returns Degrees.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* import { greenwichMeanSiderealTime } from "@johnmorrisdotca/wakusei-planets/time";
|
|
34
|
+
*
|
|
35
|
+
* console.log((greenwichMeanSiderealTime(Date.UTC(1987, 3, 10)) / 15).toFixed(4));
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export function greenwichMeanSiderealTime(when, dut1 = 0) {
|
|
39
|
+
const jd = toJulianDate(moment(when) + dut1 * 1000);
|
|
40
|
+
return wrap(meanSiderealDegrees(jd - J2000_JD));
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The equation of the equinoxes in degrees: the nutation in longitude times the cosine of the obliquity, what apparent sidereal time has over mean (about 1 second of time at most).
|
|
44
|
+
* @param when - A `Date` or milliseconds since 1970 (UTC).
|
|
45
|
+
* @returns Degrees, between about -0.0013 and 0.0013.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* import { equationOfTheEquinoxes } from "@johnmorrisdotca/wakusei-planets/time";
|
|
50
|
+
*
|
|
51
|
+
* console.log((equationOfTheEquinoxes(Date.UTC(1987, 3, 10)) * 240).toFixed(4));
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export function equationOfTheEquinoxes(when) {
|
|
55
|
+
const T = julianCenturies(when);
|
|
56
|
+
const n = nutation(T);
|
|
57
|
+
return (n.longitude * Math.cos(n.meanObliquity + n.obliquity)) / RAD;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The Greenwich apparent sidereal time in degrees, 0 to 360: the mean time with the equation of the equinoxes added, which is what the hour angle of a body is measured against.
|
|
61
|
+
* @param when - A `Date` or milliseconds since 1970 (UTC).
|
|
62
|
+
* @param dut1 - UT1 minus UTC in seconds, from the IERS; default 0.
|
|
63
|
+
* @returns Degrees.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* import { greenwichApparentSiderealTime } from "@johnmorrisdotca/wakusei-planets/time";
|
|
68
|
+
*
|
|
69
|
+
* console.log((greenwichApparentSiderealTime(Date.UTC(1987, 3, 10)) / 15).toFixed(4));
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export function greenwichApparentSiderealTime(when, dut1 = 0) {
|
|
73
|
+
return wrap(greenwichMeanSiderealTime(when, dut1) + equationOfTheEquinoxes(when));
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The local sidereal time in degrees, 0 to 360, at a longitude east of Greenwich (west negative): the right ascension on the meridian.
|
|
77
|
+
* @param when - A `Date` or milliseconds since 1970 (UTC).
|
|
78
|
+
* @param longitude - Degrees east.
|
|
79
|
+
* @param options - `apparent` (default `true`: with the equation of the equinoxes) and `dut1`, UT1 minus UTC in seconds.
|
|
80
|
+
* @returns Degrees.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* import { localSiderealTime } from "@johnmorrisdotca/wakusei-planets/time";
|
|
85
|
+
*
|
|
86
|
+
* console.log(localSiderealTime(Date.UTC(2026, 10, 7, 12), -123.1).toFixed(2));
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
export function localSiderealTime(when, longitude, options = {}) {
|
|
90
|
+
if (!Number.isFinite(longitude))
|
|
91
|
+
throw new RangeError(`longitude must be a finite number of degrees east, got ${longitude}`);
|
|
92
|
+
const greenwich = options.apparent === false ? greenwichMeanSiderealTime(when, options.dut1) : greenwichApparentSiderealTime(when, options.dut1);
|
|
93
|
+
return wrap(greenwich + longitude);
|
|
94
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { greenwichApparentSiderealTime as greenwichSiderealTime } from "../sidereal.ts";
|
|
2
|
+
import type { EquatorialAngles, HorizontalAngles, Observer } from "./types.ts";
|
|
3
|
+
export type { Observer } from "./types.ts";
|
|
4
|
+
/** A body's place on the sky of date, as the Earth's centre sees it (apparent: light time, aberration for the Sun, nutation): angles in degrees, distance in kilometres. */
|
|
5
|
+
export interface Equatorial extends EquatorialAngles {
|
|
6
|
+
distanceKm: number;
|
|
7
|
+
}
|
|
8
|
+
/** Where a body is in a place's sky: azimuth 0 to 360 from north through east, altitude, the hour angle (0 on the meridian, positive west) and the parallactic angle, all in degrees. */
|
|
9
|
+
export interface Horizontal extends HorizontalAngles {
|
|
10
|
+
hourAngle: number;
|
|
11
|
+
parallacticAngle: number;
|
|
12
|
+
/** The distance from the place to the body in kilometres. */
|
|
13
|
+
distanceKm: number;
|
|
14
|
+
}
|
|
15
|
+
/** The Sun as seen from the Earth's centre: the apparent place of date, with the annual aberration (the Earth's speed over the speed of light, about 20 arc-seconds) and nutation. */
|
|
16
|
+
export declare function sunEquatorial(ms: number): Equatorial;
|
|
17
|
+
/** The Moon as seen from the Earth's centre: the apparent place of date, with the light time (the Moon is about 1.3 seconds away) and nutation. */
|
|
18
|
+
export declare function moonEquatorial(ms: number): Equatorial;
|
|
19
|
+
/** The apparent sidereal time at Greenwich in degrees, from the UTC instant taken as UT1. */
|
|
20
|
+
export { greenwichSiderealTime };
|
|
21
|
+
/**
|
|
22
|
+
* Altitude, azimuth, hour angle and parallactic angle of a body for an observer: topocentric (parallax taken out of the Earth's centre to the place) and geometric, with no refraction.
|
|
23
|
+
* `ms` is the instant the observer's sky turns for; the body's place `equatorial` is its apparent place at that instant.
|
|
24
|
+
*/
|
|
25
|
+
export declare function horizontalOf(equatorial: Equatorial, ms: number, observer: Observer): Horizontal;
|
|
26
|
+
/**
|
|
27
|
+
* The refraction of the atmosphere in degrees at a geometric altitude in degrees (Saemundsson's formula, standard air at 10 degrees C and 1010 hPa): it lifts a body toward the zenith.
|
|
28
|
+
* It is smooth through the horizon and fades to nothing below -2 degrees.
|
|
29
|
+
*/
|
|
30
|
+
export declare function refraction(altitude: number): number;
|
|
31
|
+
/** The Moon's phase: the illuminated fraction 0 to 1, the phase 0 to 1 (0 new, 0.25 first quarter, 0.5 full, 0.75 last quarter), the bright limb's position angle in degrees eastward from north, and whether it is waxing. */
|
|
32
|
+
export declare function moonPhase(ms: number): {
|
|
33
|
+
fraction: number;
|
|
34
|
+
phase: number;
|
|
35
|
+
angle: number;
|
|
36
|
+
waxing: boolean;
|
|
37
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
// What the Sun and the Moon look like from a place on the Earth at a moment: apparent right ascension and declination of date, parallax, refraction, altitude and azimuth, the phase and the bright limb.
|
|
2
|
+
// Written from the standard methods (Meeus, "Astronomical Algorithms", chapters 12, 21, 22, 40, 48; the IAU 1976 precession; IAU 1980 nutation, its largest terms) on this package's own positions: the Sun from the Earth's VSOP87B place,
|
|
3
|
+
// the Moon from ELP2000-82B. Pure: no DOM, no three.js. Time is UTC in milliseconds; UT1 is taken as UTC (up to 0.9 s, 0.004 degrees of turn of the Earth); the theories run in terrestrial time.
|
|
4
|
+
import { earthPosition, moonGeocentric } from "../theory.js";
|
|
5
|
+
import { julianCenturies } from "../clock.js";
|
|
6
|
+
import { greenwichApparentSiderealTime as greenwichSiderealTime, nutation } from "../sidereal.js";
|
|
7
|
+
import { eclipticJ2000ToTrueEquatorialOfDate } from "./frames.js";
|
|
8
|
+
const RAD = Math.PI / 180;
|
|
9
|
+
const DEG = 180 / Math.PI;
|
|
10
|
+
const AU_KM = 149597870.7;
|
|
11
|
+
const LIGHT_KM_S = 299792.458;
|
|
12
|
+
/** The Earth's equatorial radius in kilometres and its flattening (WGS 84). */
|
|
13
|
+
const EARTH_RADIUS_KM = 6378.137;
|
|
14
|
+
const EARTH_FLATTENING = 1 / 298.257223563;
|
|
15
|
+
const toEquatorial = (v, distanceKm) => ({
|
|
16
|
+
rightAscension: ((Math.atan2(v[1], v[0]) * DEG) % 360 + 360) % 360,
|
|
17
|
+
declination: Math.asin(Math.max(-1, Math.min(1, v[2] / Math.hypot(v[0], v[1], v[2])))) * DEG,
|
|
18
|
+
distanceKm,
|
|
19
|
+
});
|
|
20
|
+
const fromEquatorial = (e) => {
|
|
21
|
+
const ra = e.rightAscension * RAD;
|
|
22
|
+
const dec = e.declination * RAD;
|
|
23
|
+
return [e.distanceKm * Math.cos(dec) * Math.cos(ra), e.distanceKm * Math.cos(dec) * Math.sin(ra), e.distanceKm * Math.sin(dec)];
|
|
24
|
+
};
|
|
25
|
+
/** The Sun as seen from the Earth's centre: the apparent place of date, with the annual aberration (the Earth's speed over the speed of light, about 20 arc-seconds) and nutation. */
|
|
26
|
+
export function sunEquatorial(ms) {
|
|
27
|
+
const T = julianCenturies(ms);
|
|
28
|
+
const earth = earthPosition(ms);
|
|
29
|
+
const later = earthPosition(ms + 60_000);
|
|
30
|
+
const sun = [-earth[0], -earth[1], -earth[2]];
|
|
31
|
+
const distanceAu = Math.hypot(sun[0], sun[1], sun[2]);
|
|
32
|
+
// the Earth's velocity in au per second, over the speed of light in au per second, moves the apparent direction toward where the Earth is heading
|
|
33
|
+
const beta = [(later[0] - earth[0]) / 60 / (LIGHT_KM_S / AU_KM), (later[1] - earth[1]) / 60 / (LIGHT_KM_S / AU_KM), (later[2] - earth[2]) / 60 / (LIGHT_KM_S / AU_KM)];
|
|
34
|
+
const aberrated = [sun[0] / distanceAu + beta[0], sun[1] / distanceAu + beta[1], sun[2] / distanceAu + beta[2]];
|
|
35
|
+
return toEquatorial(eclipticJ2000ToTrueEquatorialOfDate(aberrated, T), distanceAu * AU_KM);
|
|
36
|
+
}
|
|
37
|
+
/** The Moon as seen from the Earth's centre: the apparent place of date, with the light time (the Moon is about 1.3 seconds away) and nutation. */
|
|
38
|
+
export function moonEquatorial(ms) {
|
|
39
|
+
const T = julianCenturies(ms);
|
|
40
|
+
const first = moonGeocentric(ms);
|
|
41
|
+
const distance = Math.hypot(first[0], first[1], first[2]);
|
|
42
|
+
const geometric = moonGeocentric(ms - (distance / LIGHT_KM_S) * 1000);
|
|
43
|
+
return toEquatorial(eclipticJ2000ToTrueEquatorialOfDate(geometric, T), Math.hypot(geometric[0], geometric[1], geometric[2]));
|
|
44
|
+
}
|
|
45
|
+
/** The apparent sidereal time at Greenwich in degrees, from the UTC instant taken as UT1. */
|
|
46
|
+
export { greenwichSiderealTime };
|
|
47
|
+
/** The observer's place from the Earth's centre in the true equator of date, in kilometres, with the turn of the Earth (Meeus ch. 11). */
|
|
48
|
+
function observerVector(observer, ms) {
|
|
49
|
+
const lat = observer.latitude * RAD;
|
|
50
|
+
const height = (observer.heightM ?? 0) / 1000;
|
|
51
|
+
const u = Math.atan((1 - EARTH_FLATTENING) * Math.tan(lat));
|
|
52
|
+
const rhoSin = (1 - EARTH_FLATTENING) * Math.sin(u) + (height / EARTH_RADIUS_KM) * Math.sin(lat);
|
|
53
|
+
const rhoCos = Math.cos(u) + (height / EARTH_RADIUS_KM) * Math.cos(lat);
|
|
54
|
+
const theta = (greenwichSiderealTime(ms) + observer.longitude) * RAD;
|
|
55
|
+
return [EARTH_RADIUS_KM * rhoCos * Math.cos(theta), EARTH_RADIUS_KM * rhoCos * Math.sin(theta), EARTH_RADIUS_KM * rhoSin];
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Altitude, azimuth, hour angle and parallactic angle of a body for an observer: topocentric (parallax taken out of the Earth's centre to the place) and geometric, with no refraction.
|
|
59
|
+
* `ms` is the instant the observer's sky turns for; the body's place `equatorial` is its apparent place at that instant.
|
|
60
|
+
*/
|
|
61
|
+
export function horizontalOf(equatorial, ms, observer) {
|
|
62
|
+
const body = fromEquatorial(equatorial);
|
|
63
|
+
const place = observerVector(observer, ms);
|
|
64
|
+
const topo = [body[0] - place[0], body[1] - place[1], body[2] - place[2]];
|
|
65
|
+
const distanceKm = Math.hypot(topo[0], topo[1], topo[2]);
|
|
66
|
+
const ra = Math.atan2(topo[1], topo[0]);
|
|
67
|
+
const dec = Math.asin(topo[2] / distanceKm);
|
|
68
|
+
const lat = observer.latitude * RAD;
|
|
69
|
+
const H = (greenwichSiderealTime(ms) + observer.longitude) * RAD - ra;
|
|
70
|
+
const sinAlt = Math.sin(lat) * Math.sin(dec) + Math.cos(lat) * Math.cos(dec) * Math.cos(H);
|
|
71
|
+
const altitude = Math.asin(Math.max(-1, Math.min(1, sinAlt)));
|
|
72
|
+
const azimuth = Math.atan2(-Math.cos(dec) * Math.sin(H), Math.sin(dec) * Math.cos(lat) - Math.cos(dec) * Math.sin(lat) * Math.cos(H));
|
|
73
|
+
const parallactic = Math.atan2(Math.sin(H), Math.tan(lat) * Math.cos(dec) - Math.sin(dec) * Math.cos(H));
|
|
74
|
+
return {
|
|
75
|
+
azimuth: (((azimuth * DEG) % 360) + 360) % 360,
|
|
76
|
+
altitude: altitude * DEG,
|
|
77
|
+
hourAngle: ((((H * DEG) % 360) + 540) % 360) - 180,
|
|
78
|
+
parallacticAngle: parallactic * DEG,
|
|
79
|
+
distanceKm,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The refraction of the atmosphere in degrees at a geometric altitude in degrees (Saemundsson's formula, standard air at 10 degrees C and 1010 hPa): it lifts a body toward the zenith.
|
|
84
|
+
* It is smooth through the horizon and fades to nothing below -2 degrees.
|
|
85
|
+
*/
|
|
86
|
+
export function refraction(altitude) {
|
|
87
|
+
if (altitude < -2)
|
|
88
|
+
return 0;
|
|
89
|
+
const h = Math.max(altitude, -1);
|
|
90
|
+
const r = 1.02 / Math.tan((h + 10.3 / (h + 5.11)) * RAD) / 60;
|
|
91
|
+
return altitude < -1 ? r * (altitude + 2) : r;
|
|
92
|
+
}
|
|
93
|
+
/** The Moon's phase: the illuminated fraction 0 to 1, the phase 0 to 1 (0 new, 0.25 first quarter, 0.5 full, 0.75 last quarter), the bright limb's position angle in degrees eastward from north, and whether it is waxing. */
|
|
94
|
+
export function moonPhase(ms) {
|
|
95
|
+
const sun = sunEquatorial(ms);
|
|
96
|
+
const moon = moonEquatorial(ms);
|
|
97
|
+
const sunV = fromEquatorial(sun);
|
|
98
|
+
const moonV = fromEquatorial(moon);
|
|
99
|
+
const psi = Math.acos(Math.max(-1, Math.min(1, (sunV[0] * moonV[0] + sunV[1] * moonV[1] + sunV[2] * moonV[2]) / (sun.distanceKm * moon.distanceKm))));
|
|
100
|
+
// the angle at the Moon between the Sun and the Earth (Meeus ch. 48)
|
|
101
|
+
const inc = Math.atan2(sun.distanceKm * Math.sin(psi), moon.distanceKm - sun.distanceKm * Math.cos(psi));
|
|
102
|
+
const fraction = (1 + Math.cos(inc)) / 2;
|
|
103
|
+
const a0 = sun.rightAscension * RAD;
|
|
104
|
+
const d0 = sun.declination * RAD;
|
|
105
|
+
const a = moon.rightAscension * RAD;
|
|
106
|
+
const d = moon.declination * RAD;
|
|
107
|
+
const angle = Math.atan2(Math.cos(d0) * Math.sin(a0 - a), Math.sin(d0) * Math.cos(d) - Math.cos(d0) * Math.sin(d) * Math.cos(a0 - a)) * DEG;
|
|
108
|
+
// waxing while the Moon is east of the Sun along the ecliptic: its longitude is ahead by under half a turn
|
|
109
|
+
const n = nutation(julianCenturies(ms));
|
|
110
|
+
const epsilon = n.meanObliquity + n.obliquity;
|
|
111
|
+
const longitudeOf = (v) => Math.atan2(v[1] * Math.cos(epsilon) + v[2] * Math.sin(epsilon), v[0]) * DEG;
|
|
112
|
+
const ahead = (((longitudeOf(moonV) - longitudeOf(sunV)) % 360) + 360) % 360;
|
|
113
|
+
const waxing = ahead < 180;
|
|
114
|
+
const phase = waxing ? 0.5 - inc / (2 * Math.PI) : 0.5 + inc / (2 * Math.PI);
|
|
115
|
+
return { fraction, phase: phase >= 1 ? phase - 1 : phase, angle: ((angle % 360) + 360) % 360, waxing };
|
|
116
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type Observer } from "./engine.ts";
|
|
2
|
+
/** A date or milliseconds since 1970 as milliseconds, throwing on anything that is not a moment. */
|
|
3
|
+
export declare function moment(date: Date | number, name?: string): number;
|
|
4
|
+
export declare function place(latitude: number, longitude: number, heightM?: number): Observer;
|
|
5
|
+
/** The window of a day: the local calendar day when a UTC offset is given, otherwise the solar day from one solar midnight to the next that holds the moment. Milliseconds, the end not included. */
|
|
6
|
+
export declare function dayWindow(ms: number, observer: Observer, utcOffset: number | undefined): [number, number];
|
|
7
|
+
/** The Sun's hour angle in degrees from -180 to 180 for an observer (positive west, 0 on the meridian). */
|
|
8
|
+
export declare function sunHourAngle(ms: number, observer: Observer): number;
|
|
9
|
+
/** The instant nearest to `ms` when the Sun's hour angle is `target` degrees (0 noon, 180 midnight), by Newton steps on the Sun's turn of about 360 degrees a day. */
|
|
10
|
+
export declare function nearestHourAngle(ms: number, observer: Observer, target: number): number;
|
|
11
|
+
/** The zero crossings of `f` in [start, end), as [instant, true when f goes up], found by sampling every `step` milliseconds and bisecting each bracket to about a tenth of a second. */
|
|
12
|
+
export declare function crossings(f: (ms: number) => number, start: number, end: number, step: number): Array<[number, boolean]>;
|
|
13
|
+
/** The height of the horizon below level for an observer `height` metres up, in degrees (the dip, with the refraction along it). */
|
|
14
|
+
export declare const dip: (heightM: number) => number;
|
|
15
|
+
/** The Sun's times of a day: when it crosses each row's altitude going up and going down, with solar noon and the solar midnight that leads into it. */
|
|
16
|
+
export interface SunDay {
|
|
17
|
+
noon: number;
|
|
18
|
+
nadir: number;
|
|
19
|
+
/** For each row `[angle, morningName, eveningName]`: the instants, or null for one that does not happen in the window. */
|
|
20
|
+
events: Map<string, number | null>;
|
|
21
|
+
alwaysUp: boolean;
|
|
22
|
+
alwaysDown: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The Sun's day at a place: `utcOffset` in minutes east of UTC picks the local calendar day holding `ms`, and `undefined` the solar day (one solar midnight to the next).
|
|
26
|
+
* A row at the horizon (between -1 and 0 degrees) is lowered by the dip of the horizon for an observer `heightM` metres up.
|
|
27
|
+
*/
|
|
28
|
+
export declare function sunDay(ms: number, observer: Observer, utcOffset: number | undefined, rows: ReadonlyArray<readonly [number, string, string]>): SunDay;
|
|
29
|
+
/** The Moon between two instants at a place: rise and set (the upper limb at the horizon through 34 arc-minutes of refraction), the upper and lower meridian crossings, and whether it stays up or down. */
|
|
30
|
+
export declare function moonDay(start: number, end: number, observer: Observer): {
|
|
31
|
+
rise: number | null;
|
|
32
|
+
set: number | null;
|
|
33
|
+
transit: number | null;
|
|
34
|
+
lowerTransit: number | null;
|
|
35
|
+
alwaysUp: boolean;
|
|
36
|
+
alwaysDown: boolean;
|
|
37
|
+
};
|