I do not currently have a set of those glasses so I can't test it, but three.js has this and it's pretty easy to add. There should be an "Anaglyph 3D" checkbox at the bottom of the configuration settings. Let me know if you are able to test it out.
Thanks! I tried the anaglyphic option, but the data being provided to the engine doesn't include third dimension data (so the orbits are essentially flat in the third dimension). Also the orbital colors interfere with the anaglyphic effect (which normally expects white graphic data that it then splits into red and cyan).
I think adding third-dimension data would solve or mitigate the other issues, because full-color anaglyphs are possible, although at a reduced degree of subjective separation between the views.
Thanks for pointing out to me that an anaglyphic option is present, which I managed not to notice the first time.
Anyway, with third-dimension data, the anaglyph option ought to work -- for hard-core, old-fashioned red-blue eyeglass wearers. :)
I just added that option. It wasn’t there when you initially looked :). Are you using one of the 3D presets/random config or are you using a 2D preset? I'll order a set of glasses so I can test. Not very familiar with this so would be fun to experiment.
Thanks for adding it! I think anaglyphs are super underused in 3D visualization. The grid lines look pretty good in 3D but the orbits themselves aren't as sharp - it might be the coloring or it might be that the angular distance between the eye views is too large.
Yeah, I used Claude Code, definitely started as a vibe-coded thing. First pass was just basic physics + Three.js rendering. But once I saw it working, I spent some more time on better numerical stability and adding presets from stable 3D orbits, so it turned into more of a real project.
Yes, the softening factor keeps the forces from getting too big when bodies get close together. Better for the visualization but not very accurate to leave it in.
I'm using https://threejs.org/docs/#Line2 which does support variable thickness - you can change this via the Trail Thickness slider. I think older versions did have some issues with line width.
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.
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.
Symplectic integrators are the approach I used for some old galaxy simulations. Page 5 on the attached paper was my main reference, eq 22
https://arxiv.org/pdf/cond-mat/0110585
I believe this is used in several academic codes for long term N-body calculations.
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
An interesting corollary to this is that even if the future trajectory of a general 3-body orbit is predictable in theory using numerical methods (and infinite precision calculations), in practice the use of finite-precision floating point means that after some time the trajectory predicted by an ODE solver will diverge from the mathematically-true trajectory. Even symplectic integrators have this problem. More details on the general case of chaos are provided by this insightful blog post:
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.
> the computations would involve at least 10^8000000 terms.
Well we could speed up that simulation pretty easily, just arrange the actual masses and velocities somewhere...
Then I thought, is there a way to scale the distances, masses and velocities to create a system with the same, but proportionally faster behavior?
One guess as to perhaps why not: As distances get small, normal matter bodies will get close enough to actually collide. Perhaps some tiny primordial black holes would be useful.
When you say 'stable' here, do you mean 'periodic' or are these solutions actually stable in the face of small perturbations (as opposed to the sensitive dependence on initial conditions that we'd expect from a chaotic system)?
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.