Upload example/make_sphere.py
Browse files12345678910111213141516171819202122232425262728293031323334353637383940414243444546"""Generate a simple synthetic point cloud (sphere + noise) for quick testing.Run this first if you don't have a scan handy.
python example/make_sphere.py"""import numpy as npimport os
# Make 3000 points on a unit sphere + small noisen = 3000phi = np.random.uniform(0, 2 * np.pi, n)cos_theta = np.random.uniform(-1, 1, n)sin_theta = np.sqrt(1 - cos_theta ** 2)
x = sin_theta * np.cos(phi)y = sin_theta * np.sin(phi)z = cos_theta
pts = np.stack([x, y, z], axis=1)pts += np.random.normal(0, 0.01, pts.shape) # tiny noise
os.makedirs("example", exist_ok=True)
# Save as simple XYZnp.savetxt("example/sphere.xyz", pts, fmt="%.6f")
# Save as ASCII PLYn_verts = len(pts)header = f"""plyformat ascii 1.0element vertex {n_verts}property float xproperty float yproperty float zend_header"""with open("example/sphere.ply", "w") as f: f.write(header) for v in pts: f.write(f"{v[0]:.6f} {v[1]:.6f} {v[2]:.6f}\n")
print("Created example/sphere.ply (and example/sphere.xyz)")print(f" {n_verts} points on a noisy unit sphere")print("\nNext, run:")print(" python -m lightweightmr -i example/sphere.ply -o example/sphere_mesh.ply --device cpu")example/make_sphere.pyAdded+46