waxmorph.data.normalize_mesh

Contents

waxmorph.data.normalize_mesh#

waxmorph.data.normalize_mesh(mesh, target_extent=10.0)[source]#

Center and isotropically scale a mesh in place, preserving aspect ratio.

Returns the same object with its bounding-box center at the origin and longest side equal to target_extent. Both target and original maximum extents must be positive and finite.

Examples

>>> mesh = trimesh.creation.box(extents=(2, 4, 6))
>>> _ = normalize_mesh(mesh, target_extent=3.0)
>>> print(mesh.bounds.round(1).tolist(), mesh.extents.round(1).tolist())
[[-0.5, -1.0, -1.5], [0.5, 1.0, 1.5]] [1.0, 2.0, 3.0]
Parameters:
Return type:

Trimesh