Celestial Body Simulator
Inspiration
We were inspired by our curiosity of astrophysics and the movement of celestial bodies and the evolution of choatic systems. Specifically, we wanted to visually see how large masses in the universe work physically. Furthermore, our inspiration for the graphics aspect was driven by a passion to make something visually appealing and user-friendly.
What it does
Celestial Body Simulator is an interactive gravity playground. In N-Body Mode, you place massive celestial bodies on your cursor, set their initial velocity depending on your mouse movement, and watch them orbit and trace glowing paths in space. In Blackhole mode, you hold down your mouse to spawn hundreds or even thousands of particles which orbit around massive black holes, with the amount customizable.
How we built it
We built the project in Python using Pygame for the window, input, and drawing, and NumPy for the math operations in the physics. We used Newton's laws of universal gravitation, and also modified it slightly for visual aspects and so it doesn't break. In N-body mode, we calculated the forces between celestial bodies by looping through every pair and calculating their following acceleration and velocity. In Blackhole mode, we set the black holes to be stationary, and we calculated the forces and updated only the particle acceleration and velocity. To calculate these math operations, we used numpy vectorization for faster math as it is wrapped in the C language and optimized for vectors. Since all units are real-world units, we used a projection to convert between the math units and screen coordinates. Finally, we added the starfield background by randomly generating coordinates with random radii, and added a slider and buttons for simple user-interface.
Challenges we ran into
A big problem we ran into was scope. Since this was one of our first hackathons we weren't sure how ambitious we should be. Somethings had to be scaled up and something had to be scaled down. Original we thought about making it 3d but we soon realized it was a bit to ambitious for the time we had. On the more technically side we ran into a lot of problem when it came to the physics and math part of it and using numpy to vectorize the physics and math.
Accomplishments that we're proud of
We're really proud of how well we were able to simulate actually physics with code along with how visually appealing it is.
What we learned
We learned how N-Body simulators work and how the mass of celestial bodies affect others. We also learned more about numpy and pygame, specifically learning how to vectorize values with pygame and how to make gui's with numpy
What's next for Celestial Object Simulation
If given more time we would expand the capabilities of the simulation such as being able to move around the screen, being able to set velocities and to make stable orbits, turning it 3d, etc.
Log in or sign up for Devpost to join the conversation.