LimitedPriorityQueue<VectorDistanceTuple<VALUE>> queue) {
if (current == null) {
return;
}
int s = current.splitDimension;
DoubleVector pivot = current.keyVector;
double distancePivotToTarget = EuclidianDistance.get().measureDistance(
pivot, target);
HyperRectangle leftHyperRectangle = hyperRectangle;
HyperRectangle rightHyperRectangle = new HyperRectangle(
hyperRectangle.min.deepCopy(), hyperRectangle.max.deepCopy());
leftHyperRectangle.max.set(s, pivot.get(s));
rightHyperRectangle.min.set(s, pivot.get(s));
boolean left = target.get(s) > pivot.get(s);
KDTreeNode nearestNode;
HyperRectangle nearestHyperRectangle;
KDTreeNode furtherstNode;
HyperRectangle furtherstHyperRectangle;
if (left) {
nearestNode = current.left;
nearestHyperRectangle = leftHyperRectangle;
furtherstNode = current.right;
furtherstHyperRectangle = rightHyperRectangle;
} else {
nearestNode = current.right;
nearestHyperRectangle = rightHyperRectangle;
furtherstNode = current.left;
furtherstHyperRectangle = leftHyperRectangle;
}
getNearestNeighbourInternal(nearestNode, target, nearestHyperRectangle,
maxDistSquared, k, radius, queue);
double distanceSquared = queue.isFull() ? queue.getMaximumPriority()
: Double.MAX_VALUE;
maxDistSquared = Math.min(maxDistSquared, distanceSquared);
DoubleVector closest = furtherstHyperRectangle.closestPoint(target);
double closestDistance = EuclidianDistance.get().measureDistance(closest,
target);
// check subtrees even if they aren't in your maxDist but within our radius
if (closestDistance < maxDistSquared || closestDistance < radius) {
if (distancePivotToTarget < distanceSquared) {