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)
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)
def normal(self, v2, v3, normalise_result=True): return type(self)(vector3.generate_normals(self, type(self)(v2), type(self)(v3), normalise_result))
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