I recently thought that if life supposedly happened by chance then it should be same for the three-body problem: naturally occurred solutions floating here and there somewhere.
Were you by any chance inspired to make this because of the three body series by Cixin Liu? Or were you moreso just inspired because the simulation/math/physics are interesting?
Thanks! The Three-Body series definitely helped spark the idea, and the URL is a little nod to the books. I also took some simulation classes back in college, so the math and physics side pulled me in too. It’s crossed my mind that it could be fun to add a kind of Trisolaran mode that tracks a small planet and how habitable its position is throughout the orbits.
I spent a long time playing with the sim. Nice work.
Most of the random data sets that I ran ended up with a two body system, where the third body was flung far into space never to return. However, some of these were misleading. I had one running for 15 minutes at 5x, and the third body did eventually return.
Question, can you mathmatically plot a trajectory across time X and energy required to see when it's met and how long it would take given a start position or something? Or is the simulation so complex that you can never project.
Oh never mind I see answers to this elsewhere here, cheers.
> However, some of these were misleading. I had one running for 15 minutes at 5x, and the third body did eventually return.
That's not misleading. Real three-body orbital systems show this same behavior. Consider that such a system must obey energy conservation, so only a few extreme edge cases lose one of its members permanently (not impossible, just unlikely).
Ironically, because computer simulators are based on numerical DE solvers, they sometimes show outcomes that a real orbital system wouldn't/couldn't.
The 3D presets are the standout here, especially the ones that move in and out of the orbital plane. The interaction feels smooth, and it’s great to see this level of detail running in the browser.
This is really lovely work! Simple to use, surprisingly solid, and just a pleasure to poke around with. The fact it runs in the browser is a bit of magic on its own.
One idea for later might be a few preset systems, such as Alpha Centauri or other known three-body systems. It would give people a quick way to drop into something real before they start making chaos of their own.
Thanks so much, really appreciate it! I’ve been focusing the presets on stable or interesting solutions that aren’t tied to real systems, but adding a few real examples like Alpha Centauri would fit in nicely. I’ll keep that on the list for future updates.
Thank you! Your 2D version is great, I love seeing how different people approach this stuff. As for integrators, I currently only have Velocity Verlet and RK4 (can change in the advanced settings). I started with just Verlet, but to get some of the presets to behave properly I ended up needing RK4 as well. I’ve been thinking about adding adaptive methods next, but I'll take a look at the methods you've got listed too. Everything is still running in plain JS for now. I started moving some of the work into web workers but haven’t finished that part yet.
The link points to one of the stable solutions, and there are actually quite a few of those. The problem is that there’s no general closed form that tells us exactly where the bodies will be in the future, so we rely on numerical methods to approximate the motion. If you hit Reset All a few times or add more bodies, you’ll start to see the chaos
There actually is an analytical solution using a power series that actually converges (Karl Sundman's work). Unfortunately, the universe still mocks our attempts. Though the series converges, it does so incredibly slowly. From Wikipedia:
The corresponding series converges extremely slowly. That is, obtaining a value of meaningful precision requires so many terms that this solution is of little practical use. Indeed, in 1930, David Beloriszky calculated that if Sundman's series were to be used for astronomical observations, then the computations would involve at least 10^8000000 terms.
> No physics expert but isn't this unpredictable (based on what I saw in series) ?
A three-body orbital problem is an example of a chaotic system, meaning a system extraordinarily sensitive to initial conditions. So no, not unpredictable in the classical sense, because you can always get the same result for the same initial conditions, but it's a system very sensitive to initial settings.
> Amd this does seem predictable, I saw this for almost a minute
The fact that it remains calculable indefinitely isn't evidence that it's predictable in advance -- consider the solar system, which technically is also a chaotic system (as is any orbital system with more than two bodies).
For example, when we spot a new asteroid, we can make calculations about its future path, but those are just estimates of future behavior. Such estimates have a time horizon, after which we can no longer offer reliable assurances about its future path.
You mentioned the TV series. The story is pretty realistic about what a civilization would face if trapped in a three-solar-body system, because the system would have a time horizon past which predictions would become less and less reliable.
I especially like the Three Body Problem series because, unlike most sci-fi, it includes accurate science -- at least in places.
> Open to suggestions for additional presets or features!
Anaglyphic (red/cyan) 3D rendering would be nice. I've created a lot of anaglyphic 3D apps over the years, but they're no longer very popular -- I suspect it's the goofy glasses one must acquire and wear.
But a true 3D view of an orbital simulator like this greatly increases its impact and tutorial value.
An LLM couldn't provide results for a sim like this, compared to a relatively simple numerical differential equation solver, which is how this sim works. Unless you're asking whether a sim like this could be vibe-coded, if so, the answer is yes, certainly, because the required code is relatively easy to create and test.
Apart from a handful of specific solutions, there are no general closed-form solutions for orbital problem in this class, so an LLM wouldn't be able to provide one.
I think I found a bug: after pausing, moving a body and unpausing, I cannot move the camera. Changing "follow" to something and back to "none" helps.
Were you by any chance inspired to make this because of the three body series by Cixin Liu? Or were you moreso just inspired because the simulation/math/physics are interesting?
Most of the random data sets that I ran ended up with a two body system, where the third body was flung far into space never to return. However, some of these were misleading. I had one running for 15 minutes at 5x, and the third body did eventually return.
That's not misleading. Real three-body orbital systems show this same behavior. Consider that such a system must obey energy conservation, so only a few extreme edge cases lose one of its members permanently (not impossible, just unlikely).
Ironically, because computer simulators are based on numerical DE solvers, they sometimes show outcomes that a real orbital system wouldn't/couldn't.
One idea for later might be a few preset systems, such as Alpha Centauri or other known three-body systems. It would give people a quick way to drop into something real before they start making chaos of their own.
Anyway, cracking project.
I did something similar, mostly 2D here:
https://www.nhatcher.com/three-body-periodic/
(Mine is just unfinished)
In the avobed shared you can go to the settings a pick an integrator. I did the integrators in wasm although I suspect js is just as fast.
Color me impressed! I love the ammount of settings you can play with. I still need to understand what happens whe yu add more bodies though.
Amd this does seem predictable, I saw this for almost a minute
The corresponding series converges extremely slowly. That is, obtaining a value of meaningful precision requires so many terms that this solution is of little practical use. Indeed, in 1930, David Beloriszky calculated that if Sundman's series were to be used for astronomical observations, then the computations would involve at least 10^8000000 terms.
A three-body orbital problem is an example of a chaotic system, meaning a system extraordinarily sensitive to initial conditions. So no, not unpredictable in the classical sense, because you can always get the same result for the same initial conditions, but it's a system very sensitive to initial settings.
> Amd this does seem predictable, I saw this for almost a minute
The fact that it remains calculable indefinitely isn't evidence that it's predictable in advance -- consider the solar system, which technically is also a chaotic system (as is any orbital system with more than two bodies).
For example, when we spot a new asteroid, we can make calculations about its future path, but those are just estimates of future behavior. Such estimates have a time horizon, after which we can no longer offer reliable assurances about its future path.
You mentioned the TV series. The story is pretty realistic about what a civilization would face if trapped in a three-solar-body system, because the system would have a time horizon past which predictions would become less and less reliable.
I especially like the Three Body Problem series because, unlike most sci-fi, it includes accurate science -- at least in places.
Anaglyphic (red/cyan) 3D rendering would be nice. I've created a lot of anaglyphic 3D apps over the years, but they're no longer very popular -- I suspect it's the goofy glasses one must acquire and wear.
But a true 3D view of an orbital simulator like this greatly increases its impact and tutorial value.
An LLM couldn't provide results for a sim like this, compared to a relatively simple numerical differential equation solver, which is how this sim works. Unless you're asking whether a sim like this could be vibe-coded, if so, the answer is yes, certainly, because the required code is relatively easy to create and test.
Apart from a handful of specific solutions, there are no general closed-form solutions for orbital problem in this class, so an LLM wouldn't be able to provide one.