FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Programs
(Moderators: fry, REAS)
   finding closest object
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: finding closest object  (Read 304 times)
josh kopin
Guest
Email
finding closest object
« on: Aug 21st, 2003, 10:40pm »

Say I've got 50 circles, with one square. The circles bounce around off each other and the walls. The closest circles to the square turn red. What is the most efficient way to check whether or the circles are colliding with each other? If they are the _closest_ to the square? The only ways I have thought of involve checking each and every circle against every other one... Any ideas?
Thanks,
Josh
 
fry


WWW
Re: finding closest object
« Reply #1 on: Aug 22nd, 2003, 1:25am »

you check em all, yep..  
 
there are more advanced algorithms for diving up space (look up the barnes-hut algorithm in google) if you're modeling zillions of things, but for 50 objects, comparing them to one another should be fine.
 
on tiny speedup is to not bother w/ the square root for the distance unless things are within a certain range of your object, but for 50 things it's prolly not worth it.
 
Pages: 1 

« Previous topic | Next topic »