by @tlehman
- Euclidean space (no curvature)
- Newtonian gravity is the only force
- All bodies are spheres
- Existence of an NVIDIA GPU
- Computer runs Linux
- OpenGL is present
Each of the
The bodies need to be initialized with:
- masses
- positions and
- velocities
Once initialized, the simulation loop will take over.
The state of the universe is an array of length
typedef struct body {
float r; // radius
float m; // mass
float x,y,z; // position
float vx,vy,vz; // velocity
float fx,fy,fz; // force on object (added up each sim loop)
} body;To update the state of the universe, each unique pair of bodies needs to be selected to calculate it's mutual gravitational attraction. So with
We can pass in the