Skip to content

Commit

Permalink
Compute distance sphere-box
Browse files Browse the repository at this point in the history
  • Loading branch information
Rombur committed Mar 25, 2021
1 parent 7c8ca37 commit 131649f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/details/ArborX_DetailsAlgorithms.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,16 @@ float distance(Box const &box_a, Box const &box_b)
return std::sqrt(distance_squared);
}

// distance box-sphere
KOKKOS_INLINE_FUNCTION
float distance(Sphere const &sphere, Box const &box)
{
using KokkosExt::max;

float distance_center_box = distance(sphere.centroid(), box);
return max(distance_center_box - sphere.radius(), 0.f);
}

// expand an axis-aligned bounding box to include a point
KOKKOS_INLINE_FUNCTION
void expand(Box &box, Point const &point) { box += point; }
Expand Down

0 comments on commit 131649f

Please sign in to comment.