Hi all,

I'm not sure how this topic should best be called, so let me try to illustrate my problem.

Say I have a collection of points (the white ones), randomly scattered across the stage. Now I take one point (the red one) and try to find the one white point that is closest to it. Until now, I'd just check the distance to EVERY single point in the stage (all saved as objects in an Arraylist), and eventually find the one that is closest to my red point. This works quite fine for 1000 points, like in the image to the right. But this is only a very simplified version of what I'm trying to do, and eventually I'm expecting on having many 10k or even several 100k points in the sketch. That's where the calculations are starting to become quite resource hungry.

Is it possible to limit the "distance-checking" between the red point and it's white neighbors to a certain area (e.g. all points within the red circle)? This way I would only have to check a fraction of the total points, thus saving processing power. Is this possible? No idea if I can limit the search to an elliptical area or if it would be rectangular. How can I know if a point is near to my reference point, WITHOUT having to calculate it's position anyways?

I'd be grateful for any pointers! (See what I did there?)

Thanks!

cheers.

UPDATE: Would it perhaps make things easier, if the points where not randomly scattered, but set up on a grid? I'm guessing that it might be easier to reference the points, since they are written to the ArrayList in a more "orderly" fashion.

1