tags:

views:

141

answers:

2
+1  A: 

This is a naive algorithm:

  1. Get the list of points within the convex shape.
  2. Of those, find the minimum distance to any other point.
  3. Rank all points by their respective R values
  4. Select the top x points.

For (2), thinking of this as a radius search still means you end up calculating the distance from each point to each other point, because finding out whether a point lies within a given radius of another point is the same thing as finding the distance between the points.

To optimize the search, you can divide the space into a grid, and assign each point to a grid location. Then, your search for (2) above would first check within the same square and the surrounding 8 squares. If the minimum distance to another point is within the same square, return that value. If it is from one of the 8 and the distance is such that a point outside the 9 could be closer, you have to then check the next outline of grid locations outside those 9 for any closer than those found within the 9. Rinse/repeat.

richardtallent
This only works if the "orange" points are known in advance - I think he's trying to find/generate points that aren't close to the others.
Reed Copsey
I can find nearest points pretty quickly with a QuadTree structure, that code I already have standing by. The problem is that the number of points inside the convex hull is enormous. To get the kind of accuracy I need would require millions upon millions of searches. The image shows a rather nice distribution, but sometimes the points are extremely clustered into far away galaxies.I need this to be really fast since it's called within a GUI and I need to keep the refresh rate over 30 frames per second. I appreciate the answer, but this won't do.
David Rutten
@Reed: my algorithm was comparing *every* point to *every other* point, so it would automatically identify which ones (based on some "TOP x"-style threshold should be considered "orange."
richardtallent
+1  A: 

This is a good example of a problem that may be solved using KD-Trees... there are some good notes in Numerical Recipes 3rd Addition.

If you are trying to find point locations that are relatively isolated... maybe the center of the largest quad elements would be a good candidate.

The complexity would be O(n log^2 n) for creating the KD-Tree... and creating a sorted list of quad sizes would be O(n Log n). Seems reasonable for even a large number of points (of course, depending on your requirements).

tbischel
Interesting. I'll pursue this, it definitely sounds promising. Either find empty rectangles in Kd or Quad trees, or perhaps the centers of large triangles in a Delaunay triangulation.
David Rutten
one other thing may be that area could be misleading... you could have a tall skinny box, so it would actually be close to a point. Probably a better metric would be the quad's smallest edge length, and find the quads that maximize this metric.
tbischel