# preview mesh in a pyglet window from a terminal, or inline in a notebookmesh.show()

Out[9]:

In [10]:

# facets are groups of coplanar adjacent faces# set each facet to a random color# colors are 8 bit RGBA by default (n,4) np.uint8forfacetinmesh.facets:mesh.visual.face_colors[facet]=trimesh.visual.random_color()

In [11]:

# transform method can be passed a (4,4) matrix and will cleanly apply the transformmesh.apply_transform(trimesh.transformations.random_rotation_matrix())

# the bounding box is a trimesh.primitives.Box object, which subclasses# Trimesh and lazily evaluates to fill in vertices and faces when requestedmesh.bounding_box_oriented.show()

Out[15]:

In [16]:

# bounding spheres and bounding cylinders of meshes are also# available, and will be the minimum volume version of each# except in certain degenerate cases, where they will be no worse# than a least squares fit version of the primitive.print(mesh.bounding_box_oriented.volume,mesh.bounding_cylinder.volume,mesh.bounding_sphere.volume)