The Solar System companion textbook to the interactive 3D simulation
▶ Open the simulation
Section 1 · Overview

What we are actually looking at

Open the simulation and you will see eight dots that never stop and never collide. That is the Solar System, only very small. Let us work out what is happening on the screen before we touch a single formula.

This picture is the easiest place to start

The textbook and the simulation form one loop: read a section → open the model → watch the same thing happen live. Knowledge sticks much faster that way.

🪐 Open the simulation

The whole picture at a glance

In the middle sits the Sun: a glowing ball that provides both the light and the very reason the planets move. Eight planets travel around it, from fast, tiny Mercury to slow, distant Neptune. The thin rings are orbits: a reminder of the path a planet took on its previous lap. The glowing tail behind every planet is the trail of where it has moved during the last few seconds.

And the most important part: this is not a recorded cartoon. The computer does not know in advance where Earth will be in a minute. It looks at where the planet is now and where it is heading, asks “how hard is the Sun (and every other planet) pulling on it right now?”, nudges the velocity a little, nudges the planet itself a little, and repeats that tens of thousands of times per second. The rules are short; the picture grows on its own.

What you can poke right now

  • “Time speed” — in reality Earth takes a whole year per lap. We squeeze that year into a few seconds so you can actually notice something.
  • “Mass of the Sun” — imagine the Sun became heavier or lighter: it pulls harder or softer, and the orbits react straight away.
  • “+ Body” — launch your own planet onto a circular orbit and watch how it gets along with the others.
  • Click a planet — its live readings appear on the right: distance, speed, period. Double-click and the camera flies in closer.
  • Mouse — drags the camera around, the wheel zooms in. You fly around the model like a director with a drone.

Three layers behind all this magic

  1. Physics. One short loop: compute gravity → update the velocities → update the positions. Details in the section “How the computer does the math”.
  2. Graphics. The Three.js library turns numbers into spheres, light and stars. It decides nothing — it only draws.
  3. Controls. Camera, sliders, labels. They merely pass physical wishes (“the Sun is twice as heavy”) down to the first layer.
A habit worth having.

The same recipe — “physics apart, graphics apart” — sits inside almost every simulation, from weather forecasts to colliding galaxies. Understand it once and you understand not one program but a whole class of programs.

The planets: who is who

Distances in the model are squeezed (otherwise Neptune would sit 77 “Mercuries” out and stay a dot in the empty dark), but the order and the “farther means slower” rule are honest.

Mercury

0.39 au from the Sun

Year: 88 Earth days

Speed: 47.4 km/s

Venus

0.72 au

Year: 225 days

Speed: 35.0 km/s

Earth

1.00 au — that is us

Year: 365.25 days

Speed: 29.8 km/s

Mars

1.52 au

Year: 687 days

Speed: 24.1 km/s

Jupiter

5.20 au

Year: 11.9 years

Speed: 13.1 km/s

Saturn

9.54 au

Year: 29.5 years

Speed: 9.7 km/s

Uranus

19.2 au

Year: 84 years

Speed: 6.8 km/s

Neptune

30.1 au

Year: 165 years

Speed: 5.4 km/s

Find the pattern yourself: the farther a planet sits, the slower it flies and the longer its year. Why that happens follows almost literally from two formulas; we get to them in the sections ahead.

Quick check: why do the outer planets move more slowly than the inner ones?

Section 2 · Physics

Gravity, the Newtonian way

Our model lives by exactly two rules: every body pulls every other body, and the farther apart they are, the weaker the pull. All the graceful motion of the planets is nothing but the consequence of those two lines.

Let us start with what you already know

Throw a bunch of keys into the air. It slows down, hangs for a moment and falls back — because the Earth is pulling it down. Nobody is surprised: gravity near the ground is a familiar, very “local” feeling.

Now throw the keys forward, hard. They trace an arc and land a few metres away. Throw harder and they fly further. The arc stretches not because the keys “stopped falling”, but because they manage to travel forward farther before the height runs out.

Newton proposed a thought experiment that pushes this idea to its end. Picture a very tall mountain with a powerful cannon on top, firing perfectly horizontally:

  • Slowly — the shell lands at the foot of the mountain.
  • Faster — it flies a kilometre and lands in the valley.
  • Faster still — while the shell drops one metre, the round Earth beneath it “drops away” by one metre too. The shell falls the whole time — and misses the ground the whole time. That is what an orbit is.
