LogicEu / gsim

Toyful N-body simulation of gravitational systems in 2D.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gsim

Toyful and simple 2D N-body simulation of gravitational systems written in C. Handles collisions and provides fun interactions you can play with. It implements the Barnes-Hut approximation algorithm for N-body simulations through the use of a QuadTree data structure, spatialy accelerating collisions and gravity calculations. It runs single threaded and does all computations on the CPU side, even the rendering. Built on top of my rendering engine, the simple pixel engine.

alt text

Controls

Click and drag the mouse on top of the background to move the camera. Click and drag on the bodies to move them.

Key Action
W Move camera up
S Move camera down
D Move camera to the right
A Move camera to the left
Z Zoom in
X Zoom out
O Decrease size of physics time step, slow down time
P Increase size of physics time step, speed up time
G Turn gravity on and off
Q Switch the rendering of the quadtree on and off
LShift Switch the rendering of trails on and off
Space Pause the time of the physics in the simulation
R Restart the simulation
Escape Quit

Third Party

spxe depends on OpenGL libraries to manage windows and render graphics independently of the platform.

Try it

If you have all third party dependencies installed on your system you can easily try gsim with the following commands:

git clone --recursive https://github.com/LogicEu/gsim.git
cd gsim
make # or ./build.sh
./gsim -help

Compile

Both build script currently work on Linux an MacOS. The compiled binary will be created at the root of the repository.

make # or ./build.sh

Make sure to clean after compiling.

make clean # or ./build.sh clean

About

Toyful N-body simulation of gravitational systems in 2D.

License:MIT License


Languages

Language:C 97.3%Language:Shell 1.8%Language:Makefile 0.9%