Documentation / @interstellar-tools/equations / elementsToState
Function: elementsToState()
ts
function elementsToState(
elements: ClassicalElementsInterface,
mu: number
): StateVectorInterface;Defined in: orbits/elements-to-state.ts:70
Convert the six classical orbital elements to a state vector (position and velocity).
In the perifocal frame, with
then rotated into the inertial frame:
Units
- Inputs:
ain m,edimensionless, angles in radians,muin m³/s². - Output:
rin m,vin m/s.
Notes
- The inverse of stateToElements, including its conventions for circular and equatorial orbits.
- Elliptic orbits need
and hyperbolic ones . A parabolic orbit ( ) has no finite , so it isn't supported. - On a hyperbola, only true anomalies with
exist: the body never reaches the asymptotes.
Parameters
| Parameter | Type | Description |
|---|---|---|
elements | ClassicalElementsInterface | The classical orbital elements. |
mu | number | Gravitational parameter |
Returns
The position r in m and velocity v in m/s.
Throws
- If any input is not a finite number.
- If
mu <= 0,e < 0,e = 1,iis outside [0, π],ahas the wrong sign fore, ornuis beyond a hyperbola's asymptotes.
Example
ts
import type { Radians } from '@interstellar-tools/types';
// A circular, equatorial orbit at 7000 km, a quarter of the way round
const { r, v } = elementsToState(
{
a: 7_000_000,
e: 0,
i: 0 as Radians,
raan: 0 as Radians,
argp: 0 as Radians,
nu: (Math.PI / 2) as Radians
},
3.986004418e14
);
// r ≈ [0, 7 000 000, 0] m, v ≈ [-7546, 0, 0] m/sSee
- stateToElements
- https://en.wikipedia.org/wiki/Perifocal_coordinate_system Perifocal coordinate system