Class KdTreeConstructor<P>


public class KdTreeConstructor<P>
extends Object
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 Details

    • KdTreeConstructor

      public KdTreeConstructor​(KdTreeMemory<P> memory, AxisSplitter<P> splitter)
      Constructor which allows for maximum configurable.
      memory - Used to recycle data
    • KdTreeConstructor

      public KdTreeConstructor​(KdTreeDistance<P> distance)
      Creates canonical K-D Tree by selecting the maximum variance axis and splitting the points at the median.
  • Method Details

    • construct

      public KdTree construct​(List<P> points, boolean trackIndexes)
      Creates a new KdTree from the provided points. WARNING: Reference to each point is saved to reduce memory usage..
      points - Data points.
    • computeBranch

      protected KdTree.Node computeBranch​(List<P> points, @Nullable @Nullable DogArray_I32 indexes)
      Given the data inside this particular node, select a point for the node and compute the node's children
      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.