kzampog / cilantro

A lean C++ library for working with point cloud data
MIT License
1.03k stars 208 forks source link

Radius search using kdtree always returns sorted result. #55

Closed Austin1511 closed 4 years ago

Austin1511 commented 4 years ago

Thank you for your great project! When I use KDTree.radiusSearch() in a huge for loop, it always returns the sorted result, and the sorting feature slows down the for loop. Even I changed the sorted class member to false in the nanoflann::SearchParams, I still get the sorted result. Do you know some way to disable the sort. Thank you for your help!

wannesvanloock commented 4 years ago

Radius search indeed returns sorted results. I think it should be straightforward to make this configurable.

If only interested in a limited number of points, I would recommend using kNNInRadiusSearch which I think will be more efficient.

Austin1511 commented 4 years ago

@wannesvanloock Thank you ! That solves my problem. I notice that there is another problem with the radiusSearch() funtion. When I want to search a area with 5 radius, I have to pass 5 * 5 to the radius parameter to get the correct result.

kzampog commented 4 years ago

This was done to imitate the way nanoflann works. Please note that distances returned in search results are also squared!

Austin1511 commented 4 years ago

Ok, understood. A comment on the function may be appreciated. Thanks again!