This project implements Verlet integration to simulate particle physics in C, using GLFW for real-time visualization. This is a buildable project via Make which generate a binary executable that can run the different scripts.
Verlet integration is a numerical method used to simulate the motion of particles with great stability and minimal computational cost, even when forces become complex. This project leverages the Verlet algorithm to simulate realistic particle physics, including collision detection and response, in a 2D space. GLFW provides real-time rendering, enabling visual feedback and parameter adjustments like gravity, particle interaction, and potential fields.
- Stable Verlet Integration: Accurately simulates particle movement with position-based integration.
- GLFW Visualization: Real-time rendering of particles in a 2D environment.
- Collision Handling: Particle-to-particle and boundary collision detection with response.
- Performance Efficient: Handles a large number of particles smoothly.
Verlet-Particles/
├── bin/ # Compiled binaries
├── include/ # Header files
├── libs/ # External dependencies (e.g. GLFW, GLUT, Unity added as submodules)
├── scripts/ # Example scripts (e.g., gas_simulation.c, impulse_simulation.c)
├── src/ # Core simulation logic
├── tests/ # Unit tests
├── assets/ # Assets for visualization (e.g., GIFs, images)
├── Makefile # Build rules
└── README.md # DocumentationTo build and run the project, ensure the following are installed:
- C compiler (e.g., GCC or Clang) - add it to your system environment PATH
- Make for building the project
sudo apt update
sudo apt install -y build-essential \
libgl1-mesa-dev mesa-common-dev \
libx11-dev xorg-dev \
libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev \
libglfw3-devInstall MSYS2 and use its package manager:
pacman -S mingw-w64-x86_64-glfw mingw-w64-x86_64-gccAfter installing necessary stuff, it is very straight forward to use my project.
- Clone the repository recursively:
git clone --recursive https://github.com/davidomanovic/particle-simulator.git- Build the project with
makesimply by writing in terminal (inside the project repo):
make- Run the simulator binary either by double clicking the executable inside the generated
bin/folder, or simply in terminal
./bin/particle_simulator.exeContributions are welcome! Fork this repository, make your changes, and submit a pull request.
This project is licensed under the MIT License.
