//Collision Detection //Spatial hashing technique //by Flux 12/19/05 // Notes: // This demonstration shows one way of implementing // a fast collision detection routine using spatial hasing. // Note that this trades memory for processing speed. // The basic idea is to avoid comparing every node with // every OTHER node, just their neighbors on a grid. // This avoids the n^2 calculation time needed when comparing // every node to every other node and speeds things up happily. mass test[]=new mass[200]; // Declare a set of 200 point masses. hashVec hv=new hashVec(); // Define a hash lookup table and tools found in hashlookup.pde float massRadius=15; boolean drawCollisions=true; void setup() { size(400,220,P3D); ellipseMode(CENTER); for(int i=0;i