Documentation / @interstellar-tools/equations / stateAt
Function: stateAt()
ts
function stateAt(
orbit: OrbitInterface,
date: Date,
options?: StateAtOptionsInterface
): StateVectorInterface;Defined in: orbits/state-at.ts:84
The position and velocity of a body on its orbit at a given date, in 3D, from a dataset orbit: its a, e, period, its true anomaly angle at J2000, and its orientation i, om and w in its frame.
INFO
- The true anomaly at
datecomes from trueAnomalyAt: the orbit'sangleat J2000, moved on by itsperiod. - The state comes from elementsToState, with the gravitational parameter the orbit's own
aandperiodimply,, so the speed agrees with the period. It's the parent's (and the body's, for a pair), for a body around its parent. - It's relative to the orbit's parent: add the parent's own state to place a moon around the Sun, for example.
- A missing
omorwcounts as 0. An orbit withoutiis flat: in its reference plane,retrograde: trueturns it backwards, as. - The orbit is a fixed ellipse: it doesn't precess. Good near J2000; the further from it, the more the real body has drifted.
Parameters
| Parameter | Type | Description |
|---|---|---|
orbit | OrbitInterface | An orbit, for example body.orbit from a dataset. |
date | Date | The date to find the body at. |
options? | StateAtOptionsInterface | The frame to give the state in, 'icrf' by default. |
Returns
The position r in metres and velocity v in metres per second, relative to the orbit's parent.
Throws
- If
dateis not a validDate. - If the orbit's eccentricity is outside
. - If
frameis'icrf'and the orbit has noframe, or one that can't be placed in the ICRF yet (orbitFrameToIcrf).
Example
ts
import { AU_METERS, PLANETS } from '@interstellar-tools/constants';
import { stateAt } from '@interstellar-tools/equations';
const mars = PLANETS.find((planet) => planet.id === 'mars')!;
const { r } = stateAt(mars.orbit!, new Date('2026-11-10T00:00:00Z'));
r.map((m) => m / AU_METERS); // Mars from the Sun, in au, in the ICRFSee
orbitFrameToIcrf for the rotation to the ICRF.