Created
June 14, 2018 22:56
-
-
Save mikedh/3a462587c1519e3cefdfd6f6c7c1b2ab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import trimesh | |
import numpy as np | |
from scipy.spatial import Voronoi | |
if __name__ == '__main__': | |
points = np.random.random((20,3)) | |
v = Voronoi(points) | |
meshes = [] | |
for idx in v.regions: | |
# only mesh finite regions | |
if -1 in idx: continue | |
if len(idx) < 4: continue | |
m = trimesh.convex.convex_hull(v.vertices[idx]) | |
# color BS | |
color = trimesh.visual.random_color() | |
color[3] = 50 | |
m.visual.face_colors = color | |
meshes.append(m) | |
# show with points | |
trimesh.Scene(np.append(meshes, trimesh.points.PointCloud(points))).show(smooth=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment