Find mistake: only update search radius after K points are found

This commit is contained in:
Jackson Campolattaro 2020-07-16 13:58:04 -04:00
parent ecbf15c274
commit b5a26c9f91
2 changed files with 10 additions and 13 deletions

View File

@ -522,7 +522,8 @@ private: // functions :
});
// Update the distance
largest_radius_squared_found = out.back().second;
if (out.size() == out.capacity())
largest_radius_squared_found = out.back().second;
}
}
}
@ -539,15 +540,11 @@ private: // functions :
for (int index = 0; index < 8; ++index) {
auto &n = node[index];
// If the node isn't empty
if (0 < std::distance(node.value().begin(), node.value().end())) {
// Find the distance of the node's center
auto node_center_distance = CGAL::squared_distance(p, compute_barycenter_position(n));
// Find the distance of the node's center
auto node_center_distance = CGAL::squared_distance(p, compute_barycenter_position(n));
// Add this node to the list
children_with_distances.emplace_back(index, node_center_distance);
}
// Add this node to the list
children_with_distances.emplace_back(index, node_center_distance);
}
// Sort the children by their distance
@ -560,7 +557,7 @@ private: // functions :
auto &n = node[child.first.to_ulong()];
// Check whether this node is capable of containing closer points
if (do_intersect(n, Sphere{p, largest_radius_squared_found + 0.1 /*TODO: This is my epsilon*/})) {
if (do_intersect(n, Sphere{p, largest_radius_squared_found + 10 /*TODO: This is my epsilon*/})) {
// Recursive case
largest_radius_squared_found =
@ -569,7 +566,7 @@ private: // functions :
}
}
}
//out.push_back(p);
return largest_radius_squared_found;
}

View File

@ -174,8 +174,8 @@ int main(void) {
// naive_vs_octree(100);
// naive_vs_octree(1000);
naive_vs_octree(10000);
naive_vs_octree(100000);
// naive_vs_octree(10000);
// naive_vs_octree(100000);
kdtree_vs_octree(100);
// kdtree_vs_octree(1000);