@johnmorrisdotca/wakusei-planets 0.20.0 → 0.22.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 +17 -0
- package/NOTICE.md +27 -1
- package/README.md +36 -6
- package/dist/bodies/earth.js +13 -5
- package/dist/calendar.js +7 -6
- package/dist/clock.js +5 -6
- package/dist/coordinates.d.ts +7 -12
- package/dist/coordinates.js +19 -18
- 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/galilean.d.ts +15 -0
- package/dist/data/galilean.js +7 -0
- package/dist/data/orbits.js +25 -25
- package/dist/data/stars.d.ts +4 -0
- package/dist/data/stars.js +5088 -0
- package/dist/data/tass17.d.ts +17 -0
- package/dist/data/tass17.js +10 -0
- package/dist/data/theories.d.ts +64 -0
- package/dist/data/theories.js +70 -0
- package/dist/data/vsop.js +2 -2
- package/dist/element.d.ts +3 -24
- package/dist/element.js +92 -112
- package/dist/ephemeris.d.ts +20 -0
- package/dist/ephemeris.js +57 -22
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/portrait/element.d.ts +1 -0
- package/dist/portrait/element.js +27 -39
- 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 +4 -0
- package/dist/sidereal.js +15 -9
- package/dist/sky/engine.d.ts +6 -15
- package/dist/sky/engine.js +9 -38
- 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.js +4 -10
- package/dist/tables/all.d.ts +2 -0
- package/dist/tables/all.js +2 -0
- package/dist/tables/galilean.d.ts +1 -0
- package/dist/tables/galilean.js +4 -0
- package/dist/tables/lazy.d.ts +2 -0
- package/dist/tables/lazy.js +15 -0
- package/dist/tables/saturn-moons.d.ts +1 -0
- package/dist/tables/saturn-moons.js +4 -0
- package/dist/tables/vsop.d.ts +1 -0
- package/dist/tables/vsop.js +11 -0
- package/dist/theories/galilean.d.ts +7 -0
- package/dist/theories/galilean.js +78 -0
- package/dist/theories/tass17.d.ts +7 -0
- package/dist/theories/tass17.js +90 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/when.js +6 -11
- package/package.json +68 -4
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.22.0] - 2026-11-08
|
|
6
|
+
|
|
7
|
+
- **Moons follow published theories, and every planet is measured on 60 dates from 1800 to 2200** (MODULES-528, 511). Io, Europa, Ganymede and Callisto come from L1.2 (Lainey, Duriez and Vienne, IMCCE) and Mimas to Iapetus from TASS1.7 (Vienne and Duriez, IMCCE; the table as Orbiter keeps it, MIT, with its notice in NOTICE.md), as optional entry points `tables/galilean` and `tables/saturn-moons` that `tables` loads and the web component fetches by dynamic import only when it draws Jupiter's or Saturn's moons (its own chunk stays 68 kB gzipped, 68,286 bytes on 0.21.0; `test/lazy-size.test.ts`); on 60 dates Io is 0.11 degree from Horizons (0.19 before), Europa 0.04 (0.15), Ganymede 0.03 (0.36), Callisto 0.014 (0.14), Mimas 1.7 (9.0), Tethys 0.21 (0.61) and Iapetus 0.03 (0.88). The fitted orbits of the other moons now use Horizons for 1800 to 2199 instead of 1950 to 2050 (Phobos 4.0 degrees to 0.4 in 1800, Ariel 1.4 to 0.2, Nereid 13.5 to 4.6). `tables/vsop` is a finer VSOP87B cut (2,581 terms, 32 kB gzipped, not in `tables`): every planet within 2 arc-seconds of Horizons on 60 dates; the default cut stays 13.8 kB and Jupiter and Neptune have their drift from DE441 taken out (Neptune 5.7 to 2.6 arc-seconds). New `test/accuracy-dense.test.ts`, `test/accuracy-fine.test.ts`, `test/moon-theories.test.ts` (the two ports reproduce IMCCE's published check values), `scripts/fetch-horizons-dense.py`, `scripts/compare/dense.mjs`; the accuracy limits only went down. A bundle of every export and optional table is 76,978 bytes gzipped, 11,318 more. GUST86 and ESAPHO/ESADEI are not used: their notice forbids passing on changed files.
|
|
8
|
+
|
|
9
|
+
## [0.21.0] - 2026-11-08
|
|
10
|
+
|
|
11
|
+
- **`/spacecraft`: famous spacecraft, where they are and their whole voyage** (MODULES-622). Ten craft: Voyager 1 and 2, New Horizons, Pioneer 10 and 11, Cassini, Galileo, Juno, Parker Solar Probe and the James Webb Space Telescope. Each path is a Chebyshev table fitted to JPL Horizons over the whole of Horizons' own record of the craft (`scripts/make-spacecraft-data.py`, `src/craft/<craft>.ts`; segments from seconds near a planet to years in cruise, limit 1,000 km near a planet and a millionth of the distance from the Sun elsewhere, measured worst 570 to 840 km for the orbiters, Parker and Webb, 7,000 to 26,000 km in deep cruise), loaded on demand (`loadSpacecraft`; 2 to 5 kB gzipped each, Galileo 25, Parker 27, Juno 77, Cassini 127). `spacecraftPosition` (km from the Sun, J2000 ecliptic), `spacecraftVelocity`, `spacecraftSpeed`, `spacecraftSunDistance`, `spacecraftEarthDistance`, `spacecraftLightTime` and `spacecraftErrorKm`, with `SPACECRAFT`: names in English and Japanese, launch, agency, status, NASA's page, Horizons' record and its `joins` (where Horizons' own record steps, up to 459,000 km for Pioneer 11), and the voyage's events (launch, 33 flybys and orbit insertions, end) from NASA's mission pages. Every flyby is tested against the closest approach of the fitted path to the body. Where a NASA page and the path disagree the path's date is kept (listed in the guide). Pure, no DOM, no three.js. EN/JA guide `docs/guides/spacecraft.md`.
|
|
12
|
+
- **To scale treats every body the same** (MODULES-621). The Earth was measured against the Sun because a body was never measured against itself, so it showed as a dot with a magnified picture beside it, like a moon. A body measured against itself is now the reference, drawn full size like the planets beside it, and the caption mentions a magnified picture only when there is one (English and Japanese).
|
|
13
|
+
- **Pinch is tested** (MODULES-527): two fingers zoom the demo's view, and on the portrait page a pinch on a body sizes it while a pinch elsewhere zooms; the portrait help says so in both languages.
|
|
14
|
+
- **Why two packages** (MODULES-520): a guide in English and Japanese on this package and chikyu-earth: the rule (the Earth in detail there, every other body and the solar system here, the dependency one way), a table of what lives where, and how each works alone and together; a short README section.
|
|
15
|
+
- **`/earth` builds without chikyu-earth** (MODULES-612). It imported the optional peer `@johnmorrisdotca/chikyu-earth` itself, so a project without it failed to build with esbuild and webpack, and with Vite the line Earth stayed blank in the browser. Now `/earth` never imports it: the Earth's line look is this package's own outline, and chikyu-earth's globe with the countries when the page imports `@johnmorrisdotca/chikyu-earth/element` (add that one line if you relied on `/earth` loading it). A usage check builds `/earth` with chikyu-earth absent and draws it.
|
|
16
|
+
- **`<wakusei-space>` and `/space`: the Earth, the Moon, the Sun and the planets in their places** (MODULES-518, taken over from chikyu-earth's space view). One WebGL context through the shared renderer, a compressed scale and a true one, time forwards and backwards, a zoom from the Earth to the whole solar system, the Moon's phase and the Earth's day side from the real Sun, a body to look at, the planets' orbits, and the nearer moons round a planet; positions are this package's own VSOP87B, Pluto and ELP2000 models (the Sun and the Moon within a hundredth of a degree and the planets within a few hundredths of astronomy-engine, the test oracle). The pure maths (`frameAt`, `createTrack`, `placeSun`, `placeAround`, `radiusIn`, `groundDirection`) is in `/space`. A day a second draws 29 frames a second and looks the sky up twice a second.
|
|
17
|
+
- **Riding along, for any body** (MODULES-518). `space.ride(target)` puts the camera at the Moon, a planet, a moon of a planet (`io` over Jupiter) or any moving point of your own (`{ at(ms) }`: position and velocity from the centre of the body it goes round) and looks at that body, straight down or at the horizon; a drag looks about, a switch glides, a point that cannot be placed is reported once, and it draws only as often as the picture moves a pixel. `ridePose` (in `/space`) takes the radius of the body it goes round, so it is not tied to the Earth; it knows no satellites, so chikyu-earth can ride one through it.
|
|
18
|
+
- **Rise and set times measured against JPL Horizons** (MODULES-561). Six places from the equator to 70 degrees north, seven days from 2000 to 2040, the same definition for every package: this package is within 0.4 s for the Sun and the Moon, astronomy-engine 0.5 s and 1.4 s, suncalc 2.1.2 5.3 s and 7.1 s. The `/suncalc` guide's table now says so, and the source no longer claims suncalc is a minute or two off. `pnpm test` holds this package to 1 s; `scripts/compare/rise-set.mjs` measures all three.
|
|
19
|
+
- **The scientific core and the drawing code are cleaned up** (MODULES-562; no position, time or picture changes). One mean obliquity, one Greenwich mean sidereal angle and one J2000-ecliptic-to-true-equator-of-date rotation (`src/sky/frames.ts`) shared by `/coordinates`, `/time` and the sky engine; one `Observer` and one set of angle types (`src/sky/types.ts`); offsets validated once; the shaded looks share the texture paths, picture loading, matrix writes and the fallback look. Height in an observer is documented as above the WGS 84 ellipsoid. New `heliocentricModel(planet, ms)`: the theory that answers `heliocentric` for that body and moment with the tables loaded now, and the fitted table's measured worst error.
|
|
20
|
+
- **`/stars`: the stars you can see without a telescope** (MODULES-571, part of MODULES-539). The 5,080 stars to visual magnitude 6.0 of the Yale Bright Star Catalogue (Hoffleit and Warren 1991, credited in NOTICE.md), brightest first, with IAU names for 111 of them: `stars`, `starByHr`, `starByName`, `starPosition` (proper motion, straight line, J2000 frame), `starDistanceLightYears`, `starTemperatureK`, `blackBodyColour` and `starColour`. A separate entry point of about 100 kB gzipped that nothing else imports. Positions are tested against published values to the catalogue's 0.1 second of time and 1 arc-second, the counts by magnitude, proper motion over a century and the colour of the hot and cool ends. The data comes from Yale rather than Hipparcos because ESA's catalogues are non-commercial (CC BY-NC) and could not be passed on under the MIT licence. EN/JA guide `docs/guides/stars.md`.
|
|
21
|
+
|
|
5
22
|
## [0.20.0] - 2026-11-07
|
|
6
23
|
|
|
7
24
|
- **`/time` is the whole clock** (MODULES-538). The `julian` package's functions under the same names (`julian`, `toDate`, `toJulianDay`, `toMillisecondsInJulianDay`, `fromJulianDayAndMilliseconds`; julian truncates toward zero before 31 December 1969 and gives a day one too high, these floor); `julianCenturies`, `julianMillennia` and the epochs (`J2000_JD`, `J2000_MS`, `B1950_JD`); the Gregorian and Julian calendars (`toCalendar`, `fromCalendar`, `dayOfWeek`, `dayOfYear`, `daysInMonth`, `isLeapYear`, the switch of 1582, astronomical years, the whole range of a Date); time scales UTC, UT1, TAI, GPS, TT and TDB (`convertTimeScale`, `taiMinusUtc`, `deltaT`, `tdbMinusTt`) with the leap seconds from 1972; sidereal time (`greenwichMeanSiderealTime`, `greenwichApparentSiderealTime`, `localSiderealTime`, `equationOfTheEquinoxes`); and Mars time (`marsSolDate`, `coordinatedMarsTime`, `marsLocalMeanSolarTime`). Every function takes a `Date` or milliseconds, never changes a `Date` and throws on an invalid one. About 3 kB gzipped, no dependencies. Tests: Meeus's worked examples (chapters 7 and 12), the julian package and astronomy-engine as dev-only oracles, round trips over the years -5000 to 5000 and the ends of a Date, every pair of time scales from 1800 to 2200. EN/JA guide `docs/guides/time.md`.
|
package/NOTICE.md
CHANGED
|
@@ -11,9 +11,13 @@ No picture is used by the line and shaded looks: they are drawn from numbers.
|
|
|
11
11
|
- **Time scales**: the leap seconds are IERS Bulletin C; delta T before 1972 is the polynomials of F. Espenak and J. Meeus (NASA, https://eclipse.gsfc.nasa.gov/SEhelp/deltatpoly2004.html), in `src/time.ts`.
|
|
12
12
|
- **Calendars, sidereal time and Mars time (`/time`)**: written here from J. Meeus, "Astronomical Algorithms" (2nd edition, chapters 7 and 12: the Julian day and the sidereal time), the Richards day-number algorithm for the calendars, M. Allison and M. McEwen, "A post-Pathfinder evaluation of aerocentric solar coordinates with improved timing recipes for Mars seasonal/diurnal climate studies", Planetary and Space Science 48, 215 (2000), and Meeus's two-term formula for TDB minus TT. The names of the Julian-date functions follow the `julian` package (MIT, Stepan Stolyarov), whose code is not used; `julian` 0.2.0 and astronomy-engine are development-time comparisons in `test/calendar.test.ts` only and are not shipped.
|
|
13
13
|
- **Pluto's position**: a Chebyshev table (`src/data/pluto.ts`, made by `scripts/make-pluto-data.py`) fitted to JPL Horizons (https://ssd.jpl.nasa.gov/api/horizons.api, read 2026-11-07), 1800 to 2200; outside those years, and for its earlier edition, JPL Solar System Dynamics, "Keplerian Elements for Approximate Positions of the Major Planets", Table 1, 1800 AD to 2050 AD (https://ssd.jpl.nasa.gov/planets/approx_pos.html, read 2026-11-02; Pluto from the same page's earlier edition). NASA/JPL content is not subject to copyright in the United States; credit: NASA/JPL-Caltech.
|
|
14
|
-
- **Moons' orbits**: fitted to the positions and velocities of JPL Horizons (https://ssd.jpl.nasa.gov/api/horizons.api, read 2026-11-07) for
|
|
14
|
+
- **Moons' orbits**: fitted to the positions and velocities of JPL Horizons (https://ssd.jpl.nasa.gov/api/horizons.api, read 2026-11-07) for 1800 to 2199, by `scripts/make-moon-data.py`, which writes `src/data/orbits.ts`; the Moon's row, and the pole of each moon's reference plane, are from JPL Solar System Dynamics, "Planetary Satellite Mean Elements" (https://ssd.jpl.nasa.gov/sats/elem/, read 2026-11-02). The positions the accuracy test compares with are in `test/data/horizons.json`, fetched by `scripts/fetch-horizons-reference.py`. Credit: NASA/JPL-Caltech; the satellite ephemerides behind Horizons are R. A. Jacobson and colleagues' (the page names each).
|
|
15
15
|
- **The Moon's position**: the lunar solution ELP2000-82B, M. Chapront-Touzé and J. Chapront, "The lunar ephemeris ELP 2000", Astron. Astrophys. 124, 50 (1983) and "ELP 2000-85", Astron. Astrophys. 190, 342 (1988), from IMCCE, Observatoire de Paris (https://ftp.imcce.fr/pub/ephem/moon/elp82b/). Its 37,872 terms are cut to the 540 above 0.05 arc-seconds (`scripts/make-lunar-data.py`, `src/data/lunar.ts`) and written out as numbers, with the constants fitted to JPL's DE200 that the notice gives. IMCCE's files carry no licence text; they are published for use with the credit above (the same footing as VSOP87).
|
|
16
|
+
- **Jupiter's four big moons (`tables/galilean`)**: the theory L1.2, V. Lainey, L. Duriez and A. Vienne (2006), "Synthetic representation of the Galilean satellites' orbital motions from L1 ephemerides", Astron. Astrophys. 456, 783, from the series `BisL1.2.dat` that IMCCE, Observatoire de Paris publishes (https://ftp.imcce.fr/pub/ephem/satel/galilean/L1/L1.2/, read 2026-11-08), cut to 140 terms (`scripts/make-galilean-data.py`, `src/data/galilean.ts`; the arrangement of `src/theories/galilean.ts` follows IMCCE's `L1.2.f` and is checked against its `TestL1.2.res`). The README of that directory states no licence; the numbers are a published scientific table, credited here.
|
|
17
|
+
- **Saturn's seven inner moons (`tables/saturn-moons`)**: the theory TASS1.7, A. Vienne and L. Duriez (1995), "TASS1.6: Ephemerides of the major Saturnian satellites", Astron. Astrophys. 297, 588, from IMCCE (https://ftp.imcce.fr/pub/ephem/satel/tass17/). The terms are read from `Src/Celbody/Satsat/tass17.dat` in Orbiter (https://github.com/orbitersim/orbiter, read 2026-11-08), the same table in one plain file, MIT licence: Copyright (c) 2000-2026 Martin Schweiger. The MIT notice of Orbiter follows. Cut to 316 terms (`scripts/make-tass17-data.py`, `src/data/tass17.ts`); `src/theories/tass17.ts` follows Orbiter's `Tass17.cpp` (a conversion of IMCCE's FORTRAN) and is checked against the values in IMCCE's `tass17.f`.
|
|
18
|
+
- **The Uranus, Mars and Neptune systems' moons** are still fitted to Horizons. IMCCE's GUST86 (Laskar and Jacobson 1987) and ESAPHO/ESADEI (Chapront-Touzé 1990) come with a notice that forbids redistributing changed files, so they are not used; nothing of them is in this package.
|
|
16
19
|
- **Sun and Moon times (`/suncalc`)**: written here from the standard methods: J. Meeus, "Astronomical Algorithms" (2nd edition, chapters 11, 12, 21, 22, 48), the IAU 1976 precession, the IAU 1980 nutation (its largest terms), Saemundsson's refraction formula, and the Naval Observatory's convention for the rise and set of the Moon and Sun. The names, arguments and results follow the public interface of suncalc (BSD-2-Clause, Copyright (c) Volodymyr Agafonkin; https://github.com/mourner/suncalc), whose code is not used. suncalc 1.9.0 and 2.1.2 and astronomy-engine (MIT) are development-time comparisons in `test/suncalc.test.ts` only and are not shipped.
|
|
20
|
+
- **Stars (`/stars`)**: the Yale Bright Star Catalogue, D. Hoffleit and W. H. Warren Jr. (1991), "The Bright Star Catalogue, 5th Revised Edition (Preliminary Version)", Astronomical Data Center (NASA Goddard Space Flight Center) and the Centre de Données astronomiques de Strasbourg, catalogue V/50, as NASA's HEASARC serves it (table bsc5p, https://heasarc.gsfc.nasa.gov/W3Browse/star-catalog/bsc5p.html, file heasarc_bsc5p.tdat.gz, read 2026-11-08; a US government source), the 5,080 stars to visual magnitude 6.0, written out as numbers by `scripts/make-star-data.py` into `src/data/stars.ts`. The catalogue's own documentation calls it public domain and the Astronomical Data Center asks that it and the authors be acknowledged, which this line does; there is no formal licence text, so this footing is informal. The common names are our own list after the IAU Working Group on Star Names (https://www.iau.org/science/scientific_bodies/working_groups/280/); the star colour is Ballesteros's B-V to temperature relation (F. J. Ballesteros 2012, EPL 97, 34008) and a piecewise black-body colour fit. Deliberately NOT used: the Hipparcos, Tycho and Gaia catalogues (ESA, CC BY-NC 3.0 IGO, non-commercial), and HYG, AT-HYG and OpenNGC (CC BY-SA, which would put share-alike terms on this package's data).
|
|
17
21
|
- **Mass and escape speed** (`JOURNEY_STOPS`): JPL "Planetary Satellite Physical Parameters" (https://ssd.jpl.nasa.gov/sats/phys_par/, read 2026-11-04) for the GM of the Earth, Mars through Pluto and the moons on that page; NASA's Sun, Mercury and Venus fact sheets (https://nssdc.gsfc.nasa.gov/planetary/factsheet/, read 2026-11-04) for those three GM values and the Sun's escape speed; JPL "Planetary Physical Parameters" (https://ssd.jpl.nasa.gov/planets/phys_par.html, read 2026-11-04) for the planets' escape speeds and for the masses of Ceres, Eris, Makemake and Haumea, turned into GM with the CODATA 2018 G that page names. A moon's escape speed is computed from its GM and the radius already in this package. Nereid, Orcus, Quaoar, Gonggong, Sedna, Vanth, Hiʻiaka, Namaka and Dysnomia are left blank: those pages do not print a mass.
|
|
18
22
|
|
|
19
23
|
## The dwarf planets
|
|
@@ -27,6 +31,14 @@ Ceres, Orcus, Haumea, Quaoar, Makemake, Gonggong, Eris and Sedna (Pluto is with
|
|
|
27
31
|
|
|
28
32
|
The tests compare the Galilean moons and four planets with astronomy-engine (MIT, https://github.com/cosinekitty/astronomy), a development dependency that is never shipped.
|
|
29
33
|
|
|
34
|
+
## The spacecraft
|
|
35
|
+
|
|
36
|
+
Voyager 1 and 2, New Horizons, Pioneer 10 and 11, Cassini, Galileo, Juno, Parker Solar Probe and the James Webb Space Telescope. Values read on 2026-11-08. NASA content is not subject to copyright in the United States; credit: NASA/JPL-Caltech. This package is not endorsed by NASA and uses none of its insignia.
|
|
37
|
+
|
|
38
|
+
- **Where they are**: JPL Horizons (https://ssd.jpl.nasa.gov/api/horizons.api, read 2026-11-08), VECTORS, heliocentric, ecliptic and equinox J2000, over the whole of each craft's own record (its start and stop are the ones Horizons gives), fitted as Chebyshev tables by `scripts/make-spacecraft-data.py` (`src/craft/<craft>.ts`). The positions the tests compare with are in `test/data/spacecraft-horizons.json`. Horizons' paths after today are predictions.
|
|
39
|
+
- **Facts and events**: NASA mission pages, read 2026-11-08: Voyager 1 (https://science.nasa.gov/mission/voyager/voyager-1/), Voyager 2 (https://science.nasa.gov/mission/voyager/voyager-2/), New Horizons (https://science.nasa.gov/mission/new-horizons/), Pioneer 10 (https://science.nasa.gov/mission/pioneer-10/), Pioneer 11 (https://science.nasa.gov/mission/pioneer-11/), Cassini (https://science.nasa.gov/mission/cassini/ and its timeline, https://science.nasa.gov/mission/cassini/the-journey/timeline/), Galileo (https://science.nasa.gov/mission/galileo/), Juno (https://science.nasa.gov/mission/juno/ and the NSSDCA record 2011-040A, https://nssdc.gsfc.nasa.gov/nmc/spacecraft/display.action?id=2011-040A), Parker Solar Probe (https://science.nasa.gov/mission/parker-solar-probe/ and the NSSDCA record 2018-065A, https://nssdc.gsfc.nasa.gov/nmc/spacecraft/display.action?id=2018-065A) and the James Webb Space Telescope (https://science.nasa.gov/mission/webb/ and https://science.nasa.gov/mission/webb/launch/). A time is given only where a page gives one. Where a page's date for a flyby disagrees with the closest approach of Horizons' path, the package keeps the date of the path (listed in the guide).
|
|
40
|
+
- **Japanese names** are the usual Japanese spellings of the missions' names.
|
|
41
|
+
|
|
30
42
|
## The Earth
|
|
31
43
|
|
|
32
44
|
The Earth's line drawing is chikyu-earth's own globe (MIT, by John Morris; https://github.com/johnmorrisdotca/chikyu-earth), an optional peer dependency: its own NOTICE.md has the terms of its outlines. The Earth's realistic and painted looks are drawn here, like every other body, from NASA's Blue Marble picture (below).
|
|
@@ -69,3 +81,17 @@ Venus, Saturn, Neptune and the Sun were replaced from Solar System Scope's equir
|
|
|
69
81
|
| `saturn-ring-2048.webp` | Saturn's rings | [Saturn's rings in visible light and radio.jpg](https://commons.wikimedia.org/wiki/File:Saturn's_rings_in_visible_light_and_radio.jpg) | Public domain | NASA / JPL / Space Science Institute | Cassini's natural-colour mosaic of the lit rings (PIA07874, from PIA06175), read along one radius into a strip of 2048 colours and opacities from 74,794 to 137,035 km. The radii are fitted to five edges the picture shows (the B ring's inner edge, the two edges of the Cassini Division, the Encke gap and the A ring's outer edge), each within 300 km. The opacity is taken from the brightness, and the colour balance is moved to match the Saturn portrait above; the F ring and the D ring are not in the picture |
|
|
70
82
|
|
|
71
83
|
The package does not ship the 2048 pixel widths: `TEXTURE_FAR_BASE` fetches them from this repository by jsDelivr's GitHub address when a view is zoomed in. The 512 and 1024 pixel widths of every picture, and the ring strip, are 1.94 MB in the package (the nine of 0.2.0 were 0.53 MB; Ceres adds 0.13 MB and Tethys, Dione, Iapetus, Triton and Charon 0.45 MB). Where a source does not say where its map is centred, its row says what the picture was matched to.
|
|
84
|
+
|
|
85
|
+
## Orbiter's MIT notice
|
|
86
|
+
|
|
87
|
+
The TASS1.7 table above was read from Orbiter (https://github.com/orbitersim/orbiter), whose licence is:
|
|
88
|
+
|
|
89
|
+
> MIT License
|
|
90
|
+
>
|
|
91
|
+
> Copyright (c) 2000-2026 Martin Schweiger
|
|
92
|
+
>
|
|
93
|
+
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
94
|
+
>
|
|
95
|
+
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
96
|
+
>
|
|
97
|
+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
<p align="center"><strong>The Sun, the planets and their moons, for the web.</strong><br>
|
|
6
6
|
A clean line drawing, a shaded realistic drawing, or a painted surface map, with each body's real size, axial tilt and rotation as data, and a planet's moons where they are at any date and time.</p>
|
|
7
7
|
|
|
8
|
+
<p align="center">Part of <strong>SpaceProgramX (SPX)</strong>, the space packages: <a href="https://github.com/johnmorrisdotca/wakusei-planets">Wakusei Planets</a> · <a href="https://github.com/johnmorrisdotca/hoshi-stars">Hoshi Stars</a> · <a href="https://github.com/johnmorrisdotca/chikyu-earth">Chikyu Earth</a> · <a href="https://github.com/johnmorrisdotca/uchusen-rockets">Uchusen Rockets</a></p>
|
|
9
|
+
|
|
8
10
|
<p align="center">
|
|
9
11
|
<a href="https://github.com/johnmorrisdotca/wakusei-planets/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/johnmorrisdotca/wakusei-planets/actions/workflows/ci.yml/badge.svg"></a>
|
|
10
12
|
<a href="./LICENSE"><img alt="MIT licence" src="https://img.shields.io/badge/licence-MIT-2f5d4a"></a>
|
|
@@ -13,9 +15,9 @@ A clean line drawing, a shaded realistic drawing, or a painted surface map, with
|
|
|
13
15
|
|
|
14
16
|
<p align="center"><a href="https://johnmorrisdotca.github.io/wakusei-planets/"><strong>Open the demo →</strong></a> · <a href="https://johnmorrisdotca.github.io/wakusei-planets/embed.html">Embed page</a> · <a href="https://johnmorrisdotca.github.io/wakusei-planets/docs/">Docs</a></p>
|
|
15
17
|
|
|
16
|
-
<p align="center"><img alt="Jupiter and Saturn drawn in the realistic look, and Saturn as a line drawing" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.
|
|
18
|
+
<p align="center"><img alt="Jupiter and Saturn drawn in the realistic look, and Saturn as a line drawing" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.22.0/docs/images/hero-desk.png" width="640"></p>
|
|
17
19
|
|
|
18
|
-
<p align="center"><img alt="Every body at one scale, the Earth among them: each small body has a magnified picture joined by a line, and the Sun shows only its edge" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.
|
|
20
|
+
<p align="center"><img alt="Every body at one scale, the Earth among them: each small body has a magnified picture joined by a line, and the Sun shows only its edge" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.22.0/docs/images/lineup-desk.png" width="640"></p>
|
|
19
21
|
|
|
20
22
|
## One minute
|
|
21
23
|
|
|
@@ -111,6 +113,10 @@ Import the element once in client code, and the entry point of each body you dra
|
|
|
111
113
|
|
|
112
114
|
Every body has its real size relative to the others (`scale-to="jupiter"`), its axial tilt and its rotation. The Sun, Mercury, Venus, Mars, Jupiter, Saturn, Uranus, Neptune and Pluto are drawn, and so are the eight other dwarf planets (Ceres, Orcus, Haumea, Quaoar, Makemake, Gonggong, Eris and Sedna; Haumea and Quaoar as the long shapes they are, and Ceres with a painted map from Dawn) and 29 moons (the Moon, Phobos and Deimos, the four Galilean moons, Saturn's seven larger moons, Uranus's five, Proteus, Triton and Nereid, Charon, Nix and Hydra, and Vanth, Hiʻiaka, Namaka and Dysnomia, the moons of the dwarf planets whose orbits are published with a date). The Earth is drawn like the rest in the realistic and painted looks (NASA's Blue Marble), and its line look is [chikyu-earth](https://github.com/johnmorrisdotca/chikyu-earth)'s own globe: `import "@johnmorrisdotca/wakusei-planets/earth"` (it needs `@johnmorrisdotca/chikyu-earth` 0.10.0 or later installed). The painted looks cover the Sun, the planets from Mercury to Earth and Pluto, Ceres, the Moon, the four Galilean moons, Saturn's Mimas, Enceladus, Tethys, Dione, Rhea, Titan and Iapetus, Triton and Charon, and Saturn's rings are Cassini's own picture of them.
|
|
113
115
|
|
|
116
|
+
## Two packages: this one and chikyu-earth
|
|
117
|
+
|
|
118
|
+
This package is the Sun, the planets, the dwarf planets and the moons, and where they are. [chikyu-earth](https://github.com/johnmorrisdotca/chikyu-earth) is the Earth in detail: its countries, day and night, places and satellites. Each works alone; install both and the Earth's line look becomes chikyu-earth's globe with the countries. The dependency runs one way: this package may use chikyu-earth, never the reverse. [Why two packages](docs/guides/two-packages.md) has the rule, a table of what lives where and how to use them together.
|
|
119
|
+
|
|
114
120
|
## As the Earth sees it
|
|
115
121
|
|
|
116
122
|
Give a body a `time` and it is drawn as the sky shows it then: its pole and rotation, how far the rings are open (Saturn's rings are edge-on in March 2025), the phase of the Moon or Venus, the Sun's direction.
|
|
@@ -176,7 +182,7 @@ The pure side has no DOM: `BODIES`, `apparent(id, time)`, `system(planet, time)`
|
|
|
176
182
|
|
|
177
183
|
## The data
|
|
178
184
|
|
|
179
|
-
Sizes, flattening, poles and rotation are the IAU's and NASA's; Mercury to Neptune are VSOP87B, cut down, and Pluto is a table fitted to Horizons; the Moon's are the lunar solution ELP2000-82B cut down;
|
|
185
|
+
Sizes, flattening, poles and rotation are the IAU's and NASA's; Mercury to Neptune are VSOP87B, cut down, and Pluto is a table fitted to Horizons; the Moon's are the lunar solution ELP2000-82B cut down; Jupiter's four big moons are the theory L1.2 and Saturn's seven inner ones TASS1.7, and the others are fitted to JPL Horizons' positions, and every body is tested against Horizons ([accuracy](docs/guides/accuracy.md)). Nothing is fetched at run time by the line and shaded looks, which use no pictures. See [NOTICE.md](NOTICE.md).
|
|
180
186
|
|
|
181
187
|
## Examples
|
|
182
188
|
|
|
@@ -273,7 +279,7 @@ A body that turns by itself and a moving sky, in HTML:
|
|
|
273
279
|
|
|
274
280
|
## The portrait builder
|
|
275
281
|
|
|
276
|
-
<p align="center"><img alt="The Sun and the planets in an arc, painted, with their names, in the portrait builder" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.
|
|
282
|
+
<p align="center"><img alt="The Sun and the planets in an arc, painted, with their names, in the portrait builder" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.22.0/docs/images/portrait-family.png" width="640"></p>
|
|
277
283
|
|
|
278
284
|
[The portrait builder](https://johnmorrisdotca.github.io/wakusei-planets/portrait.html) puts any bodies in one picture: drag them, size them, turn them, order them front to back, arrange them in a row, an arc, a grid or at true orbit distance (true or readable sizes, a planet's moons round it in orbit order), light them from one direction, and take the code, a PNG or an SVG. The scene is kept in the address, and every body is drawn in one WebGL scene, so the page holds one WebGL context. [The portrait builder](docs/guides/portrait-builder.md) is its guide.
|
|
279
285
|
|
|
@@ -284,6 +290,23 @@ A body that turns by itself and a moving sky, in HTML:
|
|
|
284
290
|
<wakusei-portrait scene="look:painted~jupiter_0_0_0.3_0~io_0_0_0.1_0"></wakusei-portrait>
|
|
285
291
|
```
|
|
286
292
|
|
|
293
|
+
## The space view
|
|
294
|
+
|
|
295
|
+
[The space view](https://johnmorrisdotca.github.io/wakusei-planets/space.html) puts the Earth, the Moon, the Sun and the planets in their places for any date and time, in one WebGL context: the Moon's phase and the Earth's day side come out of the real Sun's light. Zoom from the Earth out to the whole solar system, in a compressed scale (every direction real, the distances squeezed) or the true one, and run time forwards or backwards. Positions come from this package's own models.
|
|
296
|
+
|
|
297
|
+
```html
|
|
298
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/@johnmorrisdotca/wakusei-planets/space/element/+esm"></script>
|
|
299
|
+
|
|
300
|
+
<wakusei-space time="2026-11-02T14:00Z" speed="0"></wakusei-space>
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
```ts
|
|
304
|
+
import { frameAt } from "@johnmorrisdotca/wakusei-planets/space";
|
|
305
|
+
|
|
306
|
+
const frame = frameAt(Date.UTC(2026, 10, 2, 14));
|
|
307
|
+
console.log(Math.hypot(...frame.sun).toFixed(3), "au to the Sun");
|
|
308
|
+
```
|
|
309
|
+
|
|
287
310
|
## API
|
|
288
311
|
|
|
289
312
|
The reference is a site, made from the source's own doc comments: every export has a summary, its parameters, what it returns and an example that runs when the site is built. [Open the reference](https://johnmorrisdotca.github.io/wakusei-planets/docs/).
|
|
@@ -293,6 +316,8 @@ The reference is a site, made from the source's own doc comments: every export h
|
|
|
293
316
|
| `@johnmorrisdotca/wakusei-planets` | The pure side: `BODIES`, `apparent`, `system`, `orbitPath`, `portrait`, `lineSvg`, `embedCode`. No browser. |
|
|
294
317
|
| `.../element` | `<wakusei-body>`; three.js is loaded only for a shaded look. |
|
|
295
318
|
| `.../portrait` | `<wakusei-portrait>`: many bodies in one scene. The scene model (`addBody`, `layoutPortrait`, `encodeScene`, `decodeScene`) is in the main entry. |
|
|
319
|
+
| `.../space` | Where the Sun, the Moon and the planets are for a date, in two scales, and where a camera riding along looks: `frameAt`, `createTrack`, `placeSun`, `placeAround`, `ridePose`. No browser. |
|
|
320
|
+
| `.../space/element` | `<wakusei-space>`: the Earth, the Moon, the Sun and the planets in their places. |
|
|
296
321
|
| `.../look` | What a body needs to be drawn with three.js. |
|
|
297
322
|
| `.../painter` | The bodies as objects for a scene of your own. |
|
|
298
323
|
| `.../all` | Every body's shaded look, at once. |
|
|
@@ -318,10 +343,15 @@ Each guide has a Japanese twin in [docs/guides/ja](docs/guides/ja/getting-starte
|
|
|
318
343
|
| [Put it in your page](docs/guides/put-it-in-your-page.md) | Set up a body and copy the code |
|
|
319
344
|
| [The portrait builder](docs/guides/portrait-builder.md) | Many bodies in one picture |
|
|
320
345
|
| [Looks and bodies](docs/guides/looks-and-bodies.md) | The looks and each body's entry point |
|
|
346
|
+
| [Why two packages](docs/guides/two-packages.md) | This package and chikyu-earth: which to install, alone or together |
|
|
321
347
|
| [Moons and time](docs/guides/moons-and-time.md) | The sky on a date, time that runs fast |
|
|
348
|
+
| [The space view](docs/guides/space-view.md) | The Earth, Moon, Sun and planets in their places; two scales; time both ways |
|
|
349
|
+
| [Riding along](docs/guides/ride-along.md) | The camera on a moon, a planet or any moving point, looking at what it goes round |
|
|
322
350
|
| [Accuracy](docs/guides/accuracy.md) | How far each body is from JPL Horizons |
|
|
323
351
|
| [In your own three.js scene](docs/guides/in-your-own-scene.md) | `painter.make` |
|
|
324
352
|
| [Time](docs/guides/time.md) | Julian dates, calendars, time scales, sidereal time, Mars time |
|
|
353
|
+
| [The stars you can see without a telescope](docs/guides/stars.md) | 5,080 stars with names, positions, proper motion, distance and colour |
|
|
354
|
+
| [Famous spacecraft](docs/guides/spacecraft.md) | Voyager, New Horizons, Pioneer, Cassini, Galileo, Juno, Parker and Webb: where they are and their whole voyage |
|
|
325
355
|
| [The Sun and Moon from a place](docs/guides/suncalc.md) | Position, sunrise and sunset, Moon rise, set and phase; a drop-in for suncalc |
|
|
326
356
|
| [Coordinate conversions](docs/guides/coordinates.md) | Pure spherical, ecliptic, equatorial and horizontal coordinate conversions |
|
|
327
357
|
| [TypeScript and Node](docs/guides/typescript-and-node.md) | Types and the pure side |
|
|
@@ -338,7 +368,7 @@ import { BODIES } from "@johnmorrisdotca/wakusei-planets";
|
|
|
338
368
|
BODIES.pluto.kind; // "dwarf-planet"
|
|
339
369
|
```
|
|
340
370
|
|
|
341
|
-
- A fact with no source is left out, never guessed. The Moon is within 2 arc-seconds of JPL Horizons, and the
|
|
371
|
+
- A fact with no source is left out, never guessed. The Moon is within 2 arc-seconds of JPL Horizons, and the planets within a few arc-seconds on 60 dates from 1800 to 2200; the moons are within a degree or two on the orbit for almost every moon, about the size of the moon on screen, and Jupiter's four within a few hundredths of a degree; [accuracy](docs/guides/accuracy.md) has each body's number.
|
|
342
372
|
- `realistic` and `painted` are the photo maps (`painted` is the same maps, so an older page still works). `illustrated` is the shaded drawing from the numbers, and it is not a default. Venus, Saturn, Neptune and the Sun use Solar System Scope's maps (CC BY 4.0). Mercury uses the natural grey 8K map (Shady Tex and Solar System Scope, CC BY 4.0). Mars stays on the Viking mosaic, graded toward a butterscotch ochre, with the frost in Hellas toned to the basin and the polar ice left. Jupiter and Uranus use Nestaeric's maps (CC BY 4.0), and Saturn's poles use Nestaeric's caps (CC BY 4.0). The Earth and the Moon stay on their NASA maps until those have been compared. The rest are the public-domain maps in `NOTICE.md`.
|
|
343
373
|
- A shaded look needs WebGL. Without it the line drawing is drawn.
|
|
344
374
|
- Jupiter, Saturn, Uranus and Neptune have their rings drawn.
|
|
@@ -394,7 +424,7 @@ pnpm test:readme # every ts block of the README, type-checked and run against
|
|
|
394
424
|
pnpm test:usage # every way of using it in the README and the guides, built and opened
|
|
395
425
|
pnpm docs:check # the reference site's checks
|
|
396
426
|
pnpm test:demo # the demo and the docs site in a real browser
|
|
397
|
-
pnpm dev # the demo on http://127.0.0.1:
|
|
427
|
+
pnpm dev # the demo on http://127.0.0.1:8225/wakusei-planets/
|
|
398
428
|
```
|
|
399
429
|
|
|
400
430
|
The pictures in `docs/images` are made by the package's own script:
|
package/dist/bodies/earth.js
CHANGED
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
import "./earth-look.js";
|
|
2
|
-
import { delegates } from "../scene/store.js";
|
|
3
|
-
// The Earth's line look is chikyu-earth's own globe with the countries
|
|
4
|
-
// painted looks are drawn here like every other body's (earth-look.ts
|
|
2
|
+
import { delegates, waiting } from "../scene/store.js";
|
|
3
|
+
// The Earth's line look is chikyu-earth's own globe with the countries when the page has it (`import "@johnmorrisdotca/chikyu-earth/element"`), and this package's own outline when it does not.
|
|
4
|
+
// This entry never imports chikyu-earth itself, so a project without that optional peer still builds. The realistic and painted looks are drawn here like every other body's (earth-look.ts).
|
|
5
5
|
const CENTRE = "10,20";
|
|
6
|
+
const TAG = "chikyu-earth";
|
|
6
7
|
delegates.set("earth", {
|
|
7
8
|
async line({ center, size }) {
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
if (customElements.get(TAG) === undefined)
|
|
10
|
+
return null;
|
|
11
|
+
const globe = document.createElement(TAG);
|
|
10
12
|
globe.setAttribute("center", center || CENTRE);
|
|
11
13
|
globe.setAttribute("look", "line");
|
|
12
14
|
globe.setAttribute("size", String(size));
|
|
13
15
|
return globe;
|
|
14
16
|
},
|
|
15
17
|
});
|
|
18
|
+
if (typeof customElements !== "undefined" && customElements.get(TAG) === undefined) {
|
|
19
|
+
void customElements.whenDefined(TAG).then(() => {
|
|
20
|
+
for (const wake of waiting)
|
|
21
|
+
wake();
|
|
22
|
+
});
|
|
23
|
+
}
|
package/dist/calendar.js
CHANGED
|
@@ -7,6 +7,10 @@ const UNIX_DAY_NUMBER = 2_440_588;
|
|
|
7
7
|
/** The Julian day number of 1582-10-15, the first day of the Gregorian calendar. */
|
|
8
8
|
const REFORM_DAY_NUMBER = 2_299_161;
|
|
9
9
|
const floorMod = (a, b) => a - b * Math.floor(a / b);
|
|
10
|
+
function wholeNumber(name, value) {
|
|
11
|
+
if (!Number.isInteger(value))
|
|
12
|
+
throw new RangeError(`${name} must be a whole number, got ${value}`);
|
|
13
|
+
}
|
|
10
14
|
function dayNumberOf(year, month, day, gregorian) {
|
|
11
15
|
const a = Math.floor((14 - month) / 12);
|
|
12
16
|
const y = year + 4800 - a;
|
|
@@ -37,8 +41,7 @@ function dateOfDayNumber(J, gregorian) {
|
|
|
37
41
|
* ```
|
|
38
42
|
*/
|
|
39
43
|
export function isLeapYear(year, calendar = "auto") {
|
|
40
|
-
|
|
41
|
-
throw new RangeError(`year must be a whole number, got ${year}`);
|
|
44
|
+
wholeNumber("year", year);
|
|
42
45
|
const gregorian = calendar === "gregorian" || (calendar === "auto" && year > 1582);
|
|
43
46
|
return floorMod(year, 4) === 0 && (!gregorian || floorMod(year, 100) !== 0 || floorMod(year, 400) === 0);
|
|
44
47
|
}
|
|
@@ -102,18 +105,16 @@ export function toCalendar(when, calendar = "auto") {
|
|
|
102
105
|
export function fromCalendar(civil, calendar = "auto") {
|
|
103
106
|
const { year, month = 1, day = 1, hour = 0, minute = 0, second = 0, millisecond = 0 } = civil;
|
|
104
107
|
for (const [name, value] of Object.entries({ year, month, day, hour, minute, second, millisecond }))
|
|
105
|
-
|
|
106
|
-
throw new RangeError(`${name} must be a whole number, got ${value}`);
|
|
108
|
+
wholeNumber(name, value);
|
|
107
109
|
if (hour < 0 || hour > 23 || minute < 0 || minute > 59 || second < 0 || second > 59 || millisecond < 0 || millisecond > 999)
|
|
108
110
|
throw new RangeError(`the time of day ${hour}:${minute}:${second}.${millisecond} does not exist`);
|
|
109
111
|
if (day < 1 || day > daysInMonth(year, month, calendar))
|
|
110
112
|
throw new RangeError(`${year}-${month}-${day} does not exist in the ${calendar} calendar`);
|
|
111
113
|
let gregorian = calendar === "gregorian";
|
|
112
114
|
if (calendar === "auto") {
|
|
113
|
-
const afterReform = year > 1582 || (year === 1582 && (month > 10 || (month === 10 && day >= 15)));
|
|
114
115
|
if (year === 1582 && month === 10 && day > 4 && day < 15)
|
|
115
116
|
throw new RangeError(`${year}-${month}-${day} does not exist: the calendar skipped 5 to 14 October 1582`);
|
|
116
|
-
gregorian =
|
|
117
|
+
gregorian = year > 1582 || (year === 1582 && (month > 10 || (month === 10 && day >= 15)));
|
|
117
118
|
}
|
|
118
119
|
return (dayNumberOf(year, month, day, gregorian) - UNIX_DAY_NUMBER) * DAY_MS + hour * 3_600_000 + minute * 60_000 + second * 1000 + millisecond;
|
|
119
120
|
}
|
package/dist/clock.js
CHANGED
|
@@ -156,12 +156,11 @@ export function deltaTPolynomial(year) {
|
|
|
156
156
|
*/
|
|
157
157
|
export function ttMinusUtc(when) {
|
|
158
158
|
const ms = moment(when);
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
return taiMinusUtc + TT_MINUS_TAI_SECONDS;
|
|
159
|
+
let i = LEAP_SECONDS.length;
|
|
160
|
+
while (i) {
|
|
161
|
+
const [from, seconds] = LEAP_SECONDS[--i];
|
|
162
|
+
if (ms >= from)
|
|
163
|
+
return seconds + TT_MINUS_TAI_SECONDS;
|
|
165
164
|
}
|
|
166
165
|
return deltaTPolynomial(1970 + ms / YEAR_MS);
|
|
167
166
|
}
|
package/dist/coordinates.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { EquatorialAngles, HorizontalAngles, Observer } from "./sky/types.ts";
|
|
1
2
|
/** Named axes. Of-date axes are mean, not nutated.
|
|
2
3
|
* @example
|
|
3
4
|
* ```ts
|
|
@@ -77,12 +78,10 @@ export interface EclipticCoordinates extends CoordinateContext {
|
|
|
77
78
|
* console.log(value);
|
|
78
79
|
* ```
|
|
79
80
|
*/
|
|
80
|
-
export interface EquatorialCoordinates extends CoordinateContext {
|
|
81
|
+
export interface EquatorialCoordinates extends CoordinateContext, EquatorialAngles {
|
|
81
82
|
frame: "equatorialJ2000" | "equatorialOfDate";
|
|
82
|
-
rightAscension: number;
|
|
83
|
-
declination: number;
|
|
84
83
|
}
|
|
85
|
-
/** Earth observer: degrees north/east; optional metres above
|
|
84
|
+
/** Earth observer: degrees north/east; optional metres above the WGS 84 ellipsoid. Rotations do not use height.
|
|
86
85
|
* @example
|
|
87
86
|
* ```ts
|
|
88
87
|
* import type { CoordinateObserver } from "@johnmorrisdotca/wakusei-planets/coordinates";
|
|
@@ -90,10 +89,8 @@ export interface EquatorialCoordinates extends CoordinateContext {
|
|
|
90
89
|
* console.log(value);
|
|
91
90
|
* ```
|
|
92
91
|
*/
|
|
93
|
-
export interface CoordinateObserver {
|
|
94
|
-
|
|
95
|
-
longitude: number;
|
|
96
|
-
heightM?: number;
|
|
92
|
+
export interface CoordinateObserver extends Observer {
|
|
93
|
+
heightM?: Observer["heightM"];
|
|
97
94
|
}
|
|
98
95
|
/** Geometric horizontal direction. Azimuth is clockwise from north; origin remains that of the supplied direction.
|
|
99
96
|
* @example
|
|
@@ -103,13 +100,11 @@ export interface CoordinateObserver {
|
|
|
103
100
|
* console.log(value);
|
|
104
101
|
* ```
|
|
105
102
|
*/
|
|
106
|
-
export interface HorizontalCoordinates {
|
|
103
|
+
export interface HorizontalCoordinates extends HorizontalAngles {
|
|
107
104
|
origin: CoordinateOrigin;
|
|
108
105
|
frame: "horizontal";
|
|
109
106
|
epoch: number;
|
|
110
107
|
corrections: "geometric";
|
|
111
|
-
altitude: number;
|
|
112
|
-
azimuth: number;
|
|
113
108
|
}
|
|
114
109
|
/** Convert spherical to Cartesian, preserving origin, frame, epoch and geometric corrections. Radius must be positive.
|
|
115
110
|
* @param value - Coordinates with explicit origin, frame, epoch and geometric corrections.
|
|
@@ -164,7 +159,7 @@ export declare function equatorialToEcliptic(value: EquatorialCoordinates): Ecli
|
|
|
164
159
|
/** Rotate a mean equatorial-of-date direction to an observer's horizon (Meeus 12.4, 13.5–6). The input epoch must equal when. UTC approximates UT1; height is validated but unused. No parallax, refraction, nutation or horizon dip. Azimuth at zenith/nadir is conventionally zero.
|
|
165
160
|
* @param value - Mean equatorial-of-date direction with explicit origin and epoch.
|
|
166
161
|
* @param when - Date or Unix UTC milliseconds equal to the input epoch.
|
|
167
|
-
* @param options - Observer in degrees north/east; height in metres above
|
|
162
|
+
* @param options - Observer in degrees north/east; height in metres above the WGS 84 ellipsoid.
|
|
168
163
|
* @returns Altitude and north-based azimuth in degrees; original origin preserved.
|
|
169
164
|
* @example
|
|
170
165
|
* ```ts
|
package/dist/coordinates.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
// Coordinate rotations: Meeus, Astronomical Algorithms, 2nd ed., chapters 12, 13, 22.
|
|
2
2
|
// Standalone mathematics; no body data, ephemerides or rendering dependencies.
|
|
3
3
|
import { ttMinusUtc } from "./clock.js";
|
|
4
|
+
import { meanObliquityArcseconds, meanSiderealDegrees } from "./sidereal.js";
|
|
4
5
|
const RAD = Math.PI / 180;
|
|
5
6
|
const J2000 = 2451545;
|
|
6
7
|
const DAY_MS = 86400000;
|
|
7
8
|
function finite(name, value) {
|
|
8
|
-
if (
|
|
9
|
+
if (!Number.isFinite(value))
|
|
9
10
|
throw new RangeError(`${name}: ${String(value)} must be finite`);
|
|
10
11
|
return value;
|
|
11
12
|
}
|
|
@@ -38,17 +39,17 @@ function context(c) {
|
|
|
38
39
|
throw new RangeError(`epoch: ${c.epoch}; expected Unix milliseconds`);
|
|
39
40
|
instant(c.epoch);
|
|
40
41
|
}
|
|
41
|
-
return { origin: c.origin, frame: c.frame, epoch: c.epoch, corrections:
|
|
42
|
+
return { origin: c.origin, frame: c.frame, epoch: c.epoch, corrections: "geometric" };
|
|
42
43
|
}
|
|
43
|
-
function
|
|
44
|
+
function unitDirection(longitude, latitude) {
|
|
44
45
|
const l = wrap(finite("longitude", longitude)) * RAD;
|
|
45
46
|
const b = bounded("latitude", latitude, -90, 90) * RAD;
|
|
46
47
|
const cb = Math.abs(latitude) === 90 ? 0 : Math.cos(b);
|
|
47
48
|
return [cb * Math.cos(l), cb * Math.sin(l), Math.sin(b)];
|
|
48
49
|
}
|
|
49
|
-
function
|
|
50
|
+
function directionAngles(x, y, z, radius = Math.hypot(x, y, z)) {
|
|
50
51
|
const xy = Math.hypot(x, y);
|
|
51
|
-
return [xy < 1e-15 *
|
|
52
|
+
return [xy < 1e-15 * radius ? 0 : wrap(Math.atan2(y, x) / RAD), Math.atan2(z, xy) / RAD];
|
|
52
53
|
}
|
|
53
54
|
/** Convert spherical to Cartesian, preserving origin, frame, epoch and geometric corrections. Radius must be positive.
|
|
54
55
|
* @param value - Coordinates with explicit origin, frame, epoch and geometric corrections.
|
|
@@ -64,7 +65,7 @@ export function sphericalToCartesian(value) {
|
|
|
64
65
|
const d = finite("distanceAu", value.distanceAu);
|
|
65
66
|
if (d <= 0)
|
|
66
67
|
throw new RangeError(`distanceAu: ${d} must be positive`);
|
|
67
|
-
const [x, y, z] =
|
|
68
|
+
const [x, y, z] = unitDirection(value.longitude, value.latitude);
|
|
68
69
|
return { ...c, xAu: x * d, yAu: y * d, zAu: z * d };
|
|
69
70
|
}
|
|
70
71
|
/** Convert Cartesian to spherical. Zero vectors throw; longitude at either pole is conventionally zero.
|
|
@@ -82,7 +83,7 @@ export function cartesianToSpherical(value) {
|
|
|
82
83
|
const d = finite("distanceAu", Math.hypot(x, y, z));
|
|
83
84
|
if (d === 0)
|
|
84
85
|
throw new RangeError("distanceAu: 0 has no direction");
|
|
85
|
-
const [longitude, latitude] =
|
|
86
|
+
const [longitude, latitude] = directionAngles(x / d, y / d, z / d);
|
|
86
87
|
return { ...c, longitude, latitude, distanceAu: d };
|
|
87
88
|
}
|
|
88
89
|
/** Mean obliquity in degrees: IAU 1980 (Meeus 22.2), evaluated in TT. Validated for 1800–2050; extrapolates outside it.
|
|
@@ -97,10 +98,10 @@ export function cartesianToSpherical(value) {
|
|
|
97
98
|
export function meanObliquity(when) {
|
|
98
99
|
const utc = instant(when);
|
|
99
100
|
const t = ((utc + ttMinusUtc(utc) * 1000) / DAY_MS + 2440587.5 - J2000) / 36525;
|
|
100
|
-
return (
|
|
101
|
+
return meanObliquityArcseconds(t) / 3600;
|
|
101
102
|
}
|
|
102
103
|
function obliquity(c) {
|
|
103
|
-
return (c.epoch === "J2000" ?
|
|
104
|
+
return (c.epoch === "J2000" ? meanObliquityArcseconds(0) / 3600 : meanObliquity(c.epoch)) * RAD;
|
|
104
105
|
}
|
|
105
106
|
/** Rotate a mean ecliptic direction into the matching mean equatorial frame. No precession between epochs, nutation, aberration or light-time is added.
|
|
106
107
|
* @param value - Coordinates with explicit origin, frame, epoch and geometric corrections.
|
|
@@ -115,9 +116,9 @@ export function eclipticToEquatorial(value) {
|
|
|
115
116
|
const c = context(value);
|
|
116
117
|
if (!c.frame.startsWith("ecliptic"))
|
|
117
118
|
throw new RangeError(`frame: ${c.frame}; expected ecliptic`);
|
|
118
|
-
const [x, y, z] =
|
|
119
|
+
const [x, y, z] = unitDirection(value.eclipticLongitude, value.eclipticLatitude);
|
|
119
120
|
const e = obliquity(c);
|
|
120
|
-
const [rightAscension, declination] =
|
|
121
|
+
const [rightAscension, declination] = directionAngles(x, y * Math.cos(e) - z * Math.sin(e), y * Math.sin(e) + z * Math.cos(e));
|
|
121
122
|
return { ...c, frame: c.frame === "eclipticJ2000" ? "equatorialJ2000" : "equatorialOfDate", rightAscension, declination };
|
|
122
123
|
}
|
|
123
124
|
/** Inverse mean-equator rotation, retaining the same origin and epoch.
|
|
@@ -133,15 +134,15 @@ export function equatorialToEcliptic(value) {
|
|
|
133
134
|
const c = context(value);
|
|
134
135
|
if (!c.frame.startsWith("equatorial"))
|
|
135
136
|
throw new RangeError(`frame: ${c.frame}; expected equatorial`);
|
|
136
|
-
const [x, y, z] =
|
|
137
|
+
const [x, y, z] = unitDirection(value.rightAscension, value.declination);
|
|
137
138
|
const e = obliquity(c);
|
|
138
|
-
const [eclipticLongitude, eclipticLatitude] =
|
|
139
|
+
const [eclipticLongitude, eclipticLatitude] = directionAngles(x, y * Math.cos(e) + z * Math.sin(e), -y * Math.sin(e) + z * Math.cos(e));
|
|
139
140
|
return { ...c, frame: c.frame === "equatorialJ2000" ? "eclipticJ2000" : "eclipticOfDate", eclipticLongitude, eclipticLatitude };
|
|
140
141
|
}
|
|
141
142
|
/** Rotate a mean equatorial-of-date direction to an observer's horizon (Meeus 12.4, 13.5–6). The input epoch must equal when. UTC approximates UT1; height is validated but unused. No parallax, refraction, nutation or horizon dip. Azimuth at zenith/nadir is conventionally zero.
|
|
142
143
|
* @param value - Mean equatorial-of-date direction with explicit origin and epoch.
|
|
143
144
|
* @param when - Date or Unix UTC milliseconds equal to the input epoch.
|
|
144
|
-
* @param options - Observer in degrees north/east; height in metres above
|
|
145
|
+
* @param options - Observer in degrees north/east; height in metres above the WGS 84 ellipsoid.
|
|
145
146
|
* @returns Altitude and north-based azimuth in degrees; original origin preserved.
|
|
146
147
|
* @example
|
|
147
148
|
* ```ts
|
|
@@ -159,11 +160,11 @@ export function equatorialToHorizontal(value, when, options) {
|
|
|
159
160
|
finite("observer.heightM", observer.heightM ?? 0);
|
|
160
161
|
const ra = wrap(finite("rightAscension", value.rightAscension));
|
|
161
162
|
const d = bounded("declination", value.declination, -90, 90) * RAD;
|
|
162
|
-
const days = ms / DAY_MS + 2440587.5 - J2000
|
|
163
|
-
const h = wrap(
|
|
163
|
+
const days = ms / DAY_MS + 2440587.5 - J2000;
|
|
164
|
+
const h = wrap(meanSiderealDegrees(days) + l - ra) * RAD;
|
|
164
165
|
const east = -Math.cos(d) * Math.sin(h);
|
|
165
166
|
const north = Math.sin(d) * Math.cos(p) - Math.cos(d) * Math.cos(h) * Math.sin(p);
|
|
166
167
|
const up = Math.sin(d) * Math.sin(p) + Math.cos(d) * Math.cos(h) * Math.cos(p);
|
|
167
|
-
const
|
|
168
|
-
return { origin: c.origin, frame: "horizontal", epoch: ms, corrections: "geometric", altitude
|
|
168
|
+
const [azimuth, altitude] = directionAngles(north, east, up, 1);
|
|
169
|
+
return { origin: c.origin, frame: "horizontal", epoch: ms, corrections: "geometric", altitude, azimuth };
|
|
169
170
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|