Collision Detection using Sweep and Prune algorithm

This is a companion sketch to my last post on the spatial hashing algorithm. It uses the same core code for the particle and vector classes.

If you want to know how the sweep and prune works then look at this video, I created my code based on the description in the video.

This sweep and clean appears to perform better than the spatial hash algorithm, at least for the initial conditions used in both sketches.

1 Like