| 493 | return mtx1, mtx2, R |
| 494 | |
| 495 | def storePly(path, xyz, rgb): |
| 496 | # Define the dtype for the structured array |
| 497 | dtype = [('x', 'f4'), ('y', 'f4'), ('z', 'f4'), |
| 498 | ('nx', 'f4'), ('ny', 'f4'), ('nz', 'f4'), |
| 499 | ('red', 'u1'), ('green', 'u1'), ('blue', 'u1')] |
| 500 | |
| 501 | normals = np.zeros_like(xyz) |
| 502 | |
| 503 | elements = np.empty(xyz.shape[0], dtype=dtype) |
| 504 | attributes = np.concatenate((xyz, normals, rgb), axis=1) |
| 505 | elements[:] = list(map(tuple, attributes)) |
| 506 | |
| 507 | # Create the PlyData object and write to file |
| 508 | vertex_element = PlyElement.describe(elements, 'vertex') |
| 509 | ply_data = PlyData([vertex_element]) |
| 510 | ply_data.write(path) |