The idea this section is built on.

A planet does not “defeat” gravity. It falls toward the Sun continuously, but it moves sideways so fast that it keeps missing. No magic support, no “fuel tank” needed to keep going round.

The formula, one symbol at a time

Isaac Newton managed to write all of that in one short line. Do not be afraid of it: we will read it symbol by symbol.

F = G · m₁ m₂⁄r²
SymbolWhat it isHow to think about it in human terms
FForce of attractionHow hard the two bodies tug on each other. Measured in newtons: 1 N is about the effort with which you hold an apple.
GGravitational constantThe same number everywhere in the Universe: 6.674·10⁻¹¹. It only sets how strong gravity is — and gravity is a very weak interaction.
m₁, m₂The masses of the bodiesIf either body is heavier, the tug is stronger. The mass of the Sun is exactly what the slider in the simulation turns.
rDistance between the centresFrom centre to centre, not from surface to surface. For spheres that is legitimate — they behave as though all their mass sat in the centre.
r²Distance squaredHere hides the “it fades very fast”: twice as far, four times weaker; three times farther, nine; ten times, a hundred.

Say the formula out loud like this: “the heavier the bodies, the harder they pull; the farther apart they are, the faster that pull dies away”.

Numbers to give it scale: the Sun pulls the Earth with a force of roughly 3.5·10²² newtons — as if several trillion loaded dump trucks were hanging on a scale. And yet the Earth's “fall” toward the Sun is only about 0.006 m/s² — fifteen hundred times weaker than what you deal with when you drop a phone. A tiny acceleration that keeps working every second for billions of years, and the result is an orbit.

The second step: from force to acceleration (and why everything falls the same way)

A force is not yet a motion. What changes motion is acceleration: “how much faster the body gets every second”. By Newton's second law acceleration = force ÷ mass. Substitute our formula and something curious happens: the mass of the falling body cancels out.

a = G · M⁄r²
SymbolWhat it isHow to think about it in human terms
aAccelerationHow fast the speed grows (metres per second gained every second).
G · MThe mass of the body that pullsHere M is the mass of whatever is pulling (the Sun, the Earth). It is the only mass left in the formula.
r²Distance squaredAgain: far away means much weaker.

That gives a useful everyday corollary: a hammer and a feather fall the same way where there is no air (the Apollo 15 crew checked this on the Moon). And the consequence for us: a planet's orbit hardly depends on its mass — it depends only on where the planet is and where it is heading. That is why in the simulation the Earth and a hypothetical “Earth-twice-as-heavy” would travel exactly the same orbit.

One more useful analogy: a stone on a string

Swing a stone on a string. The string pulls the stone toward the centre the whole time — that is the same “tug”. Let go, and the stone flies neither up nor down but straight ahead, along the tangent to the circle.

For planets, gravity plays the part of the string. Cut it (mentally switch the Sun off) and all eight planets fly off along straight lines, each in its own direction, exactly where it was pointing at that instant. That is what you will see in the simulation if you turn the mass of the Sun down to nearly nothing.

Careful with the “ball on a bedsheet”.

The famous picture of a heavy ball denting a stretched sheet is about Einstein and curved space, not about Newton. It explains beautifully “why there is gravity at all”, but you cannot compute orbits with it. Our model runs on the honest Newtonian law: bodies pull on each other, and we count it step by step.

Question 1. Suppose the Sun magically disappeared. What would the Earth do?

Question 2. The distance between two bodies is tripled. What happens to the gravitational force?

Section 3 · Physics

Orbital speed

Speed is the only tuning knob by which the Universe decides where a planet gets to live: fall into the Sun, stay in the neighbourhood, or leave for interstellar space for good.

“Forever falling past it” — now with numbers

Back to the cannon on the mountain. There is exactly one speed at which the shell falls with precisely the same curvature as the surface of the planet. It is called the circular, or orbital, speed. It follows from one plain demand: gravity must bend the path exactly as much as a circle requires.

