Class KdTreeSearch1Standard<P>

java.lang.Object
org.ddogleg.nn.alg.searches.KdTreeSearch1Standard<P>
All Implemented Interfaces:
KdTreeSearch1<P>

public class KdTreeSearch1Standard<P> extends Object implements KdTreeSearch1<P>
Standard algorithm for searching a KdTree for the nearest-neighbor of a search. This is the algorithm which is typically described in books. At each node it examines distance of the two children and investigates the closer child. After it reaches a leaf it steps back in the search and sees if the other child could produce a better solution, if it can it is also investigated. The search stops when no more nodes can produce a better result.
  • Constructor Details

    • KdTreeSearch1Standard

      public KdTreeSearch1Standard(KdTreeDistance<P> distance)
  • Method Details

    • setTree

      public void setTree(Object tree)
      Description copied from interface: KdTreeSearch1
      Specifies the tree which will be searched. The type of object is implementation specific
      Specified by:
      setTree in interface KdTreeSearch1<P>
      Parameters:
      tree - search tree
    • setMaxDistance

      public void setMaxDistance(double maxDistance)
      Specifies the greatest distance it will search
      Specified by:
      setMaxDistance in interface KdTreeSearch1<P>
      Parameters:
      maxDistance - Maximum distance (Euclidean squared) a closest point can be
    • findNeighbor

      @Nullable public KdTree.Node findNeighbor(P target)
      Finds the node which is closest to 'target'
      Specified by:
      findNeighbor in interface KdTreeSearch1<P>
      Parameters:
      target - A point
      Returns:
      Closest node or null if none is within the minimum distance.
    • getDistance

      public double getDistance()
      Description copied from interface: KdTreeSearch1
      Returns the distance of the closest node.
      Specified by:
      getDistance in interface KdTreeSearch1<P>
      Returns:
      distance to closest node.
    • copy

      public KdTreeSearch1<P> copy()
      Description copied from interface: KdTreeSearch1
      Creates a copy of this search with the same configuration. workspace isn't copied
      Specified by:
      copy in interface KdTreeSearch1<P>