37 #define BOOST_TEST_MODULE COAL_CONTACT_PATCH 
   38 #include <boost/test/included/unit_test.hpp> 
   48   const Box box1(2 * halfside, 2 * halfside, 2 * halfside);
 
   49   const Box box2(2 * halfside, 2 * halfside, 2 * halfside);
 
   55   tf2.setTranslation(
Vec3s(0, 0, 2 * halfside + offset));
 
   57   const size_t num_max_contact = 1;
 
   75   const Box box(2 * halfside, 2 * halfside, 2 * halfside);
 
   82   tf2.setTranslation(
Vec3s(0, 0, 2 * halfside - offset));
 
   84   const size_t num_max_contact = 1;
 
  101     BOOST_CHECK(contact_patch.
size() == 1);
 
  113   const Box box1(2 * halfside, 2 * halfside, 2 * halfside);
 
  114   const Box box2(2 * halfside, 2 * halfside, 2 * halfside);
 
  120   tf2.setTranslation(
Vec3s(0, 0, 2 * halfside - offset));
 
  122   const size_t num_max_contact = 1;
 
  147     const size_t expected_size = 4;
 
  153     const std::array<Vec3s, 4> corners = {
 
  154         Vec3s(halfside, halfside, halfside),
 
  155         Vec3s(halfside, -halfside, halfside),
 
  156         Vec3s(-halfside, -halfside, halfside),
 
  157         Vec3s(-halfside, halfside, halfside),
 
  159     for (
size_t i = 0; i < expected_size; ++i) {
 
  172   const Box box(2 * halfside, 2 * halfside, 2 * halfside);
 
  178   tf2.setTranslation(
Vec3s(0, 0, halfside - offset));
 
  180   const size_t num_max_contact = 1;
 
  206     const size_t expected_size = 4;
 
  212     const std::array<Vec3s, 4> corners = {
 
  213         tf2.transform(
Vec3s(halfside, halfside, -halfside)),
 
  214         tf2.transform(
Vec3s(halfside, -halfside, -halfside)),
 
  215         tf2.transform(
Vec3s(-halfside, -halfside, -halfside)),
 
  216         tf2.transform(
Vec3s(-halfside, halfside, -halfside)),
 
  218     for (
size_t i = 0; i < expected_size; ++i) {
 
  232   const Capsule capsule(radius, height);
 
  238   tf2.setTranslation(
Vec3s(0, 0, height / 2 - offset));
 
  240   const size_t num_max_contact = 1;
 
  260     const size_t expected_size = 1;
 
  270     BOOST_CHECK(expected.
tf == contact_patch.
tf);
 
  271     BOOST_CHECK(expected.
isSame(contact_patch, tol));
 
  276   tf2.rotation().col(0) << -1, 0, 0;
 
  277   tf2.rotation().col(1) << 0, 1, 0;
 
  278   tf2.rotation().col(2) << 0, 0, -1;
 
  291     const size_t expected_size = 1;
 
  301     BOOST_CHECK(expected.
tf == contact_patch.
tf);
 
  302     BOOST_CHECK(expected.
isSame(contact_patch, tol));
 
  307   tf2.rotation().col(0) << 0, 0, 1;
 
  308   tf2.rotation().col(1) << 0, 1, 0;
 
  309   tf2.rotation().col(2) << -1, 0, 0;
 
  310   tf2.translation() << 0, 0, capsule.
radius - offset;
 
  323     const size_t expected_size = 2;
 
  335     BOOST_CHECK(expected.
tf == contact_patch.
tf);
 
  336     BOOST_CHECK(expected.
isSame(contact_patch, tol));
 
  344   const Cone cone(radius, height);
 
  350   tf2.setTranslation(
Vec3s(0, 0, height / 2 - offset));
 
  352   const size_t num_max_contact = 1;
 
  378     std::array<Vec3s, ContactPatch::default_preallocated_size> points;
 
  383       Vec3s point_on_cone_base(std::cos(theta) * cone.
radius,
 
  385       expected.
addPoint(
tf2.transform(point_on_cone_base));
 
  389     BOOST_CHECK(expected.
tf == contact_patch.
tf);
 
  390     BOOST_CHECK(expected.
isSame(contact_patch, tol));
 
  395   tf2.rotation().col(0) << -1, 0, 0;
 
  396   tf2.rotation().col(1) << 0, 1, 0;
 
  397   tf2.rotation().col(2) << 0, 0, -1;
 
  408     BOOST_CHECK(contact_patch.
size() == 1);
 
  416     const size_t expected_size = 1;
 
  425     BOOST_CHECK(contact_patch.
isSame(expected, tol));
 
  430   tf2.rotation().col(0) << 0, 0, 1;
 
  431   tf2.rotation().col(1) << 0, 1, 0;
 
  432   tf2.rotation().col(2) << -1, 0, 0;
 
  433   tf2.translation() << 0, 0, cone.
radius - offset;
 
  444     BOOST_CHECK(contact_patch.
size() == 1);
 
  452     const size_t expected_size = 1;
 
  459     expected.
addPoint(
tf2.transform(point_on_circle_basis));
 
  461     BOOST_CHECK(contact_patch.
isSame(expected, tol));
 
  469   const Cylinder cylinder(radius, height);
 
  475   tf2.setTranslation(
Vec3s(0, 0, height / 2 - offset));
 
  477   const size_t num_max_contact = 1;
 
  493     std::array<Vec3s, ContactPatch::default_preallocated_size> points;
 
  498       Vec3s point_on_cone_base(std::cos(theta) * cylinder.
radius,
 
  499                                std::sin(theta) * cylinder.
radius,
 
  501       expected.
addPoint(
tf2.transform(point_on_cone_base));
 
  515       BOOST_CHECK(expected.
tf == contact_patch.
tf);
 
  516       BOOST_CHECK(expected.
isSame(contact_patch, tol));
 
  521     tf2.rotation().col(0) << -1, 0, 0;
 
  522     tf2.rotation().col(1) << 0, 1, 0;
 
  523     tf2.rotation().col(2) << 0, 0, -1;
 
  534       BOOST_CHECK(expected.
tf == contact_patch.
tf);
 
  535       BOOST_CHECK(expected.
isSame(contact_patch, tol));
 
  541   tf2.rotation().col(0) << 0, 0, 1;
 
  542   tf2.rotation().col(1) << 0, 1, 0;
 
  543   tf2.rotation().col(2) << -1, 0, 0;
 
  544   tf2.translation() << 0, 0, cylinder.
radius - offset;
 
  559     const size_t expected_size = 2;
 
  571     BOOST_CHECK(expected.
isSame(contact_patch, tol));
 
  584   tf2.setTranslation(
Vec3s(0, 0, 2 * halfside - offset));
 
  586   const size_t num_max_contact = 1;
 
  611     const size_t expected_size = 4;
 
  617     const std::array<Vec3s, 4> corners = {
 
  618         Vec3s(halfside, halfside, halfside),
 
  619         Vec3s(halfside, -halfside, halfside),
 
  620         Vec3s(-halfside, -halfside, halfside),
 
  621         Vec3s(-halfside, halfside, halfside),
 
  623     for (
size_t i = 0; i < expected_size; ++i) {
 
  637   const size_t expected_size = 2;
 
  638   const Vec3s expected_cp1(0, 0.5, 0);
 
  639   const Vec3s expected_cp2(0, 1, 0);
 
  644   const size_t num_max_contact = 1;
 
  653     std::shared_ptr<std::vector<Vec3s>> pts1(
new std::vector<Vec3s>({
 
  659     std::shared_ptr<std::vector<Triangle>> tris1(
 
  664     std::shared_ptr<std::vector<Vec3s>> pts2(
new std::vector<Vec3s>({
 
  670     std::shared_ptr<std::vector<Triangle>> tris2(
 
  698       BOOST_CHECK(expected.
isSame(contact_patch, tol));
 
  704     std::shared_ptr<std::vector<Vec3s>> pts1(
new std::vector<Vec3s>({
 
  710     std::shared_ptr<std::vector<Triangle>> tris1(
 
  715     std::shared_ptr<std::vector<Vec3s>> pts2(
new std::vector<Vec3s>({
 
  721     std::shared_ptr<std::vector<Triangle>> tris2(
 
  747       BOOST_CHECK(expected.
isSame(contact_patch, tol));
 
  753     std::shared_ptr<std::vector<Vec3s>> pts1(
new std::vector<Vec3s>({
 
  759     std::shared_ptr<std::vector<Triangle>> tris1(
 
  764     std::shared_ptr<std::vector<Vec3s>> pts2(
new std::vector<Vec3s>({
 
  770     std::shared_ptr<std::vector<Triangle>> tris2(
 
  796       BOOST_CHECK(expected.
isSame(contact_patch, tol));
 
  804   const size_t expected_size = 1;
 
  805   const Vec3s expected_cp(0, 0, 0);
 
  810   const size_t num_max_contact = 1;
 
  819     std::shared_ptr<std::vector<Vec3s>> pts1(
new std::vector<Vec3s>({
 
  825     std::shared_ptr<std::vector<Triangle>> tris1(
 
  830     std::shared_ptr<std::vector<Vec3s>> pts2(
new std::vector<Vec3s>({
 
  836     std::shared_ptr<std::vector<Triangle>> tris2(
 
  861       BOOST_CHECK(expected.
isSame(contact_patch, tol));
 
  867     std::shared_ptr<std::vector<Vec3s>> pts1(
new std::vector<Vec3s>({
 
  873     std::shared_ptr<std::vector<Triangle>> tris1(
 
  878     std::shared_ptr<std::vector<Vec3s>> pts2(
new std::vector<Vec3s>({
 
  884     std::shared_ptr<std::vector<Triangle>> tris2(
 
  909       BOOST_CHECK(expected.
isSame(contact_patch, tol));
 
  915     std::shared_ptr<std::vector<Vec3s>> pts1(
new std::vector<Vec3s>({
 
  921     std::shared_ptr<std::vector<Triangle>> tris1(
 
  926     std::shared_ptr<std::vector<Vec3s>> pts2(
new std::vector<Vec3s>({
 
  932     std::shared_ptr<std::vector<Triangle>> tris2(
 
  957       BOOST_CHECK(expected.
isSame(contact_patch, tol));
 
  965   const size_t expected_size = 2;
 
  966   const Vec3s expected_cp1(0, 0, 0);
 
  967   const Vec3s expected_cp2(-0.5, 0.5, 0);
 
  972   const size_t num_max_contact = 1;
 
  980     std::shared_ptr<std::vector<Vec3s>> pts1(
new std::vector<Vec3s>({
 
  986     std::shared_ptr<std::vector<Triangle>> tris1(
 
  991     std::shared_ptr<std::vector<Vec3s>> pts2(
new std::vector<Vec3s>({
 
  997     std::shared_ptr<std::vector<Triangle>> tris2(
 
 1023       BOOST_CHECK(expected.
isSame(contact_patch, tol));