Skip to content

Commit

Permalink
Add test computing the distance between a sphere and a box
Browse files Browse the repository at this point in the history
  • Loading branch information
Rombur committed Mar 25, 2021
1 parent 131649f commit 11bbb1d
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/tstDetailsAlgorithms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,26 @@ BOOST_AUTO_TEST_CASE(distance_box_box)
BOOST_TEST(distance(Box{}, Box{}) == infinity);
}

BOOST_AUTO_TEST_CASE(distance_sphere_box)
{
using ArborX::Details::distance;
auto infinity = KokkosExt::ArithmeticTraits::infinity<float>::value;

// unit sphere
constexpr Sphere sphere{{{0., 0., 0.}}, 1.};
// distance between a sphere and a box no intersection
BOOST_TEST(distance(sphere, Box{{2.0, 3.0, 4.0}, {2.5, 3.5, 4.5}}) ==
std::sqrt(29.f) - 1.f);
// distance between a sphere and a box with intersection
BOOST_TEST(distance(sphere, Box{{0.5, 0.5, 0.5}, {2.5, 3.5, 4.5}}) == 0.f);
// distance between a sphere included in a box and that box
BOOST_TEST(distance(sphere, Box{{-2., -2., -2.}, {2., 2., 2.}}) == 0.f);
// distance between a sphere and a box included in that sphere
BOOST_TEST(distance(sphere, Box{{0.5, 0.5, 0.5}, {0.6, 0.7, 0.8}}) == 0.f);
// distance to empty box
BOOST_TEST(distance(sphere, Box{}) == infinity);
}

BOOST_AUTO_TEST_CASE(intersects)
{
using ArborX::Details::intersects;
Expand Down

0 comments on commit 11bbb1d

Please sign in to comment.