def test_generate_normals_unnormalized(self):
     vertices = np.array([[2.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 2.0, 0.0],
                          [2.0, 2.0, 0.0]])
     index = np.array([
         [0, 2, 1],
         [0, 3, 2],
     ])
     v1, v2, v3 = np.rollaxis(vertices[index], axis=1)
     result = vector3.generate_normals(v1, v2, v3, normalize_result=False)
     expected = np.array([[0., 0., 4.], [0., 0., 4.]])
     np.testing.assert_array_equal(result, expected)
Example #2
0
 def test_generate_normals_unnormalized(self):
     vertices = np.array([
         [2.0, 0.0, 0.0],
         [0.0, 0.0, 0.0],
         [0.0, 2.0, 0.0],
         [2.0, 2.0, 0.0]
     ])
     index = np.array([
         [0, 2, 1],
         [0, 3, 2],
     ])
     v1, v2, v3 = np.rollaxis(vertices[index], axis=1)
     result = vector3.generate_normals(v1, v2, v3, normalize_result=False)
     expected = np.array([
         [0., 0., 4.],
         [0., 0., 4.]
     ])
     np.testing.assert_array_equal(result, expected)
Example #3
0
 def normal(self, v2, v3, normalise_result=True):
     return type(self)(vector3.generate_normals(self,
                                                type(self)(v2),
                                                type(self)(v3),
                                                normalise_result))
Example #4
0
File: base.py Project: RazerM/Pyrr
 def normal(self, v2, v3, normalise_result=True):
     return type(self)(vector3.generate_normals(self, type(self)(v2), type(self)(v3), normalise_result))
Example #5
0
def cull_face(vertices: List[Vector3], face: Face, side: str = 'back') -> bool:
    z = vector3.generate_normals(vertices[face.vertices[0]],
                                 vertices[face.vertices[1]],
                                 vertices[face.vertices[2]])[2]
    return z >= 0 if side == 'back' else z < 0