Skip to content

Documentation / @interstellar-tools/equations / trueToMeanAnomaly

Function: trueToMeanAnomaly() ​

ts
function trueToMeanAnomaly(V: Radians, e: number): Radians;

Defined in: anomalies/true-to-mean-anomaly.ts:77

Converts true anomaly (ν) to mean anomaly (M) using Kepler's equation.


Mathematical Explanation:

In orbital mechanics, the true anomaly (ν), the eccentric anomaly (E), and the mean anomaly (M) are related through Kepler's equation.

Step 1: Convert True Anomaly (ν) to Eccentric Anomaly (E)

E=2tan−1⁡(1−e1+etan⁡(ν2))

This transformation ensures that E is computed correctly across all quadrants, using atan2(y, x) instead of atan(x) to avoid ambiguity in angle computation.

Step 2: Convert Eccentric Anomaly (E) to Mean Anomaly (M)

Kepler’s equation states:

M=E−esin⁡(E)

Since anomalies are periodic over one full orbit (0≤M<2π), we apply wrapAngle(M) to ensure that the computed mean anomaly remains within this range.


Why Use wrapAngle?

  • Ensures that the mean anomaly is always wrapped within [0,2π].
  • Corrects floating-point precision issues that may cause values slightly greater than 2π.
  • Prevents negative anomalies by shifting them into the valid range.

Parameters ​

ParameterTypeDescription
VRadiansTrue anomaly (ν) in radians.
enumberEccentricity of the orbit (0≤e<1).

Returns ​

Radians

The mean anomaly (M) in radians, wrapped to the range [0,2π].

Throws ​

RangeError If the eccentricity (e) is outside the valid range 0≤e<1.


Examples ​

ts
import { trueToMeanAnomaly } from '@interstellar-tools/equations';

// Example 1: Standard elliptical orbit
const V = Math.PI / 3; // 60 degrees in radians
const e = 0.1; // Eccentricity
console.log(trueToMeanAnomaly(V, e)); // Output: Mean anomaly in radians
ts
// Example 2: Retrograde motion handling
const V_retrograde = -Math.PI / 2; // -90 degrees
const e_retrograde = 0.2;
console.log(trueToMeanAnomaly(V_retrograde, e_retrograde));

See ​