A fun physics simulation where you can draw planets and watch them interact!
Report Bug
·
Request Feature
Table of Contents
It all started when I had the bright idea of making a planetary simulation. After doing a bit of research, I came across the n-body problem. The rest was history. Anyhow, this is a basic simulation of n-body physics using a KSK method (Kick, Step, Kick) to model planetary motion. I hope you have fun playing with it!
There's a few libraries that you'll need to get installed before you can start messing around with playlists. To get a local copy up and running follow these simple example steps.
This is an example of how to list things you need to use the software and how to install them.
- pip
pip install numpy pip install pygame
- Clone the repo
git clone https://github.com/TSKoduru/NBodySimulation.git
All you'll need to do is run the program, which will lead to a popup containing the simulation. Click and drag to release a new planet; A white line will be drawn containing the trajectory. Planet masses are random, but are
fairly similar. Each body will have a trail behind it; As you add more bodies, you'll be able to visualize them interact as their trails distort. Here's an example simulation with 5 bodies:
- KEYBINDS:
- Press 'esc' to exit the simulation.
- Press 'r' to reset the simulation to 0 bodies.
- Click and drag to add a new body.
- Add a system to combine planets; i.e, when they collide, insert a planet with their combined mass
- Fix bug where two planets that collide head-on get launched off map (This is because as their distance goes to 0, the gravitational force on them goes to infinity.)
- Add system to allow user to choose planet sizes
Note: I've stopped developing this proejct, so open source contributions are welcome. See the contributions section below.
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Distributed under the MIT License. See LICENSE.txt for more information.
Teja Koduru - [email protected]
Project Link: https://github.com/TSKoduru/NBodySimulation
