Skip to content

Commit

Permalink
added util for distance
Browse files Browse the repository at this point in the history
  • Loading branch information
teseoch committed Aug 5, 2024
1 parent 2b08a67 commit 786e248
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/SimpleBVH/BVH.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class BVH {
if (nearest_facet < 0) {
get_nearest_facet_hint(p, nearest_facet, nearest_point, sq_dist);
}

facet_in_envelope_recursive(
p, sq_epsilon, nearest_facet, nearest_point, sq_dist, 1, 0,
n_corners);
Expand All @@ -119,6 +120,29 @@ class BVH {
getPoint = callback;
}

inline void point_facet_distance(
const VectorMax3d& p,
const int facet,
VectorMax3d& closest_point,
double& sq_d) const
{
const int f = new2old[facet];

if (faces.cols() == 2) {
point_segment_squared_distance(
p, { { vertices.row(faces(f, 0)), vertices.row(faces(f, 1)) } },
closest_point, sq_d);
return;
} else if (faces.cols() == 3) {
point_triangle_squared_distance(
p,
{ { vertices.row(faces(f, 0)), vertices.row(faces(f, 1)),
vertices.row(faces(f, 2)) } },
closest_point, sq_d);
return;
}
}

private:
void init_boxes_recursive(
const std::vector<std::array<VectorMax3d, 2>>& cornerlist,
Expand Down

0 comments on commit 786e248

Please sign in to comment.