def test_trimesh_face_normals(): points = np.array([[0.0, 0.0, -1.0], [1.0, 0.0, 0.0], [1.0, 1.0, 0.0], [0.0, 1.0, 0.0]]) trilist = np.array([[0, 1, 3], [1, 2, 3]]) expected_normals = np.array( [[-np.sqrt(3) / 3, -np.sqrt(3) / 3, np.sqrt(3) / 3], [-0, -0, 1]]) trimesh = TriMesh(points, trilist=trilist) face_normals = trimesh.tri_normals() assert_allclose(face_normals, expected_normals) trimesh.points = trimesh.points.astype(np.float32) face_normals = trimesh.tri_normals() assert_allclose(face_normals, expected_normals)
def test_trimesh_face_normals(): points = np.array([[0.0, 0.0, -1.0], [1.0, 0.0, 0.0], [1.0, 1.0, 0.0], [0.0, 1.0, 0.0]]) trilist = np.array([[0, 1, 3], [1, 2, 3]]) expected_normals = np.array([[-np.sqrt(3)/3, -np.sqrt(3)/3, np.sqrt(3)/3], [-0, -0, 1]]) trimesh = TriMesh(points, trilist=trilist) face_normals = trimesh.tri_normals() assert_allclose(face_normals, expected_normals) trimesh.points = trimesh.points.astype(np.float32) face_normals = trimesh.tri_normals() assert_allclose(face_normals, expected_normals)
def test_trimesh_vertex_normals(): points = np.array([[0.0, 0.0, -1.0], [1.0, 0.0, 0.0], [1.0, 1.0, 0.0], [0.0, 1.0, 0.0]]) trilist = np.array([[0, 1, 3], [1, 2, 3]]) # 0 and 2 are the corner of the triangles and so the maintain the # face normals. The other two are the re-normalized vertices: # normalize(n0 + n2) expected_normals = np.array( [[-np.sqrt(3) / 3, -np.sqrt(3) / 3, np.sqrt(3) / 3], [-0.32505758, -0.32505758, 0.88807383], [0, 0, 1], [-0.32505758, -0.32505758, 0.88807383]]) trimesh = TriMesh(points, trilist) vertex_normals = trimesh.vertex_normals() assert_allclose(vertex_normals, expected_normals) trimesh.points = trimesh.points.astype(np.float32) vertex_normals = trimesh.vertex_normals() assert_allclose(vertex_normals, expected_normals)
def test_trimesh_vertex_normals(): points = np.array([[0.0, 0.0, -1.0], [1.0, 0.0, 0.0], [1.0, 1.0, 0.0], [0.0, 1.0, 0.0]]) trilist = np.array([[0, 1, 3], [1, 2, 3]]) # 0 and 2 are the corner of the triangles and so the maintain the # face normals. The other two are the re-normalized vertices: # normalize(n0 + n2) expected_normals = np.array([[-np.sqrt(3)/3, -np.sqrt(3)/3, np.sqrt(3)/3], [-0.32505758, -0.32505758, 0.88807383], [0, 0, 1], [-0.32505758, -0.32505758, 0.88807383]]) trimesh = TriMesh(points, trilist) vertex_normals = trimesh.vertex_normals() assert_allclose(vertex_normals, expected_normals) trimesh.points = trimesh.points.astype(np.float32) vertex_normals = trimesh.vertex_normals() assert_allclose(vertex_normals, expected_normals)