Some experimental gravity engines using Newton's formula to calculate forces between bodies.
The intention of this code is NOT to use it in prduction as python is not knwon for doing such calculation in a fast manner. It was rather written to understand the underlying algorithms and to have a working sketch for transposing into a more performant language, namely C.
Currently implemented:
More links!
- RK Engine Code stolen here
- Great explanation of Barnes-Hut algorithm
- Cython docs, which were extremely helpful to write/optimize CyGravity
Requirements and module itself:
pip install -r requirements.txt
python setup.py install
Cythonzied versions of PyGravity engine(s). Runs much faster due to static typing and less calls into python. Still not really production capable but rather easy to write.
Simple visualization using pygame for Barnes-Hut, run after installation:
pygravity
...or much faster...
cygravity
LEFT CLICK
more bodiesRIGHT CLICK
show Barnes-Hut tree