Documentation / @interstellar-tools/tracking / stateAt
Function: stateAt()
ts
function stateAt(
ephemeris: EphemerisInterface,
date: Date,
options?: StateAtOptionsInterface
): StateVectorInterface;Defined in: probes/interpolate.ts:68
The state of a spacecraft at any moment of an ephemeris: its position and velocity, interpolated between the samples.
Fits the Hermite polynomial through the positions and velocities of the points samples around the date, a polynomial of degree
Where:
are the sample times, each twice are the divided differences of the positions, with the velocities as the first differences at each sample
Units
- Inputs: the ephemeris from parseOem or parseHorizonsVectors, and a
Date. - Output:
rin m andvin m/s, from the ephemeris's centre, on its frame's axes.
Notes
- Using the velocities matches the slope as well as the position at each sample: the default 4 samples interpolate to degree 7, as the OEM standard's own example recommends, and follow a sharp perihelion that linear interpolation cuts across.
- At a sample's epoch, the sample is returned exactly.
- Only within the ephemeris: outside the first and last samples, it throws rather than extrapolate. Near either end, the samples are taken from the one side.
- The samples should be close enough to follow the motion: for a probe in cruise, a day apart; near a planet or the Sun, hours or minutes.
Parameters
| Parameter | Type | Description |
|---|---|---|
ephemeris | EphemerisInterface | The ephemeris, from parseOem or parseHorizonsVectors. |
date | Date | The moment, as a Date, within the ephemeris. |
options? | StateAtOptionsInterface | points, the number of samples to interpolate through (an integer from 2 to 8, default 4). |
Returns
The position r in m and velocity v in m/s: see StateVectorInterface.
Throws
- If
dateis not a validDate, the ephemeris has no samples, orpointsis not an integer. - If
dateis outside the ephemeris, orpointsis outside 2 to 8.
Example
ts
const voyager1 = parseHorizonsVectors(text);
const { r, v } = stateAt(voyager1, new Date('2026-01-05T06:00:00Z'));
Math.hypot(...r) / AU_METERS; // ≈ 169: au from the Sun