collision_node_asserts.cpp
Go to the documentation of this file.
1 #define BOOST_TEST_MODULE COAL_COLLISION_NODE_ASSERT
2 
3 #include <boost/test/included/unit_test.hpp>
4 #include <boost/math/constants/constants.hpp>
5 #include "coal/BVH/BVH_model.h"
6 #include "coal/collision.h"
7 
8 using namespace coal;
9 
10 constexpr CoalScalar pi = boost::math::constants::pi<CoalScalar>();
11 
12 double DegToRad(const double& deg) {
13  static double degToRad = pi / 180.;
14  return deg * degToRad;
15 }
16 std::vector<Vec3s> dirs{Vec3s::UnitZ(), -Vec3s::UnitZ(), Vec3s::UnitY(),
18 
19 BOOST_AUTO_TEST_CASE(TestTriangles) {
20  std::vector<Vec3s> triVertices{Vec3s(1, 0, 0), Vec3s(1, 1, 0),
21  Vec3s(0, 1, 0)};
22  std::vector<Triangle> triangle{{0, 1, 2}};
23 
24  BVHModel<OBBRSS> tri1{};
25  BVHModel<OBBRSS> tri2{};
26 
27  tri1.beginModel();
28  tri1.addSubModel(triVertices, triangle);
29  tri1.endModel();
30 
31  tri2.beginModel();
32  tri2.addSubModel(triVertices, triangle);
33  tri2.endModel();
34 
36 
37  ComputeCollision compute(&tri1, &tri2);
38 
39  Transform3s tri1Tf{};
40  Transform3s tri2Tf{};
41 
43  for (int i = 0; i < 360; i += 30) {
44  for (int j = 0; j < 180; j += 30) {
45  for (int k = 0; k < 180; k += 30) {
46  tri1Tf.setQuatRotation(
47  Eigen::AngleAxis<double>(0., Vec3s::UnitZ()) *
48  Eigen::AngleAxis<double>(DegToRad(k), Vec3s::UnitY()));
49  tri2Tf.setQuatRotation(
50  Eigen::AngleAxis<double>(DegToRad(i), Vec3s::UnitZ()) *
51  Eigen::AngleAxis<double>(DegToRad(j), Vec3s::UnitY()));
52  CollisionResult result;
53 
55  BOOST_CHECK_NO_THROW(compute(tri2Tf, tri1Tf, request, result));
56  }
57  }
58  }
59 }
collision.h
coal::BVHModelBase::beginModel
int beginModel(unsigned int num_tris=0, unsigned int num_vertices=0)
Begin a new BVH model.
Definition: BVH_model.cpp:179
coal::CONTACT
@ CONTACT
Definition: coal/collision_data.h:305
DegToRad
double DegToRad(const double &deg)
Definition: collision_node_asserts.cpp:12
coal::Vec3s
Eigen::Matrix< CoalScalar, 3, 1 > Vec3s
Definition: coal/data_types.h:77
coal
Main namespace.
Definition: coal/broadphase/broadphase_bruteforce.h:44
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(TestTriangles)
Definition: collision_node_asserts.cpp:19
coal::DISTANCE_LOWER_BOUND
@ DISTANCE_LOWER_BOUND
Definition: coal/collision_data.h:306
coal::Transform3s
Simple transform class used locally by InterpMotion.
Definition: coal/math/transform.h:55
coal::Transform3s::setQuatRotation
void setQuatRotation(const Quatf &q_)
set transform from rotation
Definition: coal/math/transform.h:148
coal::UnitZ
const Vec3s UnitZ
Definition: utility.cpp:90
BVH_model.h
coal::CollisionResult
collision result
Definition: coal/collision_data.h:390
coal::CollisionRequest
request to the collision algorithm
Definition: coal/collision_data.h:311
coal::UnitX
const Vec3s UnitX
Definition: utility.cpp:88
dirs
std::vector< Vec3s > dirs
Definition: collision_node_asserts.cpp:16
coal::BVHModel
A class describing the bounding hierarchy of a mesh model or a point cloud model (which is viewed as ...
Definition: coal/BVH/BVH_model.h:314
coal::UnitY
const Vec3s UnitY
Definition: utility.cpp:89
pi
constexpr CoalScalar pi
Definition: collision_node_asserts.cpp:10
coal::CoalScalar
double CoalScalar
Definition: coal/data_types.h:76
coal::ComputeCollision
This class reduces the cost of identifying the geometry pair. This is mostly useful for repeated shap...
Definition: coal/collision.h:78


hpp-fcl
Author(s):
autogenerated on Sat Nov 23 2024 03:44:57