/** * Finds the nodes which are closest to 'target' and within range of the maximum distance. * * @param target A point * @param searchN Number of nearest-neighbors it will search for * @param results Storage for the found neighbors */ @Override public void findNeighbor(P target, int searchN, FastQueue<KdTreeResult> results) { if( searchN <= 0 ) throw new IllegalArgumentException("I'm sorry, but I refuse to search for less than or equal to 0 neighbors."); if( tree.root == null ) return; this.searchN = searchN; this.target = target; this.mostDistantNeighborSq = maxDistanceSq; stepClosest(tree.root,results); }
return; checkBestDistance(node, neighbors); stepClosest(nearer,neighbors); if( dx*dx <= mostDistantNeighborSq) { if( neighbors.size() < searchN || dx*dx < mostDistantNeighborSq) { stepClosest(further,neighbors);
public KdTreeNearestNeighbor( KdTreeDistance<P> distance ) { this( new KdTreeSearch1Standard<>(distance), new KdTreeSearchNStandard<>(distance), new AxisSplitterMedian<>(distance)); }
return; checkBestDistance(node, neighbors); stepClosest(nearer,neighbors); if( dx*dx <= mostDistantNeighborSq) { if( neighbors.size() < searchN || dx*dx < mostDistantNeighborSq) { stepClosest(further,neighbors);
public KdTreeNearestNeighbor( KdTreeDistance<P> distance ) { this( new KdTreeSearch1Standard<>(distance), new KdTreeSearchNStandard<>(distance), new AxisSplitterMedian<>(distance)); }
@Override public KdTreeSearchN<double[]> createAlg() { return new KdTreeSearchNStandard<>(new KdTreeEuclideanSq_F64(N)); } }
/** * Finds the nodes which are closest to 'target' and within range of the maximum distance. * * @param target A point * @param searchN Number of nearest-neighbors it will search for * @param results Storage for the found neighbors */ @Override public void findNeighbor(P target, int searchN, FastQueue<KdTreeResult> results) { if( searchN <= 0 ) throw new IllegalArgumentException("I'm sorry, but I refuse to search for less than or equal to 0 neighbors."); if( tree.root == null ) return; this.searchN = searchN; this.target = target; this.mostDistantNeighborSq = maxDistanceSq; stepClosest(tree.root,results); }