Take the orbits at TDB as the spins already were, so a locked moon faces the planet it is drawn round
Every element set here runs on TDB: Standish's T_eph, the SSD satellite and SBDB epochs, the IAU's d and T. bodyOrientation already took the clock's UTC to TDB, but SystemOrbitsRenderer.update and the body page's heliocentricPosition fed the UTC date straight to meanElementsAt, so in one frame each body's place was 69.184 s behind its spin. That is n x 69 s of orbit: Phobos 0.90 degrees, Mimas 0.31, Deimos 0.23, Enceladus 0.21, Miranda 0.20, Io 0.16, Tethys 0.15, Europa 0.08, the Moon 0.011. 48319c3's table measured the app at a UTC date against Horizons at the same number read as TDB, which hid it, and its "nothing for anything else" was wrong: Io's 0.16 is four to five times Io's worst model error there (0.035). tdbFromUtc, in constants.ts, is now the one conversion, and positions and spins both go through it. In the running app, clock pinned to 2025-06-01 12:00 UTC, Io's face towards Jupiter is at 0.024 E, latitude -0.009, where Horizons (observer quantity 14 from Jupiter's centre) has 0.036 E and -0.003: 0.012 degrees apart, where it was 0.175. The renderer spec checks that point, and now hands its frozen Horizons vectors, which are TDB, to update() as the UTC dates that name them, 69.184 s earlier; the same frozen rows fed at the UTC date fail for Io and Europa. A body-page test checks that the Sun lights the point it stands over at the same TDB instant the body is turned for. Controls: taking the renderer's orbits at the clock's UTC fails "faces jupiter and the Sun with the points Horizons gives on io"; taking the page's Sun there fails "takes the Sun where it stands at the same TDB instant". Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
import * as THREE from 'three/webgpu';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { TT_MINUS_UTC_DAYS } from '../astro/constants';
|
||||
import { eclipticToEquatorial } from '../astro/coordinates';
|
||||
import { meanElementsAt, positionAtEpoch } from '../astro/kepler';
|
||||
import { BodyRecord } from '../models/body.model';
|
||||
import { bodyPageView } from './body-orientation';
|
||||
import { bodyOrientation, bodyPageView } from './body-orientation';
|
||||
|
||||
// Earth (the Earth-Moon barycentre's mean elements) and the Moon as bodies.json carries them.
|
||||
const EARTH: BodyRecord = {
|
||||
@@ -51,6 +54,17 @@ describe('bodyPageView', () => {
|
||||
expect(Math.abs(moon.latDeg - 1.503004)).toBeLessThan(0.05);
|
||||
});
|
||||
|
||||
it('takes the Sun where it stands at the same TDB instant the body is turned for', () => {
|
||||
// Earth's own sphere, turned as the system view turns it, and the Sun seen from Earth's mean
|
||||
// place at the clock's date taken to TDB: the page must light that same point of its map.
|
||||
const planet = new THREE.Quaternion();
|
||||
const sun = new THREE.Vector3();
|
||||
bodyPageView(EARTH, BODIES, JUNE_1_2025_NOON_UTC, SUN_AZIMUTH, planet, sun);
|
||||
const place = eclipticToEquatorial(positionAtEpoch(meanElementsAt(EARTH.orbit, EARTH.rates, JUNE_1_2025_NOON_UTC + TT_MINUS_UTC_DAYS)));
|
||||
const expected = new THREE.Vector3(-place.x, -place.y, -place.z).normalize().applyQuaternion(bodyOrientation(EARTH.rotationalElements!, JUNE_1_2025_NOON_UTC).invert());
|
||||
expect(sun.clone().applyQuaternion(planet.clone().invert()).angleTo(expected)).toBeLessThan(1e-9);
|
||||
});
|
||||
|
||||
it('keeps the pole up and the Sun where the page’s light stands, turning the body under it', () => {
|
||||
const planet = new THREE.Quaternion();
|
||||
const sun = new THREE.Vector3();
|
||||
|
||||
Reference in New Issue
Block a user