Show HN: Gravity – interactive solar-system simulator, from Newton to Einstein
qunabu.github.io31 points by qunabu 3 hours ago
31 points by qunabu 3 hours ago
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
This is nice. 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! My physics bias would like to see earth forming while it's constituents were orbiting around the sun. In any case, nice visualization. Great job! 14 is misleading though - while the context is one day, the animation depicts axial precession which takes place over ~26,000 years > Einstein How are you handling relativistic effects in the N-body simulation? Not in the sim right now — it's purely Newtonian (symplectic leapfrog, classical gravity). I show the concept on the last slide ("Einstein: gravity is curved spacetime") — a curve in space wrapping around a star/planet that pulls nearby objects into the well. The quantitative case, Mercury's ~43″/century perihelion precession, I'd add next as a 1PN correction — haven't gotten to it yet. Will try to figure it out how to show this Looks great but on mobile the popover covers a quarter of the screen, obscuring the sun I should have mentioned that its not mobile friendly so far. I will try to fix this. It should be better now It works pretty well on iPhone, except the descriptive text fills most of the bottom half of the screen, overlapping the sim which is centered on the screen. If the sim were instead centered on the free space (the top half of the screen) it’d be perfect.
VikingCoder - 31 minutes ago
Iolaum - 13 minutes ago
BigTuna - 28 minutes ago
genpfault - 37 minutes ago
qunabu - 28 minutes ago
stevenalowe - an hour ago
qunabu - an hour ago
qunabu - an hour ago
iainmerrick - 17 minutes ago