I am doing some rewrite of this ikdtree to adapt my situation.
And I find you used nth_element while building a tree. According to my experiments there might be a bug.
Suppose at some point division-axis is 0, which is x-axis, let's use 1-D data to explain:
Suppose we have a vector [0,1,2,2,2,2,2,2,3,4] which is points' x-axis value after nth_element() function call, y-axis value is totally different, say [0,1,2,3,4,5,6,7,8,9]。nth_element() divide these points into different group but not determinately which point is on left or right node. point (2,2) might be on the left or right.
Thus while searching, or delete or add by point. it not guaranteed to find this point.
I am doing some rewrite of this ikdtree to adapt my situation.
And I find you used nth_element while building a tree. According to my experiments there might be a bug.
Suppose at some point division-axis is 0, which is x-axis, let's use 1-D data to explain:
Suppose we have a vector [0,1,2,2,2,2,2,2,3,4] which is points' x-axis value after nth_element() function call, y-axis value is totally different, say [0,1,2,3,4,5,6,7,8,9]。nth_element() divide these points into different group but not determinately which point is on left or right node. point (2,2) might be on the left or right.
Thus while searching, or delete or add by point. it not guaranteed to find this point.