Documentation / @interstellar-tools/equations / solveLambert
Function: solveLambert()
function solveLambert(
r1: Vector3DTupleType,
r2: Vector3DTupleType,
dt: number,
mu: number,
options?: SolveLambertOptionsInterface
): LambertSolutionInterface;Defined in: manoeuvres/solve-lambert.ts:110
Solve Lambert's problem: find the orbit that goes from one position to another in a given time.
In universal variables, solve for
and recover the velocities from the Lagrange coefficients
Where:
, are the two positions and , their lengths (m) is the angle swept from to (rad) and are the Stumpff functions, stumpffC and stumpffS is the gravitational parameter (m³/s²)
Units
- Inputs:
r1andr2in m,dtin s,muin m³/s². - Output:
v1andv2in m/s.
Notes
- One formula for ellipses, parabolas and hyperbolas:
is an ellipse, a hyperbola. The time of flight grows steadily with , so this solves for by bisection, which can't diverge, below : single-revolution transfers only. - The fastest transfers, seconds across thousands of kilometres, end where the terms of the equation nearly cancel. If fewer than about 8 significant digits would be left, the function throws instead of returning an inaccurate answer. It also throws for a time too long for a single revolution.
- Two positions allow two transfers, the short way round and the long way.
progradepicks the one that goes counterclockwise seen from, so is under 180° when ; prograde: falsepicks the clockwise one. - At 0° and 180° the transfer plane isn't defined by the two positions, and the function throws. Near 180° the solution exists but is sensitive to small changes in the positions.
- For a transfer between two circular orbits, the velocity changes are
v1minus the speed of the first orbit and the speed of the second minusv2, as vectors.
11 032 m/s at −6.48°
At entry interface, 44.8 h and 154.15° round Earth from the edge of the Moon's sphere of influence, 322 000 km out
Chapter V of the Apollo 11 tutorial runs Columbia's orbit back from entry interface to the edge of the Moon's sphere of influence: 44.8 h of falling. Ask Lambert's question for those two positions and that time, and it finds the same orbit: it arrives at the flown entry speed and angle, and leaves the edge at 1 239 m/s. Planners asked the question the other way round, to target the midcourse corrections.
const swept = toRad(154.15); // from the edge to entry interface
const edge: Vector3DTupleType = [
322e6 * Math.cos(swept),
-322e6 * Math.sin(swept),
0
];
const entry: Vector3DTupleType = [6_500_086, 0, 0]; // 121.92 km up
const { v2 } = solveLambert(edge, entry, 161_219, 3.986004418e14);
Math.hypot(...v2); // ≈ 11 032 m/s
toDeg(Math.asin(v2[0] / Math.hypot(...v2))); // ≈ −6.48°Parameters
| Parameter | Type | Description |
|---|---|---|
r1 | Vector3DTupleType | Position |
r2 | Vector3DTupleType | Position |
dt | number | Time of flight |
mu | number | Gravitational parameter |
options? | SolveLambertOptionsInterface | prograde (default true): the direction of the transfer. Room for more, such as multi-revolution transfers, later. |
Returns
The velocities v1 at r1 and v2 at r2, in m/s.
Throws
- If any input is not finite.
- If
dt <= 0,mu <= 0, a position is zero, the positions are 0° or 180° apart, ordtis too short to solve accurately or too long for a single revolution.
Example
// Curtis, Example 5.2: one hour between two positions around Earth
const { v1, v2 } = solveLambert(
[5_000_000, 10_000_000, 2_100_000],
[-14_600_000, 2_500_000, 7_000_000],
3600,
3.986e14
);
// v1 ≈ [-5 992, 1 925, 3 246] m/s, v2 ≈ [-3 312, -4 197, -385] m/s