Inspiration

I really enjoy physics, and have found astrophysics and orbital mechanics particularly interesting. A while back I learned about gravitational N-body simulations: simulations of many particles interacting with each other through gravity. The complexity that arose from such a seemingly simple equation (Newton's Law of Gravitation) was amazing! I wanted to share this experience with other people, so I decided to make an interactive N-body simulation with a simple interface.

What it does

The program simulates the gravitational interactions of many objects. You can move around the simulation, view the properties of each object (such as mass, density, radius, coordinates, and velocity), control aspects of the simulation (such as the time steps and distance scale), and add new objects with customized properties.

How I built it

I made this program in UPBGE, and improved version of the Blender game engine. I wrote the code in python. The central part of this project is the N-body simulation itself. I also wrote this in python, using the vector equation for Newton's law of universal gravitation. Other important equations that were used (for collisions) included conservation of momentum, center of mass, and composite density.

Challenges I ran into

There were plenty of challenges, including limitations with UPBGE's physics engine. I ended up writing a script to calculate all of the necessary physics instead of using UPBGE's physics engine.

Accomplishments that I'm proud of

I am proud of my progress with python, blender, and physics. I was able to write this program in a single day.

What I learned

This project has helped me practice some physics, as well as learn more about UPBGE, including its features and its limitations.

What's next for Gravity Sandbox

Many things can be improved. For one, I would like to make a more intuitive way for applying velocity and forces to objects - perhaps with vectors showing the direction of the applied force and/or trajectories which show you exactly where the object will go. And of course, there is lots of room for aesthetic improvements and optimization.

Built With

Share this project:

Updates