coding

Spurred by a query on the Processing forum, I’ve had a go at grid-based collision. Instead of checking every ball against all of the others to see if there’s a collision, you just look to see if there’s a ball in the same or neighbouring grid cell.
Move the mouse over the grid to see which cells are checking which neighbouring cells.


It doesn’t yet deal with mass, nor does it cope well when the balls start out as overlapping. Refresh the page if the balls go mental!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.