v = √( G · M⁄r )
SymbolWhat it isHow to think about it in human terms
vCircular speedExactly the sideways speed at which you neither fall down nor fly away.
√Square rootThe opposite of squaring: pull four times weaker and you need only half the speed.
G · MMass of whatever you orbitThe heavier the owner of the orbit, the faster you have to move to hold on.
rDistance to the centreFarther out means slower. Here it is — the pattern from the first section.

Put in the numbers for the Earth (M is the mass of the Sun, r = 150 million km) and you get 29.8 km/s, about 107,000 km/h. We fly around the Sun faster than any bullet and feel nothing, because we fly evenly and there is nothing to brake against.

The ISS, 400 km above us

Circular speed: 7.66 km/s

One lap in 92 minutes

The Moon, 384,000 km

Circular speed: 1.02 km/s

One lap in 27.3 days

Mercury

47.4 km/s — fastest of all

Here the Sun's pull is at its meanest

Neptune

5.4 km/s — slowest of all

Far out, so everything is calm

Newton's cannon: watch it live

Below is that very thought experiment, except it is actually computed. Four shells leave the same height horizontally, each with a different speed. The only difference between them is the number v.

The shells are computed with the same Newtonian law as the big simulation — only in a flat, two-dimensional world.
below circular speed → falls onto the planet exactly circular → an orbit forever above circular speed → a stretched ellipse past escape speed → gone for good

Watch the blue trajectory: it does not “keep drifting away”, it comes back. A little extra speed is not an escape, it is an ellipse: the planet moves outward, slows down, falls back and repeats. Almost every real orbit lives like this — Mars, comets, and your own body in the simulation if you give it a small shove.

Escape speed: when “too fast” turns into “forever”

There is one more threshold — the escape speed. It is exactly √2 (≈ 1.41) times the circular speed:

vescape = √2 · vcircular

For a satellite around the Earth that means 11.2 km/s instead of 7.9. For a planet sitting at Earth's distance — 42.1 km/s instead of 29.8. Cross that line and the body never returns: it goes on slowing down forever, yet always keeps moving away. That is exactly why hammering “+ Body” at high speed is so much fun in the simulation: some of the bodies simply slide over the horizon and never come back.

A cheat sheet of three numbers.

v below circular speed → it falls. v equal to circular → a circle. Between circular and 1.41 × circular → an ellipse. 1.41 × circular or more → goodbye, Solar System. All of orbital mechanics is variations on those four lines.

You put a satellite into orbit around the Earth and speed it up to exactly twice the circular speed (v = 2·vcirc). What happens?

Once the speeds make sense, one question is left: how do you make a computer work all of this out honestly, millions of times a second? The answer is in the next section.

Section 4 · Method

How the computer does the math

A computer cannot “see a whole ellipse”. It can do exactly one thing: take very small steps. A million small steps is what an orbit is made of.

Four steps only, repeated endlessly

Imagine driving blindfolded on a navigator's commands. The navigator shouts “three metres straight ahead!” — you drive three metres. He looks around again and shouts a new command. The shorter the commands, the smoother and more accurate your route. That is numerical integration.

// what the model does over and over again for every frame on the screen: for 1200 tiny steps: a = −G · M · r⃗ / |r⃗|³ // 1. how hard is it pulling right now, and where v = v + a · dt // 2. nudge the velocity a little (a “kick”) r = r + v · dt // 3. nudge the planet itself a little // 4. …and start again, from the new position

Here dt is the size of one step in time. In our model it is 0.00025 of a year, about 2.2 hours of real time. In one Earth year the computer takes roughly 4000 of these steps — and every single one asks physics again: “which way am I being pulled?”.

Why the step has to be small (and clever)

The naive way — “compute the acceleration, move the position” — is called Euler's method. It is simple, but it has a bad habit: every step adds a tiny bit of extra energy to the system, and after a thousand orbits the planets have left the building. The error itself is minuscule, but it always piles up in the same direction — like drifting half a degree to the right with every step you take.

So the model uses a trick called “kick — drift — kick”: the velocity gets kicked for half a step, the planet is moved, gravity is recomputed at the new position, and the second half of the kick is applied. That symmetry stops the error from accumulating: the orbit may wobble slightly, but it does not fall apart. In the model you are about to open, the Earth's orbital energy does not leak even over 200 years — that is covered by automated tests.

Play with the step size

