trimesh.permutate

permutate.py

Randomly deform meshes in different ways.

class trimesh.permutate.Permutator(mesh)

Bases: object

__init__(mesh)

A convenience object to get permutated versions of a mesh.

noise(magnitude=None)

Add gaussian noise to every vertex of a mesh, making no effort to maintain topology or sanity.

Parameters:
  • mesh (trimesh.Trimesh) – Input geometry, will not be altered

  • magnitude (float) – What is the maximum distance per axis we can displace a vertex. If None, value defaults to (mesh.scale / 100.0)

Returns:

permutated – Input mesh with noise applied

Return type:

trimesh.Trimesh

tessellation()

Subdivide each face of a mesh into three faces with the new vertex randomly placed inside the old face.

This produces a mesh with exactly the same surface area and volume but with different tessellation.

Parameters:

mesh (trimesh.Trimesh) – Input geometry

Returns:

permutated – Mesh with remeshed facets

Return type:

trimesh.Trimesh

transform(translation_scale=1000)

Return a permutated variant of a mesh by randomly reording faces and rotatating + translating a mesh by a random matrix.

Parameters:

mesh (trimesh.Trimesh) – Mesh, will not be altered by this function

Returns:

permutated – Mesh with same faces as input mesh but reordered and rigidly transformed in space.

Return type:

trimesh.Trimesh

trimesh.permutate.noise(mesh, magnitude=None)

Add gaussian noise to every vertex of a mesh, making no effort to maintain topology or sanity.

Parameters:
  • mesh (trimesh.Trimesh) – Input geometry, will not be altered

  • magnitude (float) – What is the maximum distance per axis we can displace a vertex. If None, value defaults to (mesh.scale / 100.0)

Returns:

permutated – Input mesh with noise applied

Return type:

trimesh.Trimesh

trimesh.permutate.tessellation(mesh)

Subdivide each face of a mesh into three faces with the new vertex randomly placed inside the old face.

This produces a mesh with exactly the same surface area and volume but with different tessellation.

Parameters:

mesh (trimesh.Trimesh) – Input geometry

Returns:

permutated – Mesh with remeshed facets

Return type:

trimesh.Trimesh

trimesh.permutate.transform(mesh, translation_scale=1000.0)

Return a permutated variant of a mesh by randomly reording faces and rotatating + translating a mesh by a random matrix.

Parameters:

mesh (trimesh.Trimesh) – Mesh, will not be altered by this function

Returns:

permutated – Mesh with same faces as input mesh but reordered and rigidly transformed in space.

Return type:

trimesh.Trimesh