Skip to content

Commit

Permalink
Fix insertion bug in find k-nearest
Browse files Browse the repository at this point in the history
  • Loading branch information
Yanko-7 authored and crvs committed Oct 4, 2024
1 parent 0c15700 commit 625093e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions KDTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,15 @@ pointIndexArr KDTree::nearest_pointIndices(point_t const& pt,

pointVec KDTree::nearest_points(point_t const& pt, size_t const& num_nearest) {
auto const k_nearest{nearest_pointIndices(pt, num_nearest)};
pointVec k_nearest_points{k_nearest.size()};
pointVec k_nearest_points(k_nearest.size());
std::transform(k_nearest.begin(), k_nearest.end(), k_nearest_points.begin(),
[](pointIndex const& x) { return x.first; });
return k_nearest_points;
}

indexArr KDTree::nearest_indices(point_t const& pt, size_t const& num_nearest) {
auto const k_nearest{nearest_pointIndices(pt, num_nearest)};
indexArr k_nearest_indices{k_nearest.size()};
indexArr k_nearest_indices(k_nearest.size());
std::transform(k_nearest.begin(), k_nearest.end(),
k_nearest_indices.begin(),
[](pointIndex const& x) { return x.second; });
Expand Down

0 comments on commit 625093e

Please sign in to comment.