Skip to content

Documentation / @interstellar-tools/equations / meanAnomalyAt

Function: meanAnomalyAt() ​

ts
function meanAnomalyAt(
  orbit: Pick<OrbitInterface, 'e' | 'angle' | 'period'>,
  date: Date
): Radians;

Defined in: anomalies/anomaly-at.ts:53

The mean anomaly (M) of an orbit at a given date.

Every orbit.angle in the datasets is the true anomaly at J2000 (2000-01-01 12:00 TT), so this advances the orbit from J2000 to date with advanceMeanAnomaly. Dates before J2000 work too.

M=M0+2π|P|(t−tJ2000)

The time is measured in UTC, as JavaScript dates are, against J2000_UTC. Leap seconds since 2000 are ignored, which moves a body by a few seconds of its orbit at most.

Parameters ​

ParameterTypeDescription
orbitPick<OrbitInterface, "e""angle"
dateDateThe date to find the body at.

Returns ​

Radians

The mean anomaly at date, in [0,2π).

Throws ​

If date is not a valid Date.

Throws ​

If the orbit's eccentricity is outside 0≤e<1.

Example ​

ts
import { PLANETS } from '@interstellar-tools/constants';
import { meanAnomalyAt } from '@interstellar-tools/equations';

const earth = PLANETS.find((planet) => planet.id === 'earth')!;

meanAnomalyAt(earth.orbit!, new Date('2026-10-17T12:00:00Z')); // ≈ 4.934 rad (282.7°)

See ​

trueAnomalyAt for where the body actually is.