Show HN: Gravity – interactive solar-system simulator, from Newton to Einstein
This Show HN unveils "Gravity," an interactive solar system simulator built for self-education, explaining orbital mechanics from Newton to Einstein with a guided tour. Its accurate physics, including N-body simulation and real orbital elements, makes complex concepts engaging and accessible. The project, crafted with TypeScript and Three.js, exemplifies a passion for demystifying science through robust web development.
The Lowdown
Gravity is an interactive, web-based solar system simulator, presented as a "Show HN" by a developer aiming to teach themselves (and others) the fundamental principles behind orbits and gravitational mechanics. Dissatisfied with conventional explanations, the creator built this tool to illustrate "why orbits exist" rather than just showing planets moving.
- The simulator features a comprehensive, 23-step guided tour that systematically introduces gravitational concepts. It begins with the two-body problem and Newton's third law, progresses through inertia, the idea of an orbit as "falling and continuously missing," and the different cosmic velocities.
- Advanced topics covered include the Earth-Moon system, the Sun's motion and helical orbits, and detailed explanations of real-world phenomena like Voyager 1 & 2's gravity assists (aligned with actual 1977-1989 dates). The tour culminates with an intuitive visualization of Einstein's concept of gravity as curved spacetime, often depicted as a rubber-sheet well.
- Physically, the simulator strives for accuracy, utilizing real radii, masses, and J2000 orbital elements for each body. Planetary positions are derived by solving Kepler's equation per frame. Users can switch to an N-body mode, employing a symplectic leapfrog integrator, which demonstrates honesty with a live energy drift display (~1e-6%).
- A key design choice addresses scale: while physics calculations run in real Astronomical Units (AU), the visual representation offers a toggle between true scale (where objects are too small to see) and a log-remapped "visual" scale for usability.
- Technologically, the project is a client-side application built with TypeScript, Three.js, and Vite, requiring no backend and functioning offline. Surface textures are procedurally generated, except for Earth's, and the entire source code is available on GitHub.
This "Show HN" demonstrates an impressive blend of educational ambition and technical execution, providing a powerful, interactive tool for understanding the intricate dance of celestial bodies.