In the picture below the perfect circle is what the exact formula gives. The green line is how our “kick-drift-kick” scheme travels, the pink one is naive Euler. Move the slider: it changes the size of the step dt.

perfect circle (exact solution) “kick-drift-kick” — the method used in the model naive Euler — energy piles up, the orbit swells

With a small step both lines almost merge with the ideal one. Make the step bigger and you will see the green turn into a “polygon” while the pink starts spiralling outward. The very same compromise lives in the big simulation: when you crank “time speed” to the maximum, the steps automatically get coarser and the orbits get slightly rougher — so that everything stays smooth.

Why not just solve it with a formula?

Because a ready-made formula exists only for two bodies: the Sun plus one planet. As soon as there are three or more, their mutual pulls knot into a problem that has no general closed-form solution (Poincaré proved that). And our model has eight planets plus the Sun plus whatever bodies you throw in. One honest road is left: compute it in steps.

A side effect that matters.

Precisely because it works in steps, the simulation turns out to be more alive than any formula: mid-experiment you can change the mass of the Sun, crash two planets together, add a comet — and everything just keeps computing. A formula cannot do that; an integrator can.

What happens if the integration step is made too large?

That is enough to understand what is being computed. Now we can look inside the file and take it apart piece by piece — the “code, piece by piece” section.

Section 5 · Under the hood

The code, piece by piece

The file simulation.js is not a soup of three thousand lines. It is laid out in six blocks, and each one solves exactly one problem. Recognise the blocks and you can change anything you like.

How to peek at the code

Right-click the file → “Open with” → Notepad (or VS Code). Inside, everything is divided by big headings starting with РАЗДЕЛ (“section”), for example РАЗДЕЛ 1 · ЕДИНИЦЫ И ДАННЫЕ — “units and data”. Search with Ctrl+F and you are there. Nothing to be afraid of: you have to try hard to break something, and Ctrl+Z puts everything back.

The six blocks of the file

  1. Units and data — the numbers and the list of planets. The “bricks” of this Universe live here.
  2. The scene — renderer, camera, light, the starfield. Pure film studio.
  3. Sun and planets — building the balls, the trails, the labels and the orbit rings.
  4. Physics — that very acceleration → velocity → position. The brain of the simulation.
  5. Interface and camera — sliders, buttons, clicking a planet, the camera that follows.
  6. Main loop — the order of work: “once per frame, compute first, draw second”.

The data block: what a planet is made of

Every planet is a single line. All its properties are out in the open — a pleasure to edit:

