Documentation / @interstellar-tools/equations / computeAngle
Function: computeAngle()
function computeAngle(
orbit: Pick<OrbitInterface, 'e' | 'angle' | 'period'>,
timeStep: TimeStepInterface
): Radians;Defined in: angle/compute-angle.ts:68
Advances a body along its orbit by one time step and returns its new true anomaly (
The orbit's angle is the starting true anomaly. There is no date input: call this once per frame or step, and feed the result back in as the next angle to move the body over time. To find a body at a given date instead, use trueAnomalyAt.
Step 1: Mean anomaly after the time step (
Done by advanceMeanAnomaly:
is the mean anomaly at the start, converted from the true anomaly angle(equal to it when). is the mean motion, from the period converted to days. is a positive duration; a negative one, from data in the old 0.x convention, is read as its absolute value. A positive step always moves the body forward. is timeStep.valuein days. It can be any length, and negative to go back in time.
The result is wrapped to
Step 2: Solve Kepler's equation for the eccentric anomaly (
Step 3: Convert the eccentric anomaly to the true anomaly (
Done by eccentricToTrueAnomaly:
Parameters
| Parameter | Type | Description |
|---|---|---|
orbit | Pick<OrbitInterface, "e" | "angle" |
timeStep | TimeStepInterface | How far to advance, in days. |
Returns
The true anomaly after the time step, in radians.
Throws
RangeError If the orbit's eccentricity is outside
Example
import { PLANETS } from '@interstellar-tools/constants';
import { computeAngle } from '@interstellar-tools/equations';
const earth = PLANETS.find((planet) => planet.id === 'earth')!;
const timeStep: TimeStepInterface = { value: 1, unit: 'd' };
// Earth's true anomaly one day after its dataset position
const angle: Radians = computeAngle(earth.orbit!, timeStep);