Show HN: Browser-based interactive 3D Three-Body problem simulator (trisolarchaos.com)
Features include:
- Several preset periodic orbits: the classic Figure-8, plus newly discovered 3D solutions from Li and Liao's recent database of 10,000+ orbits (https://arxiv.org/html/2508.08568v1)
- Full 3D camera controls (rotate/pan/zoom) with body-following mode
- Force and velocity vector visualization
- Timeline scrubbing to explore the full orbital period
The 3D presets are particularly interesting. Try "O₂(1.2)" or "Piano O₆(0.6)" from the Load Presets menu to see configurations where bodies weave in and out of the orbital plane. Most browser simulators I've seen have been 2D.Built with Three.js. Open to suggestions for additional presets or features!
45 comments
[ 2.4 ms ] story [ 67.3 ms ] threadWere 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?
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)
Amd this does seem predictable, I saw this for almost a minute
Computing the trajectory of a 3 body problem is a comparatively simple task.
The two grains of truth are that the solutions for most starting conditions are not analytic, roughly meaning that they can not be expressed in terms of functions. The other being that the numerical solution to an ODE diverges exponentially.
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.
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.
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.
Oh this brings memories. I have tried to create a little bit of 3D→2D renderer in TP 6.0 but precision was never enough for nodes to not fall apart and 80286 speed was too slow to render anything meaningful except maybe a cube.
(a) There's a method that works well for monopolar sources (gravitational + electrostatic particles) called the Barnes-Hut method. You effectively divide space up into a quadtree (2D) or octree (3D), and in each cell work out the center of mass / total charge. You make particles in "nearby" cells (using a distance criterion that can be adjusted to speed up/slow down the simulation in a trade off with accuracy) interact directly, and far away cells you just use the center of mass to work out the interaction between any given 'far' particle and the particles in that cell. The method is O(N log N) but in practice, this is 'good enough' for many applications.
(b) uses a more rigorous technique called the Fast Multipole Method which is O(N), where rather than just using the center of mass or sum of charges, you expand the potential from particles out into higher order components which captures the distribution of particles within each cell. This also means you can capture more complex potentials. The downside is that this is a nightmare to implement in comparison to the Barnes-Hut method. Each cell has it's own multipole expansion, and it is 'transferred' to work out the additive contribution to every 'far' cell, calculating a 'local' expansion. Typically people use the most compact representation of these potential expansions which uses Lagrange polynomials, but this is a pain.
I've been working on some n-body code too, currently native only though: https://www.youtube.com/watch?v=rmyA9AE3hzM
It’s one of those things that seems so obvious and yet actually seeing it is a really important step in understanding.
Simulating a four-body problem from the point of view of a telluric planet being juggled around by three stars. It's supposed to emulate the evolution of trisolarans from the "Three Body Problem" novel by Liu Cixin.
one issue i have always had with the n-body calculations is how can you be sure there is exactly n?
https://lweb.cfa.harvard.edu/seuforum/questions/#:~:text=EVO...
https://ned.ipac.caltech.edu/level5/Peacock/Peacock3_3.html