Simulation - Spheres in Collision
Path of the code: [02_sphere_collision]
This scene models a set of particles representing spheres falling under gravity.
Each particle is associated to the following parameters: position \(p\), speed \(v\), forces \(f\), as well as radius and color.
The position and speed of each particle is updated through time using a discrete integration in the file simulation/simulation.cpp
- - \(v^{k+1} = v^{k} + \Delta t\;f^{k}\)
- - \(p^{k+1} = p^{k} + \Delta t\;v^{k+1}\)
Collisions
Add the collision detection and response between the spheres and boundary faces of the cube using impulse based response on the sphere velocities. The collision response can be implemented in two steps:- - First applying impulse response to generate the bouncing (with the cube, and other particles)
- - Second canceling the velocity components that still generate a penetration (with the cube, and other particles)
Possible extension
- Allow the user to move the box interactively. (In this case, the particles that goes out of the cube will need to get their position projected back inside the cube.)
- Speed-up the collision detection in building a spatial acceleration structure such as a regular grid storing neighboring particles.