35 #define BOOST_TEST_MODULE COAL_SECURITY_MARGIN
36 #include <boost/test/included/unit_test.hpp>
59 #define MATH_SQUARED(x) (x * x)
61 template <
typename Shape>
66 typedef Eigen::Matrix<CoalScalar, 1, 1> Matrix;
71 return m1.isApprox(m2, tol);
102 return s1.
a.isApprox(s2.
a, tol) && s1.
b.isApprox(s2.
b, tol) &&
103 s1.
c.isApprox(s2.
c, tol);
107 return isApprox(s1.
d, s2.
d, tol) && s1.
n.isApprox(s2.
n, tol);
110 template <
typename Shape>
116 const auto &inflation_result = original_shape.inflated(inflation);
117 const Transform3s &shift = inflation_result.second;
118 const Shape &inflated_shape = inflation_result.first;
120 BOOST_CHECK(
isApprox(original_shape, inflated_shape, tol));
126 const auto &inflation_result = original_shape.inflated(inflation);
127 const Shape &inflated_shape = inflation_result.first;
128 const Transform3s &inflation_shift = inflation_result.second;
130 BOOST_CHECK(!
isApprox(original_shape, inflated_shape, tol));
132 const auto &deflation_result = inflated_shape.inflated(-inflation);
133 const Shape &deflated_shape = deflation_result.first;
134 const Transform3s &deflation_shift = deflation_result.second;
136 BOOST_CHECK(
isApprox(original_shape, deflated_shape, tol));
137 BOOST_CHECK((inflation_shift * deflation_shift).isIdentity(tol));
142 const auto &inflation_result = original_shape.inflated(-inflation);
143 const Shape &inflated_shape = inflation_result.first;
144 const Transform3s &inflation_shift = inflation_result.second;
146 BOOST_CHECK(!
isApprox(original_shape, inflated_shape, tol));
148 const auto &deflation_result = inflated_shape.inflated(+inflation);
149 const Shape &deflated_shape = deflation_result.first;
150 const Transform3s &deflation_shift = deflation_result.second;
152 BOOST_CHECK(
isApprox(original_shape, deflated_shape, tol));
153 BOOST_CHECK((inflation_shift * deflation_shift).isIdentity(tol));
157 template <
typename Shape>
159 BOOST_REQUIRE_THROW(shape.inflated(inflation), std::invalid_argument);
162 template <
typename Shape>
164 BOOST_REQUIRE_NO_THROW(shape.inflated(inflation));
178 test(ellipsoid, 0.01, 1e-8);
182 test(capsule, 0.01, 1e-8);
186 test(cylinder, 0.01, 1e-8);
190 test(cone, 0.01, 1e-8);
194 test(halfspace, 0.01, 1e-8);