python_unit/collision.py
Go to the documentation of this file.
1 import unittest
2 from test_case import TestCase
3 import coal
4 
5 import numpy as np
6 
7 
8 def tetahedron():
9  pts = coal.StdVec_Vec3s()
10  pts.append(np.array((0, 0, 0)))
11  pts.append(np.array((0, 1, 0)))
12  pts.append(np.array((1, 0, 0)))
13  pts.append(np.array((0, 0, 1)))
14  tri = coal.StdVec_Triangle()
15  tri.append(coal.Triangle(0, 1, 2))
16  tri.append(coal.Triangle(0, 1, 3))
17  tri.append(coal.Triangle(0, 2, 3))
18  tri.append(coal.Triangle(1, 2, 3))
19  return coal.Convex(pts, tri)
20 
21 
24  convex = tetahedron()
25  halfspace = coal.Halfspace(np.array((0, 0, 1)), 0)
26 
27  req = coal.CollisionRequest()
28  res = coal.CollisionResult()
29 
30  M1 = coal.Transform3s()
31  M2 = coal.Transform3s(np.eye(3), np.array([0, 0, -0.1]))
32  res.clear()
33  coal.collide(convex, M1, halfspace, M2, req, res)
34  self.assertFalse(coal.collide(convex, M1, halfspace, M2, req, res))
35 
36  M1 = coal.Transform3s()
37  M2 = coal.Transform3s(np.eye(3), np.array([0, 0, 0.1]))
38  res.clear()
39  self.assertTrue(coal.collide(convex, M1, halfspace, M2, req, res))
40 
41  M1 = coal.Transform3s()
42  M2 = coal.Transform3s(np.eye(3), np.array([0, 0, 2]))
43  res.clear()
44  self.assertTrue(coal.collide(convex, M1, halfspace, M2, req, res))
45 
46 
47 if __name__ == "__main__":
48  unittest.main()
collision.tetahedron
def tetahedron()
Definition: python_unit/collision.py:8
coal::Halfspace
Half Space: this is equivalent to the Plane in ODE. A Half space has a priviledged direction: the dir...
Definition: coal/shape/geometric_shapes.h:892
test_case.TestCase
Definition: test_case.py:5
collision.TestMainAPI
Definition: python_unit/collision.py:22
coal::Transform3s
Simple transform class used locally by InterpMotion.
Definition: coal/math/transform.h:55
coal::CollisionResult
collision result
Definition: coal/collision_data.h:390
collision.TestMainAPI.test_convex_halfspace
def test_convex_halfspace(self)
Definition: python_unit/collision.py:23
coal::CollisionRequest
request to the collision algorithm
Definition: coal/collision_data.h:311
coal::Convex
Convex polytope.
Definition: coal/serialization/collision_object.h:51
coal::collide
void collide(CollisionTraversalNodeBase *node, const CollisionRequest &request, CollisionResult &result, BVHFrontList *front_list, bool recursive)
Definition: collision_node.cpp:62
coal::Triangle
Triangle with 3 indices for points.
Definition: coal/data_types.h:111


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