summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2014-03-11 21:12:56 -0400
committerTavian Barnes <tavianator@tavianator.com>2014-03-11 21:12:56 -0400
commit03383e4c753d386712fd92c714bde46e2cdbd7e7 (patch)
tree6cacbcb71d95f10688718d7f90a2a0c95e60bd1f
parentfd5651a159da880b0c378ae9d2a2b4ac1c0614b3 (diff)
downloadkd-forest-03383e4c753d386712fd92c714bde46e2cdbd7e7.tar.xz
Look for strictly better matches in the k-d tree code.
-rw-r--r--kd-forest.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/kd-forest.c b/kd-forest.c
index 5b230be..f1e8f0b 100644
--- a/kd-forest.c
+++ b/kd-forest.c
@@ -163,10 +163,10 @@ kd_find_nearest_recursive(kd_node_t *root, kd_node_t *target, kd_node_t **best,
coord = (coord + 1)%KD_DIMEN;
- if (root->left && (dist <= 0 || dist_sq <= *limit)) {
+ if (root->left && (dist < 0.0 || dist_sq < *limit)) {
kd_find_nearest_recursive(root->left, target, best, limit, coord);
}
- if (root->right && (dist >= 0 || dist_sq <= *limit)) {
+ if (root->right && (dist > 0.0 || dist_sq < *limit)) {
kd_find_nearest_recursive(root->right, target, best, limit, coord);
}
}