Reference · Where the Sun, Moon and planets are for a date, in two scales, with the camera maths
createTrackfunction
Answers for any moment from two real ones: at(ms) works out a frame only when ms leaves the span the last two answers cover, and then looks stepMs ahead, so playing
time at a steady rate costs one pair of lookups every stepMs and every draw in between is arithmetic.
Import it
import { createTrack } from "@johnmorrisdotca/wakusei-planets/space";
Definition
function createTrack(initialStepMs?: number): { at(ms: number): SpaceFrame; ends(): [SpaceFrame, SpaceFrame] | undefined; readonly lookups: number; reset(): void; setStep(ms: number): void; }
Parameters
| Name | Type | Description |
|---|---|---|
initialStepMs (optional) | number | How far ahead the second answer looks, in milliseconds. |
Returns
{ at(ms: number): SpaceFrame; ends(): [SpaceFrame, SpaceFrame] | undefined; readonly lookups: number; reset(): void; setStep(ms: number): void; }
A track: at(ms) for a frame, lookups for how many frames were worked out, ends() for the two answers it is between (undefined before the first at), reset() and setStep(ms).
Examples
import { createTrack } from "@johnmorrisdotca/wakusei-planets/space";
const track = createTrack(1000);
const start = Date.UTC(2026, 10, 2);
for (let step = 0; step < 10; step += 1) track.at(start + step * 50);
console.log(track.lookups);2What it prints (run when this page was built)