const PLANETS = [ { name: 'Mercury', a: 0.387, inc: 7.0, size: 0.155, color: 0xb8ab9b, mass: 1.66e-7 }, { name: 'Earth', a: 1.000, inc: 0.0, size: 0.26, color: 0x5aa9ff, mass: 3.00e-6 }, // …and so on, all the way out to Neptune ];
FieldWhat it controlsIf you change it
aDistance to the Sun in astronomical units (1 au = 8 light-minutes)The planet moves onto another orbit and gets the correct speed automatically
incOrbital inclination in degreesThe orbit tilts — you can see that the system is not flat as a stack of pancakes
sizeVisible size of the ball (in screen units, not real ones)The planet gets bigger or smaller — physics stays untouched
colorColour of the ball, the trail and the labelSimply beautiful
massMass in masses of the SunThe planet starts tugging, just a little, on the Sun and on its neighbours

Physics: nine lines that move every planet

The function accelerations is Newton's law translated into something a computer understands. For every pair of bodies it computes the distance and the pull:

function accelerations(bodies, gm) { for (every pair of bodies i, j) { dx = b.pos[0] − a.pos[0]; dy = …; dz = …; // the vector “from one to the other” r2 = dx*dx + dy*dy + dz*dz; // distance squared r = √r2; k = gm / (r2 * r); // this is G·M / r³, two steps in one acc[i] += k * b.mass * (dx, dy, dz); // i is pulled toward j acc[j] -= k * a.mass * (dx, dy, dz); // and j toward i — Newton's third law } }

Then integrate performs a single “kick-drift-kick” step, and advanceTime repeats it as many times as needed to fast-forward the requested amount of time. That is it — there is no more “physics” anywhere in the file.

Two “secret” numbers worth understanding.

GM_SUN = 4π² is not magic, it is a convenient choice of units: measure distance in astronomical units and time in years, and for the Earth's orbit you get r = 1 and v = 2π ≈ 6.28. The circular-speed function then returns the correct answer on its own.
COMPRESS = 0.62 — squeezing distances for the screen. The distances in the model are honest; it is the picture that drags the far orbits closer, otherwise Neptune would sit past the edge of the view.

The main loop: where time “flows”

This block is the heart. It runs 60 times a second and does exactly two things: computes the physics, then draws.

function animate() { requestAnimationFrame(animate); // “call me again on the next frame” const dtReal = clock.getDelta(); // seconds since the previous frame if (state.running) { const simYears = state.yearsPerSec * dtReal; // how many model years to fast-forward advanceTime(bodies, GM_SUN, simYears); // ← all the physics lives here } updateVisuals(false); // move the balls to the new numbers controls.update(); // the camera catches up with the mouse renderer.render(scene, camera); // show the frame }

Want time to run twice as fast by default? Find yearsPerSecond and change the factor. Want the model to “breathe” more accurately? Make BASE_DT smaller (slower) or larger (faster, but rougher).

The camera: its own orbit around the chosen point

The Three.js library only knows how to draw. Controlling the camera is on us, so the code contains its own small OrbitCam class — three lines to plug it in, about a hundred lines of arithmetic inside:

const controls = new OrbitCam(camera, renderer.domElement); controls.enableDamping = true; // inertia: the camera eases after the mouse controls.minDistance = 2.5; // do not fly into the Sun controls.maxDistance = 900; // do not lose the system out of sight

Every frame controls.update() does the same thing: it looks at where the camera stands relative to the target point, converts that into two angles and a distance, adds the turns coming from the mouse and converts everything back into coordinates. Plus two small functions: focusOn(bodyNumber) flies in to a planet, and followTarget() drags the camera after the selected planet every single frame. They are what creates the “I am flying behind Saturn” effect.

The home-made “controller” was not chosen out of laziness: this way the page needs one library file instead of two, which means fewer things that can fail to download when you open it.

How the starting orbit is born

An interesting spot is planetSpec. That is where a planet is handed its initial velocity, and it is not taken “by eye” but straight from the formula in section three:

const v0 = circularSpeed(GM_SUN * state.sunMass, r0) * speedFactor * dir; // circularSpeed(gm, r) = √(gm / r) — that very circular speed // speedFactor = 1 → a circle; 0.8 → an ellipse; 1.5 → it escapes // dir = 1 or −1 → clockwise or against it

Map: “I want to…” → “look here”

I want toWhere to look
…add a planet or move an orbitthe PLANETS array (field a)
…make the planets bigger or smallerthe size field in PLANETS
…change the strength of gravitythe “Mass of the Sun” slider, or state.sunMass
…change the accuracy and speed of the computationBASE_DT, MAX_STEPS
…stop the planets from pulling on each otherin accelerations you can skip pairs that contain no Sun
…change the colours, the background, the glowglowTexture, starLayer, corona1/2 and the CSS variables at the top of simulation.css
…switch off the distance compressionCOMPRESS = 1 (and be ready for a lot of empty space in the middle)

You want the planet balls to look bigger on screen. Which field do you change?

Now you know where everything sits, so go ahead and break the Universe. On to the experiments.

Section 6 · Practice

Try the experiments yourself

Real understanding arrives not when you have read something, but when you have predicted it — and been wrong. Below are eight experiments: first read exactly what to do, say your prediction out loud, then open the hint and check.

Experiment 1. Turn the mass of the Sun down to 0.3× (slider)

What we do: drag the “Mass of the Sun” slider to the left, to 0.30 ×.

What happens: almost every planet flies off its circular orbit onto a stretched ellipse, and some leave entirely. In the panel on the right their period starts reading “not orbiting — escaping”.

Why: the planets kept their speeds, but the circular speed they need dropped — it depends on √M. Result: a speed surplus. Where a circle fitted before, there is now a hyperbola. Exactly the story of the cannon: too fast a shell leaves forever.

Experiment 2. Turn the mass of the Sun up to 2.5× (slider)

What we do: drag the slider to the right.

What happens: the orbits shrink: planets begin to fall toward the Sun and bounce back, producing very elongated ellipses. With a big enough excess, Mercury and Venus can cross each other's orbits or even fall into the Sun — in which case the planet disappears.

Why: gravity grew while the sideways speed stayed the same — it is no longer enough to keep “missing”. Numerically the new semi-major axis is a′ = a/(2 − v²/GM′), i.e. smaller than before. This case is covered by an automated test: the deviation from theory is under 1%.

Experiment 3. Launch your own body (the “+ Body” button or the C key)

What we do: press it several times. Each new body starts on a circular orbit at a random distance, sometimes travelling the other way.

What happens: at first an almost perfect circle. Then the trail starts to wander: the neighbours pull on the newcomer and its orbit turns into a slow pattern. A body launched against the flow gets a hard kick when they meet — sometimes it is thrown out of the system.

Why: the model honestly computes every pair of bodies, including “planet — planet”. The real Solar System behaves the same way: Neptune was discovered precisely from irregularities in the motion of Uranus.

Experiment 4. Speed the Earth up by 1.5× (one line of code)

What we do: in simulation.js find the line PLANETS.forEach((p, i) => addBody(planetSpec(p, i * GOLDEN))); and change it to:

PLANETS.forEach((p, i) => addBody(planetSpec(p, i * GOLDEN, p.name === 'Земля' ? 1.5 : 1)));

The names in the data table stay Russian on purpose: they are internal keys, and the English labels you see on screen are looked up from them in the L10N dictionary.

What happens: the Earth stops orbiting the Sun — it leaves along an open curve, and its trail draws a beautiful arc that never closes. The other planets stay where they are.

Why: 1.5 is more than √2 ≈ 1.41, the escape factor at that distance. The speed ended up above escape velocity.

Experiment 5. Make the integration step coarse (BASE_DT)

What we do: find const BASE_DT = 0.00025; and set it to 0.0025; — a step ten times bigger.

What happens: the trails become visibly “polygonal”, and the orbit of Mercury — the fastest body — starts to drift and may turn into a looping star pattern.

Why: a 22-day step is too much for Mercury: in that time it covers a serious arc, while the computer keeps assuming the pull was what it used to be. Want accuracy? Set 0.00005: it will compute more slowly, but the trail turns smooth again.

Experiment 6. Put the real distances back (COMPRESS)

What we do: const COMPRESS = 0.62; → const COMPRESS = 1;

What happens: the inner Solar System collapses into a bright dot right next to the Sun, and only the giants stay distinguishable. You will be living on the mouse wheel.

Why: those are the true proportions. The model looked handsome precisely because we told a small lie about distances — an honest, deliberate lie of visualisation.

Experiment 7. Put two bodies on one orbit

What we do: copy the Earth's line inside PLANETS, rename it to “Земля-2” (Earth-2) and keep a: 1.000.

What happens: the two bodies start pulling on each other: the one chasing brakes and falls behind, the one in front speeds up and draws away. This does not last — the orbits drift apart.

Why: it is stable only at special points, when the bodies sit about 60° apart along the orbit (the Lagrange points L4 and L5). That is how Jupiter's “Trojans” live: thousands of asteroids sharing one orbit with the planet and never falling onto it.

Experiment 8. Check that energy is conserved

What we do: pause, select the Earth, remember its speed and distance. Run 20 years, pause again and compare: the readings should not have moved.

What happens: the orbital period stays the same to within fractions of a percent.

Why: the “kick-drift-kick” method adds and loses almost no energy — that is its chief property. It is what keeps models like this alive: you can compute for billions of years and they do not fall apart.

How to get the most out of these experiments.

The rule is simple: prediction first, button second. Say out loud “now it will do this” — then press. It matched: the knowledge is cemented. It did not match: even better, because now you have a real question, and that is worth more than a correct answer.

Section 7 · The road ahead

What comes next

You already know more than it feels like: where orbits come from, why speed matters, how a computer outwits infinity with tiny steps, and where every knob sits in the code. Here is a map of where to grow next.

What you already have in your head

The vocabulary that opens the next doors

You will meet these words in any article about orbits. Once you know them, you stop tripping over the text.

Eccentricity (e)

How stretched the ellipse is: 0 is a perfect circle, 0.9 is very stretched. Earth has 0.017, Halley's comet 0.97.

Kepler's laws

Three rules Newton later derived from his own law: ellipses, “equal areas in equal times”, T² ∝ a³.

Vis-viva

The connective formula: speed, distance and orbit size in one line. Use it to size up “what happens if I speed up”.

Orbital energy

Negative for those that are bound, exactly zero for those that escape. The “potential pit” is the best way to think about gravity.

Hill sphere

The region where a planet is in charge: inside it its moons live their own lives, outside the Sun gives the orders.

Lagrange points

Five “pockets” between two bodies where you can hover and travel along with the planet. Observatories stand there.

Gravity assist

A fly-by of a planet that hands the spacecraft speed as a gift, without a gram of fuel. That is how we reach the outer planets.

Resonance

When orbital periods relate as small whole numbers (2:1, 3:2) and the orbits start to “hold” each other.

The N-body problem and chaos

Why orbits cannot be predicted a billion years ahead: a small difference at the start grows exponentially.

Symplectic integrators

A family of methods (our “kick-drift-kick” among them) that look after energy over long distances.

Post-Newtonian correction

Mercury's orbit precesses a little — general relativity noticed that. The first crack in the Newtonian picture.

Sphere of influence and patching

Tools of real mission design: where the Earth ends and Mars begins, gravitationally speaking.

How to make this same project harder (in order of effort)

  1. Elliptical orbits “like the real ones”. Instead of circular speed, give the planet a speed that accounts for eccentricity (the vis-viva formula does it in one line).
  2. Moons. Give the Earth a Moon and see whether it can keep it next to the Sun (spoiler: yes, if you do not launch it too far away).
  3. Collisions. Right now bodies pass through each other. Add a distance check and merge them, conserving momentum — you get the “giant impact hypothesis” of how the Moon was born.
  4. Comets with tails. A tail always points away from the Sun — a fine exercise in drawing a direction from a vector.
  5. Real glow. Post-processing (bloom) would make the Sun genuinely dazzling.
  6. Textures and lighting. Surface pictures plus an honest day/night terminator, and the model turns into a space photograph.
  7. An exact starting position from real data — then you can compare the model with where the planets actually are.
  8. Relativistic correction — one extra line in the acceleration, and Mercury's perihelion starts creeping the way it does in nature.

Where to play and look further

Universe Sandbox

A proper sandbox: crash planets, change stellar masses, watch the climate. Very close to what you can already do.

Kerbal Space Program

The best textbook of orbital mechanics anyone ever invented. After it, formulas become obvious.

“My Solar System” (PhET)

A tiny browser n-body sandbox: four balls and the very same effects you saw in our model.

SpaceEngine

A walk through a huge Universe — to catch the feel of real distances.

3Blue1Brown

Visual explanations of vectors, derivatives and differential equations — exactly the mathematics standing behind this simulation.

MIT OCW 8.01

A free, complete mechanics course. The first lectures will read easily for you now.

The mathematics that pays off fastest

  1. Vectors — simply “an arrow: where and how much”. All of our physics is written in vectors; you cannot take a step without them.
  2. The derivative = “how fast something changes”. Speed is the derivative of position, acceleration the derivative of speed. After that, formulas stop being incantations.
  3. The integral = “add up many little pieces” — which is exactly what the computer does with its steps.
  4. Conservation laws (energy, momentum, angular momentum) — the cheapest way to predict an outcome without computing anything.
  5. Differential equations — the language nature uses for “how things change”. An orbit is the first and most beautiful example.
  6. Numerical methods: Euler, Runge–Kutta, symplectic schemes — and knowing which one to trust when.
And the door next door: programming.

It is worth redoing these same experiments in Python with numpy and matplotlib: there you will see the same things in numbers and plots, without a single pixel. And if you want beauty — Three.js: you already know enough to read its examples.

Final check. What happens to the Earth's orbit if the Sun in the model is made twice as heavy while the Earth keeps its speed?

Everything you have read can be touched

Open the simulation and walk through the sections from top to bottom: the mass of the Sun, “+ Body”, a coarse step, clicking a planet. Ten minutes with the mouse will cement more than another ten pages.

🚀 Open the simulation