Package org.ddogleg.nn.alg
Class KdTreeConstructor<P>
java.lang.Object
org.ddogleg.nn.alg.KdTreeConstructor<P>
Creates a new
KD-Tree
from a list of points and (optional) associated data. Which axis is used
to split the data and how to split the data is determined by the AxisSplitter
passed in.
A child node can be null if it is a leaf and there was no data in that direction.
WARNING: A reference to the input points is saved. Do not modify the input until the K-D Tree is no longer needed.
This reduced memory overhead significantly.-
Constructor Summary
ConstructorDescriptionKdTreeConstructor
(KdTreeDistance<P> distance) Creates canonical K-D Tree by selecting the maximum variance axis and splitting the points at the median.KdTreeConstructor
(KdTreeMemory<P> memory, AxisSplitter<P> splitter) Constructor which allows for maximum configurable. -
Method Summary
Modifier and TypeMethodDescriptionprotected KdTree.Node
computeBranch
(List<P> points, @Nullable DogArray_I32 indexes) Given the data inside this particular node, select a point for the node and compute the node's childrenprotected KdTree.Node
computeChild
(List<P> points, @Nullable DogArray_I32 indexes) Creates a child by checking to see if it is a leaf or branch.Creates a newKdTree
from the provided points.
-
Constructor Details
-
KdTreeConstructor
Constructor which allows for maximum configurable.- Parameters:
memory
- Used to recycle data
-
KdTreeConstructor
Creates canonical K-D Tree by selecting the maximum variance axis and splitting the points at the median.
-
-
Method Details
-
construct
Creates a newKdTree
from the provided points. WARNING: Reference to each point is saved to reduce memory usage..- Parameters:
points
- Data points.- Returns:
- KdTre
-
computeBranch
Given the data inside this particular node, select a point for the node and compute the node's children- Returns:
- The node associated with this region
-
computeChild
@Nullable protected KdTree.Node computeChild(List<P> points, @Nullable @Nullable DogArray_I32 indexes) Creates a child by checking to see if it is a leaf or branch.
-