37 #define BOOST_TEST_MODULE COAL_SWEPT_SPHERE_RADIUS
38 #include <boost/test/included/unit_test.hpp>
57 node1_type = shape1.getNodeType(); \
58 node2_type = shape2.getNodeType(); \
61 #define COAL_CHECK(cond) \
62 BOOST_CHECK_MESSAGE( \
63 cond, "from line " << line << ", for collision pair: " \
64 << get_node_type_name(node1_type) << " - " \
65 << get_node_type_name(node2_type) \
66 << " with ssr1 = " << shape1.getSweptSphereRadius() \
67 << ", ssr2 = " << shape2.getSweptSphereRadius() \
70 #define COAL_CHECK_VECTOR_CLOSE(v1, v2, tol) \
71 EIGEN_VECTOR_IS_APPROX(v1, v2, tol); \
72 COAL_CHECK(((v1) - (v2)).isZero(tol))
74 #define COAL_CHECK_REAL_CLOSE(v1, v2, tol) \
75 CoalScalar_IS_APPROX(v1, v2, tol); \
76 COAL_CHECK(std::abs((v1) - (v2)) < tol)
78 #define COAL_CHECK_CONDITION(cond) \
115 template <
typename S1,
typename S2>
119 Vec3s& normal,
bool use_swept_sphere_radius_in_gjk_epa_iterations)
const {
120 if (use_swept_sphere_radius_in_gjk_epa_iterations) {
122 this->runGJKAndEPA<S1, S2, details::SupportOptions::WithSweptSphere>(
129 this->runGJKAndEPA<S1, S2, details::SupportOptions::NoSweptSphere>(
135 template <
typename S1,
typename S2>
145 const bool compute_penetration =
true;
149 std::vector<Transform3s> tf1s;
150 std::vector<Transform3s> tf2s;
153 const std::array<CoalScalar, 4> swept_sphere_radius = {0, 0.1, 1., 10.};
155 for (
const CoalScalar& ssr1 : swept_sphere_radius) {
156 shape1.setSweptSphereRadius(ssr1);
157 for (
const CoalScalar& ssr2 : swept_sphere_radius) {
158 shape2.setSweptSphereRadius(ssr2);
159 for (std::size_t i = 0; i < n; ++i) {
166 std::array<Vec3s, 2>
p1;
167 std::array<Vec3s, 2> p2;
168 std::array<Vec3s, 2> normal;
174 p1[0], p2[0], normal[0],
false);
179 p1[1], p2[1], normal[1],
true);
187 (1 / 100.0) * std::max(shape1.getSweptSphereRadius(),
188 shape2.getSweptSphereRadius());
278 template <
typename S1,
typename S2>
280 std::cout <<
"Testing collision between "
286 std::vector<Transform3s> tf1s;
287 std::vector<Transform3s> tf2s;
291 const std::array<CoalScalar, 4> swept_sphere_radius = {0, 0.1, 1., 10.};
292 for (
const CoalScalar& ssr1 : swept_sphere_radius) {
293 shape1.setSweptSphereRadius(ssr1);
294 for (
const CoalScalar& ssr2 : swept_sphere_radius) {
295 shape2.setSweptSphereRadius(ssr2);
296 for (std::size_t i = 0; i < n; ++i) {
311 std::array<CollisionResult, 2> result;
314 const CoalScalar ssr1 = shape1.getSweptSphereRadius();
315 const CoalScalar ssr2 = shape2.getSweptSphereRadius();
316 shape1.setSweptSphereRadius(0.);
317 shape2.setSweptSphereRadius(0.);
321 shape1.setSweptSphereRadius(ssr1);
322 shape2.setSweptSphereRadius(ssr2);
325 BOOST_CHECK(result[0].isCollision());
326 BOOST_CHECK(result[1].isCollision());
327 if (result[0].isCollision() && result[1].isCollision()) {
328 std::array<Contact, 2> contact;
329 contact[0] = result[0].getContact(0);
330 contact[1] = result[1].getContact(0);
337 3 * sqrt(tol) + (1 / 100.0) * std::max(ssr1, ssr2);
342 contact[1].penetration_depth, precision);
347 std::abs(1 - (contact[0].normal).dot(contact[1].normal)) <
352 contact[0].nearest_points[0] + ssr1 * contact[0].normal,
353 contact[1].nearest_points[0], precision);
355 contact[0].nearest_points[1] - ssr2 * contact[0].normal,
356 contact[1].nearest_points[1], precision);