jlblancoc/nanoflann

Support for range-based search?

szhorvat opened this issue · 1 comments

Does nanoflann have any facilities for finding all points within a box? To give a 2D example, we may be looking to list all $(x,y)$ points so that $x \in [x_1, x_2]$ and $y \in [y_1, y_2]$.

Motivation: If my understanding of $k$-d trees is correct, the natural way to search is precisely in a box. My application requires listing all points within a given region of a non-trivial shape. I can determine the bounding box of this region, so one approach is to list all points within the box, then test each of these points for inclusion within the region. With radiusSearch, I can implement the same approach, but use a bounding disk instead of a bounding box. However, if the underlying mechanism operates with a bounding box anyway, I am wondering if using boxes would be faster. My shape tends to be long and narrow, and when it happens to be aligned with the axes, the area of its bounding box will be much smaller than that of its bounding disk. This translates into having to test fewer points.

I think your approach in #185 is ok for your goal. Perhaps my additional advice is to use L1 distances to save one double multiplication for each dimension of each distance calculation.