Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for range-based search? #184

Open
szhorvat opened this issue Nov 16, 2022 · 1 comment
Open

Support for range-based search? #184

szhorvat opened this issue Nov 16, 2022 · 1 comment

Comments

@szhorvat
Copy link
Contributor

szhorvat commented Nov 16, 2022

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.

@jlblancoc
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants