Show HN: Gravity β interactive solar-system simulator, from Newton to Einstein
92 points - today at 11:46 AM
Just for fun and self education, I've built this over a weekend to teach myself why orbits exist, not just show planets going around. Something that was never clearly explain to me in school. It opens with a guided tour that builds the idea up step by step: two bodies and the equal/opposite force, inertia (the Sun is removed and Earth just drifts straight), then "an orbit is falling and continuously missing," cosmic velocities with a little rocket, Voyager 1 & 2's real gravity assists (the clock runs the actual 1977β1989 dates so the planets orbit into their grand-tour alignment and the slingshots line up), and it ends on Einstein β gravity as curved spacetime, the classic rubber-sheet well. What's real: every body uses its real radius/mass and J2000 orbital elements; positions come from solving Kepler's equation each frame. You can toggle to an N-body mode (symplectic leapfrog) that shows live energy drift (~1e-6%) so you can see the integrator is honest. The only thing faked is scale β at true scale you can't see anything β so there's a toggle between true scale and a log-remapped "visual" scale, with physics always running in real AU. Tech: TypeScript + Three.js + Vite, fully client-side, no backend, works offline (surface textures are generated procedurally from value-noise; only Earth uses a real image). Source: https://github.com/qunabu/Gravity
Happy to answer questions β and feedback on the physics or the explanations is very welcome. This project might be totally inaccurate in terms of real physics, this is how i do understand this on my own - i'm happy to confront this with reality
Comments
Reading stuff like this always makes me think "well that is fortunate." Of course there is survivorship bias so its not exactly surprising. But it also makes me wonder what could change the status quo.
I guess these are the things that could change it:
- suns becomes lighter (earth shoots into space)
- earth accelerates (earth shoots into space)
- sun becomes heavier (earth falls into sun)
- earth decelerates (earth falls into sun)
I guess in theory some large interstellar object could pass to close too earth and fling us off into space or into the sun.
I don't like the explicit split of Newtonian and relativistic gravity, this is often how it's presented in educational content, but it creates too much confusion; for instance it gives the illusion that they are somehow separate theories even though Newtonian gravity is a limiting case of Einsteinian gravity when v << c and gravitational fields are weak (see Poissons eq for Newtons gravitational potential.
Lastly, you should consider rendering spacetime similar to Alessandro Roussels spacetime visualization https://www.youtube.com/watch?v=wrwgIjBUYVc; probably the best and most innovative one I've seen.
I did laugh at how the Gravity built the Earth, with a tiny North America and all, and then as more mass was accumulated, North America got to get bigger and bigger and bigger!
In any case, nice visualization.
How are you handling relativistic effects in the N-body simulation?
no computers, no calculators, barely working telescopes looking at the moons orbiting Jupiter
(don't be limited by episode title, lots of amazing astrophysics in there)