@@ -161,6 +161,39 @@ BOOST_AUTO_TEST_CASE(distance_point_triangle)
161161 BOOST_TEST (distance (Point3{1 , -1 , -1 }, triangle3_2) == std::sqrt (3 .f ));
162162}
163163
164+ BOOST_AUTO_TEST_CASE (distance_point_tetrahedron)
165+ {
166+ using ArborX::Details::distance;
167+
168+ using Point = ArborX::Point<3 >;
169+
170+ constexpr ArborX::ExperimentalHyperGeometry::Tetrahedron tet{
171+ Point{0 , 0 , 0 }, Point{1 , 0 , 0 }, Point{0 , 1 , 0 }, Point{0 , 0 , 1 }};
172+
173+ // vertices
174+ BOOST_TEST (distance (Point{0 , 0 , 0 }, tet) == 0 );
175+ BOOST_TEST (distance (Point{1 , 0 , 0 }, tet) == 0 );
176+ BOOST_TEST (distance (Point{0 , 1 , 0 }, tet) == 0 );
177+ BOOST_TEST (distance (Point{0 , 0 , 1 }, tet) == 0 );
178+
179+ // inside
180+ BOOST_TEST (distance (Point{0 .4f , 0 .4f , 0 .1f }, tet) == 0 );
181+ BOOST_TEST (distance (Point{0 .8f , 0 .05f , 0 .05f }, tet) == 0 );
182+
183+ // same plane as some side
184+ BOOST_TEST (distance (Point{2 , 0 , 0 }, tet) == 1 );
185+ BOOST_TEST (distance (Point{0 .5f , -0 .5f , 0 }, tet) == 0 .5f );
186+ BOOST_TEST (distance (Point{-0 .5f , 0 .5f , 0 }, tet) == 0 .5f );
187+ BOOST_TEST (distance (Point{0 , 0 , 2 }, tet) == 1 );
188+ BOOST_TEST (distance (Point{0 , -0 .5f , 0 }, tet) == 0 .5f );
189+
190+ // outside
191+ BOOST_TEST (distance (Point{-1 , -1 , -1 }, tet) == std::sqrt (3 .f ));
192+ BOOST_TEST (distance (Point{-1 , -1 , 2 }, tet) == std::sqrt (3 .f ));
193+ BOOST_TEST (distance (Point{1 .5f , 1 .5f , -1 }, tet) == std::sqrt (3 .f ));
194+ BOOST_TEST (distance (Point{1 .5f , 1 .5f , 0 .5f }, tet) == 1 .5f );
195+ }
196+
164197BOOST_AUTO_TEST_CASE (distance_box_box)
165198{
166199 using ArborX::Details::distance;
0 commit comments