Course 08 · Orbital mechanics
Spheres of influence and patched conics
Where the Earth stops being in charge, how a trajectory is stitched from one conic to the next, and what arriving at another world costs.
Every orbit so far has had one body at its focus. That is what made it a conic: orbits as conic sections derived the shape from a single inverse-square pull, and nothing else. A trip to the Moon has at least three bodies in it — the Earth, the Moon and the Sun — and a trip to Mars has four. The three-body problem has no general solution in closed form. There is no curve to write down, only the equations of motion to integrate.
Mission design gets round this with an approximation old enough to have planned the first interplanetary flights. Near each body, that body's gravity is by far the strongest, so pretend it is the only one. Divide space into regions, one per body, and fly a conic in each: a hyperbola leaving the Earth, an ellipse about the Sun, a hyperbola arriving at Mars. Where two regions meet, stitch the conics together so that position and velocity match. That is the method of patched conics, and the regions are spheres of influence.
It is worth understanding in detail for two reasons. It is how every transfer is first found, including every launch window the playground offers. And it is not how the playground flies them, which makes the playground a good place to see what the approximation leaves out.
Two descriptions of the same motion
Near the Moon, the vehicle's motion can be written relative to the Moon or relative to the Earth, and each choice keeps one pull and demotes the other to a perturbation. The demoted one has a subtlety that matters later.
Take a frame centred on a body of gravitational parameter , and one other body at position . The vehicle at is pulled by both. But the frame's centre is itself pulled by and accelerates towards it, and the vehicle's motion relative to the centre is the difference of the two accelerations:
The first term in the bracket is the direct term, 's pull on the vehicle; the second, the indirect term, is 's pull on the centre, subtracted. Near the centre they almost cancel and what is left is the difference across the distance — the tide. The Sun pulls both the Moon and a vehicle near it with 5.9 mm/s², and in the Moon's frame nearly all of it cancels.
So the two descriptions ignore different things. About the Moon, a conic keeps the Moon's pull, , and ignores the Earth's tide. About the Earth, a conic keeps the Earth's pull and ignores the Moon's pull on the vehicle less its pull on the Earth. Close to the Moon the first description ignores less; far from it, the second. Somewhere in between they are equally good.
Laplace's sphere of influence
Laplace found where, to leading order. Let a small body of mass orbit a large one of mass at distance , and put the vehicle at distance from the small one, with .
- About the small body, the kept pull is and the ignored one is the large body's tide, which for is of order . The ratio is , and it grows with .
- About the large body, the kept pull is about and the ignored one is the small body's pull, . The ratio is , and it falls with .
Setting the two ratios equal, , and
With the playground's constants from src/sim/bodies.ts, where the masses are
gravitational parameters and their ratio is all that matters:
- The Moon about the Earth: , km, and km — the value the playground uses, 17 per cent of the way to the Earth.
- The Earth about the Sun: , AU, and km. The playground's 924,630 km comes from a semi-major axis 0.002 per cent shorter. Counting the Moon's mass in with the Earth's would move it out to 929,182 km.
- Mars about the Sun: , AU, and km, against the playground's 577,460 km.
Put either ratio back in at the boundary and it says how much each conic is ignoring there. For the Earth in the Sun's field it is 8 per cent, for Mars 5 per cent: at the edge of their spheres the planets' conics are good, and inside them they are very good. For the Moon it is 41 per cent. The Moon is heavy for a satellite, its sphere reaches a sixth of the way to the Earth, and a conic about either body is rough anywhere near the boundary. Hold on to that number; it is the reason lunar trajectories are integrated rather than patched.
The sphere is not a sphere, either. Laplace kept only the leading terms and ignored direction, but the tide is twice as strong along the line to the large body as across it. Solve for the equal-ratio surface exactly and it is a lumpy spheroid: for the Moon, 51,841 km on the Earth side, 64,548 km on the far side, 66,733 km broadside. On Laplace's sphere itself, 66,183 km out on the Earth side, the Earth's tide is 111 per cent of the Moon's own pull.
Figure · where the pull changes hands
- LAPLACE RADIUS
- 66,183 km
- THE PLAYGROUND'S SOI
- 66,183 km
- HILL SPHERE
- 61,524 km
- BOUNDARY ALONG THIS DIRECTION
- 66,733 km
- IGNORED AT LAPLACE'S RADIUS: SOLID · DASHED
- 41% · 43%
Swing the direction round and watch the crossing move: the exact boundary sits inside Laplace's circle towards the parent and bulges out broadside, where the tide is weakest. For the Sun–Earth and Sun–Mars pairs the whole picture shrinks into a tiny fraction of the orbit and the ignored fractions stay small; for the Moon they do not.
The Hill sphere
A different question has a different radius. In the frame that turns with the small body round the large one, a satellite of the small body feels its pull, the large body's tide and the centrifugal term. On the line between the two bodies these balance at the Lagrange points and , at a distance
This is the Hill sphere, and it bounds the region where an orbit about the small body can stay bound to it at all. It is 61,524 km for the Moon, 1.50 million km for the Earth — the distance of the Sun–Earth and points where observatories are parked — and 1.08 million km for Mars. Orbits near its edge are not stable; long-lived ones sit well inside.
The two radii answer different questions. The sphere of influence says which conic is the better description of a passing trajectory; the Hill sphere says how far out a body can hold a satellite. For the planets the Hill sphere is the larger, 1.6 times the sphere of influence for the Earth and 1.9 times for Mars. For the Moon it is the smaller.
Patched conics
The method has three steps.
- The transfer conic, between centres. On the scale of the Solar System a planet's sphere of influence is a point: the Earth's 0.92 million km is 0.6 per cent of an astronomical unit. So the heliocentric leg is solved as if it ran from the centre of the Earth to the centre of Mars, ignoring both, by Lambert's problem for the chosen dates. It gives the velocity needed at each end.
- The excess velocities. Subtract each planet's own orbital velocity. What is left is the velocity relative to the planet far from it: , the hyperbolic excess velocity.
- The planetary hyperbolas. Inside each sphere of influence, the vehicle is on a hyperbola about the planet whose asymptote carries that . On the planetary scale the sphere is infinitely far away, so the asymptote is the patch.
Each approximation is made where it is best: at the edges of their spheres the planets' conics ignore 5 to 8 per cent of the field, and far less deeper in. For interplanetary flight the result is good enough to find every window and to price it; what it leaves out is small enough for mid-course corrections to absorb.
Leaving: v∞, C3 and the injection burn
On a hyperbola the specific energy is . Mission planners quote it as the characteristic energy , because it is what a launch vehicle's performance is tabulated against. From a circular parking orbit of radius , vis-viva gives the speed needed at periapsis and the burn is the difference from circular speed:
The escape speed adds in quadrature, which is the Oberth effect of transfers and the Oberth effect in its purest form. The playground's late-2026 Mars window from Cape Canaveral injects on 31 October 2026 at 12:29 UTC with km²/s², so km/s. From 200 km that needs 11.421 km/s at periapsis and a burn of 3.637 km/s.
The hyperbola also says where to burn. Its eccentricity is , and its outgoing asymptote lies round from periapsis. The burn has to be made 150° before the direction the vehicle is meant to leave in, most of the way round the Earth from it, and the plane of the parking orbit has to contain that direction — which is where the previous lesson left the launch.
Far from the Earth the vehicle is not yet at , either. At the edge of the sphere of influence it is still doing km/s: it has 139 m/s more of the Earth's well to climb. The patched conic books that climb to the hyperbola, not to the heliocentric leg, which is one of the small inconsistencies the method lives with.
Arriving: the aim point, the turn and the capture
At the far end the same hyperbola runs backwards, and the question becomes where to point. Far out, the vehicle approaches along the incoming asymptote, and what can be chosen is how far that line passes from the planet's centre: the aim offset or impact parameter . Angular momentum ties it to the periapsis, , and with the periapsis speed above,
where is the turn: the angle through which the planet bends the velocity between the two asymptotes. A flyby leaves with the same relative to the planet, pointing away — and in the Sun's frame, where the planet is moving, that turn changes the vehicle's speed. That is a gravity assist.
The aim offset is larger than the periapsis because gravity bends the path in. To hit the planet at all, only has to be less than : at Mars, arriving at 2.571 km/s, that is 7,452 km, more than twice Mars's radius. The playground's late-2026 arrival aims for a 250 km periapsis, km. The two are 328 km apart at the edge of the sphere of influence: that is the whole difference between an orbit and a crater, which is why arrivals are navigated for weeks.
Capture is a burn at periapsis, and the Oberth effect says to make it there and to make it small. The playground captures Mars arrivals into a one-sol ellipse, 250 × 33,854 km. At 2.571 km/s the vehicle reaches periapsis at 5.487 km/s, and the capture costs 861 m/s; capturing straight into a 250 km circle would cost 2,059 m/s. The ellipse can be lowered later by aerobraking or small burns at periapsis. At the Moon, arriving from the Cape's window of 3 November 2026 at 0.879 km/s, a 100 km periapsis is reached at 2.472 km/s and the capture into the playground's two-hour orbit, 100 × 146 km, costs 828 m/s.
Figure · the hyperbola at either end
- ARRIVING AT v∞
- 2.571 km/s
- ECCENTRICITY
- 1.563
- TURN δ
- 79.6 °
- SPEED AT PERIAPSIS
- 5.487 km/s
- CAPTURE: 1 SOL · CIRCULAR
- 0.861 · 2.059 km/s
- AIM OFFSET b · TO GRAZE
- 7,780 · 7,452 km
Lower the periapsis and the turn grows, the burn shrinks and the aim offset closes on the grazing value; raise and everything straightens out and gets dearer. For the departure case, watch : at low the asymptote is nearly 180° from periapsis, and the burn is made almost exactly opposite the direction of departure.
How good is the patch?
For the planets it is good. For the Moon it is not, and it is easy to see why: a translunar trajectory spends the best part of a day in the region where both pulls matter, and at the boundary each conic is ignoring 41 per cent of the field.
Figure · patched and integrated
- INJECTION
- 3.1300 km/s
- INTO THE MOON'S SPHERE
- 98.6 h
- v∞ AT THE MOON (PATCHED)
- 0.721 km/s
- CLOSEST APPROACH: PATCHED · INTEGRATED
- 120 · 1,075 km
- THEN (INTEGRATED)
- an Earth orbit, perigee 243,346 km
The defaults inject at 3.130 km/s with the Moon 114° ahead. The patched conic enters the sphere of influence after 98.6 hours, arrives at 0.72 km/s and predicts a closest approach 120 km above the surface. The integration passes 1,075 km up. Both are flights of the same injection; the patch is out by nearly a thousand kilometres, and a trajectory aimed with it would need correcting on the way. Move the lead angle and the gap changes size and sign, but for any pass close enough to matter it stays between several hundred and more than a thousand kilometres. The patched conic is how a lunar trajectory is found; it is not how one is aimed.
Patched conics give out in the same kind of place everywhere:
- Where the two pulls are comparable for a long time. The Moon's whole sphere; slow approaches with small , which linger at the boundary; anything near the Hill sphere's edge.
- Where the dynamics have no conic at all. The Lagrange points and the halo orbits round them; low-energy transfers that use the Sun's tide to reach the Moon for almost no capture burn, taking months instead of days. NASA's CAPSTONE reached the Moon this way in 2022.
- Where the answer has to be exact. Every real trajectory is finished by integration and differential correction: start from the patched conic, fly it in the full field, measure the miss, correct and repeat.
In Vivapse
The playground plans with patched conics and flies without them.
Planning. The window search in src/sim/windows.ts is steps 1 to 3 above.
For Mars it solves a heliocentric Lambert problem between the Earth's and
Mars's centres, takes
at each end, and prices the two hyperbolas with hyperbolicInjection and
hyperbolicCapture from src/sim/lambert.ts, the equations of this lesson line
for line. It places the injection point by rotating the asymptote back through
in the parking orbit's plane (injectionDir). For the Moon the
transfer is a Lambert problem about the Earth, from the parking orbit's radius
to the Moon's centre, and the capture is priced from the arrival velocity less
the Moon's: a patched conic with the Moon's sphere shrunk to a point. A program
reads the result as fc.plan — c3, vInfDep, dvInjection, dvArrival.
Flying. On the cruise rails the vehicle coasts through the full field: the
central body's point mass and , plus every other body's third-body term
written direct minus indirect exactly as above (acceleration in
src/sim/nbody.ts, frameAcceleration in src/sim/world.ts for frames built
on another body's pole). A program that calls fc.cruise(seconds) gets the
cruise rails: steps of up to an hour, sized to a few per cent of the local
dynamical time , that shrink near every body, never
cross a sphere-of-influence boundary and drop back to 20 ms before an
atmosphere or any surface within 2,000 km.
The sphere of influence is bookkeeping. When the vehicle crosses one,
World.setPrimary re-centres the frame on the new body — a fixed rotation onto
that body's pole plus a velocity shift, applied to every vehicle in the same
step, so the inertial state is conserved exactly. What changes is the frame's
centre, which body's is applied, and what fc.body, fc.soi and
fc.orbit describe; the gravity does not change at the line. To stop a
trajectory that grazes the boundary from flipping back and forth, soiFor
switches with a 1 % band — out at 1.01 times the radius, in at 0.99 times — and
is tested at most once a second. Re-centring is still worth doing: an orbit
100 km above the Moon, held in an Earth-centred frame, would be a small
difference between large numbers, and the conic a program reads in fc.orbit
should be the one about the body that matters.
The indirect term, the wrong way round. frameAcceleration is the path
every Moon- and Mars-centred coast takes. It wrote the vector between the
vehicle and the third body as , the opposite of
nbody.ts's convention, and negated both terms to compensate. That fixed the
direct term and flipped the indirect one: it added
instead of subtracting it. Near the Moon, where the Sun's direct and indirect
terms should cancel almost exactly, it left twice the Sun's and the Earth's
indirect terms standing. Measured on a live lunar arrival 56,811 km from the
Moon, the field came out at m/s² against a true
— wrong by six times the field itself. Close to the
surface the Moon's own pull swamps it, so capture and descent were unaffected;
the approach was not. An aimed 300 km lunar flyby arrived at 2,700 km, and
mid-course corrections were costing around 500 m/s instead of 50. The fix, in
the commit "Third-body gravity had the wrong sign off Earth", is one sign.
A bug like that has siblings. The field a vehicle feels while it is awake —
climbing, burning, descending — comes from a second function, World.gravity,
which holds the third bodies' positions for a few seconds at a time to save
recomputing the ephemeris. It stored the indirect term already negated and then
subtracted it: the same double negation, on the path the first fix did not
touch. It put m/s² of phantom pull on every awake step
about the Earth and the Moon, against true tides of to
— about 0.7 m/s of spurious velocity for every minute of
burn. The third physics audit found it, while this lesson was being written,
and the same one-sign fix now holds on both paths.
Figure · the term with the wrong sign
- THE MOON ALONE
- 1.519 mm/s²
- REAL FIELD
- 1.902 mm/s²
- INDIRECT TERMS ADDED
- 14.749 mm/s²
- WRONG BY
- 685 %
Slide the distance in and out. Near the surface the three curves agree to within about a per cent. Further out the real field falls with the Moon's own pull until the Earth's tide takes over — on the Earth side it all but vanishes near the edge of the sphere, where the two nearly cancel — while the wrong-signed field levels off between about 6 and 19 millimetres per second squared, depending on where the Sun is. At the default setting, 56,811 km out with the Sun at right angles, it is wrong by 685 per cent.
The simulator's documented simplifications, for completeness. Jupiter and the
other planets are left out. Coasting with fc.sleep near the Moon or Mars, at
20 ms steps, the rails fly a two-body conic about the current body; only
fc.cruise gets the full field between burns. And the planner's lunar search
stops at five days of flight, though the cheapest transfers to the Moon are
slower than that. Missions and destinations has the rest.
Try it
Set up a lunar flyby: in the Mission panel, choose the Moon as the destination with the arrival set to Flyby, launch from Cape Canaveral, and load the Odyssey vehicle and the "Moon flyby" example program. Then watch the conic about the Moon change while nothing fires. At the top of the program add
let nextConicLog = 0;
and as the first lines inside update(fc):
if (fc.soi.body === "moon" && fc.t >= nextConicLog) {
nextConicLog = fc.t + 3600;
fc.log("about the Moon at", (fc.soi.distance / 1e3).toFixed(0), "km:",
"conic periapsis", (fc.orbit.periapsis / 1e3).toFixed(0), "km");
}
The program sleeps on the cruise rails through most of the approach, so the
line prints only when it wakes. Whenever it does, fc.orbit is the osculating
conic about the Moon — a point mass with nothing else in it, which is the
patched conic's prediction of the flyby made from that moment. If the patch
were exact the number would not move while the engine is off.
It moves. In a calm flight in the November 2026 window, sampled every hour from the handover at 65,386 km from the Moon's centre, the conic's periapsis read −152 km — a conic that hits the Moon — then −98, −10, +49, +86 and +103 km by 16,900 km out, with nothing burning; then it turned down again, and the flyby event reported the closest approach at 48 km. The program's perilune keeper wakes at 13,000 km to hold the pass off the surface, and it is there because of this drift: 255 km of it, every kilometre the Earth's and the Sun's tides acting inside the sphere of influence, which the patched conic leaves out and the simulator does not.
What carries forward
Patched conics turn a transfer into three problems that are each easy: two hyperbolas and the conic between them. The middle one, between two positions at two given times, is Lambert's problem, which is how the playground's windows are found. The next lessons come back down to the atmosphere, beginning with dynamic pressure and max-Q, where the vehicle has to survive long enough to reach any orbit at all.