Documentation / @interstellar-tools/equations / visVivaSpeed
Function: visVivaSpeed()
ts
function visVivaSpeed(r: number, a: number, mu: number): number;Defined in: orbits/vis-viva-speed.ts:60
Vis-viva (orbital speed) - compute speed magnitude (
Definition
- (
): current distance from the focus (m) - (
): semi-major axis (m). Elliptic ( ), parabolic ( ), hyperbolic ( ) - (
): gravitational parameter (m³/s²)
Units
- Inputs: (
) in m, ( ) in m, ( ) in m³/s². - Output: (
) in m/s.
TIP
- For circular orbits ((
)): ( ). - For parabolic trajectories, pass
a = Infinity(so ()): ( ).
In practiceDeparting for Mars
32.73 km/s
Speed at the start of a Hohmann transfer to Mars
Earth moves around the Sun at 29.78 km/s, so a spacecraft leaving on the transfer orbit needs 2.95 km/s on top of Earth's own speed.
ts
const au = 1.495978707e11; // m
const muSun = 1.32712440018e20; // m³/s²
const a = ((1 + 1.524) / 2) * au; // transfer orbit
visVivaSpeed(au, a, muSun); // ≈ 32 731 m/sParameters
| Parameter | Type | Description |
|---|---|---|
r | number | Radius ( |
a | number | Semi-major axis (Infinity for parabolic, negative for hyperbolic. |
mu | number | Gravitational parameter ( |
Returns
number
Speed magnitude (
Throws
Error If inputs are non-finite / out of domain, or the radicand becomes negative.
Example
ts
// LEO (~400 km): a ≈ r for near-circular
const muEarth = 3.986004418e14; // m³/s²
const r = 6378e3 + 400e3; // m
const a = r; // circular
const v = visVivaSpeed(r, a, muEarth); // ≈ 7670 m/s