Tutorial 10: Collisions and Spatial Data Structures
Aims
- To look at the uniform grid data structure and compare its performance to brute force for collision detection.
- To get 2D inelastic collisions working.
Exercises
For this tutorial use the code from particles-2D.c.
- Finish the 1D collision detection tutorial from last week if you have not already done so.
- Run particles-2D and check if momentum and kinetic energy are conserved. Try with both brute force and uniform grid collision detection. Are they?
- Modify particles-2D and change the type ‘Real’ to be float instead of double. Again check if momentum and kinetic energy are conserved. Are they?
- How is the program keeping momentum conserved for wall collisions?
- Compare the performance of the brute force and uniform grid approaches to collision detection. Try 1000, 2000, 4000, 8000 particles. Examine the frametimes and plot graphs. What scaling is being exhibited for each technique? (Make sure you use a linear scale for the plots).
- Extrapolate frametime and framerate for 32000, 64000 particles. Now try running those cases and see if prediction matches experiment.
- Modify the program to work for 2D inelastic collisions.