jlblancoc / nanoflann

nanoflann: a C++11 header-only library for Nearest Neighbor (NN) search with KD-trees
Other
2.26k stars 491 forks source link

fix bug that the min and max elem in middleSplit_ is wrong sometimes. #231

Closed YongZouGN closed 9 months ago

YongZouGN commented 10 months ago

if span is always equal to max_span and equal to 0,if condition(span > (1 - EPS) * max_span) is always false, the min_elem and max_elem are always the default initailized value 0, this is a bug. so the max_elem and min_elem should inlitialized while setting max_span. This bug could be occur while there all the points which has the same location(x,y,z).

YongZouGN commented 10 months ago

test data, a large numer of points which have the same negative coordinate could trigger this issue

jlblancoc commented 9 months ago

Hi @YongZouGN ! Sorry for not coming back sooner. If this remains being a real bug, please, add a minimal unit test case that fails with the current code, and gets fixed with your patch and we'll review it.