python_unit/collision.py
Go to the documentation of this file.
1 import unittest
2 from test_case import TestCase
3 import hppfcl
4 
5 import numpy as np
6 
7 
8 def tetahedron():
9  pts = hppfcl.StdVec_Vec3f()
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 = hppfcl.StdVec_Triangle()
15  tri.append(hppfcl.Triangle(0, 1, 2))
16  tri.append(hppfcl.Triangle(0, 1, 3))
17  tri.append(hppfcl.Triangle(0, 2, 3))
18  tri.append(hppfcl.Triangle(1, 2, 3))
19  return hppfcl.Convex(pts, tri)
20 
21 
24  convex = tetahedron()
25  halfspace = hppfcl.Halfspace(np.array((0, 0, 1)), 0)
26 
27  req = hppfcl.CollisionRequest()
28  res = hppfcl.CollisionResult()
29 
30  M1 = hppfcl.Transform3f()
31  M2 = hppfcl.Transform3f(np.eye(3), np.array([0, 0, -0.1]))
32  res.clear()
33  hppfcl.collide(convex, M1, halfspace, M2, req, res)
34  self.assertFalse(hppfcl.collide(convex, M1, halfspace, M2, req, res))
35 
36  M1 = hppfcl.Transform3f()
37  M2 = hppfcl.Transform3f(np.eye(3), np.array([0, 0, 0.1]))
38  res.clear()
39  self.assertTrue(hppfcl.collide(convex, M1, halfspace, M2, req, res))
40 
41  M1 = hppfcl.Transform3f()
42  M2 = hppfcl.Transform3f(np.eye(3), np.array([0, 0, 2]))
43  res.clear()
44  self.assertTrue(hppfcl.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
test_case.TestCase
Definition: test_case.py:5
collision.TestMainAPI
Definition: python_unit/collision.py:22
collision.TestMainAPI.test_convex_halfspace
def test_convex_halfspace(self)
Definition: python_unit/collision.py:23


hpp-fcl
Author(s):
autogenerated on Fri Aug 2 2024 02:45:13