Example #1
0
    def test_get_rotation_mtx(self):
        a = np.array([1., 0., 0.])
        b = np.array([0., 1., 0.])
        rot = VecMath.rotate_fromto_matrix(a, b)
        self.assertIsNotNone(rot)

        a2 = rot.__matmul__(a)
        self.assertNotEqual(VecMath.angle_between(a, b), 0.0)
        self.assertEqual(VecMath.angle_between(a2, b), 0.0)
Example #2
0
 def angle_between(self, other):
     """ Return the angle in radians between this plane and another plane or vector """
     if isinstance(other, Plane):
         other_v = other._norm
     elif len(other) == 3:
         # elif isinstance(other, np.array) and len(other) == 3:
         other_v = other
     return vm.angle_between(self._norm, other_v)
Example #3
0
    def test_get_rotation_mtx_equal_vecs(self):
        """ edge case: would normaly break rot mtx. use identity mtx instead """
        a = np.array([1., 0., 0.])
        b = np.array([1., 0., 0.])
        rot = VecMath.rotate_fromto_matrix(a, b)
        self.assertIsNotNone(rot)

        a2 = rot.__matmul__(a)
        self.assertEqual(VecMath.angle_between(a2, b), 0.0)
Example #4
0
 def simplify(self, epsilon=.00001):
     face_count_before = len(self._faces)
     for face in list(self._faces): # very important to copy the list first as we modify while iteration is not done yet
         for neighbour in face._neighbour_faces:
             if VecMath.angle_between(face._norm, neighbour._norm) < epsilon:
                 v_ids = face.merge_face_vids(neighbour)
                 # as we are modifying the list while iterating though it we need this test to check if the consolidation of this tri was already done
                 if v_ids and len(face._vertex_ids) < len(v_ids):
                     self.remove_face(face)
                     self.remove_face(neighbour)
                     self.add_face([self._vertices[id] for id in v_ids], group=face._group, tags=set(face._tags + neighbour._tags))
     self._update()
     print(f'Simplify: Face count {face_count_before} before -> {len(self._faces)} after')
Example #5
0
 def test_angle_between(self):
     self.assertEqual(VecMath.angle_between((1, 0, 0), (0, 1, 0)),
                      1.5707963267948966)
     self.assertEqual(VecMath.angle_between((1, 0, 0), (1, 0, 0)), 0.0)
     self.assertEqual(VecMath.angle_between((1, 0, 0), (-1, 0, 0)),
                      3.141592653589793)