Skip to content

Rigid Transformations

fit_into_unit_cube(mesh)

Applies translation and global scaling for the mesh to fit inside a cube [0;1]^3

Parameters:

Name Type Description Default
mesh Mesh

the input mesh. Can be any mesh data structure

required

Returns:

Name Type Description
Mesh Mesh

the scaled and translated mesh

flatten(mesh, dim=None)

Snaps to 0 one dimension to retrieve a flat 2D mesh.

Parameters:

Name Type Description Default
mesh Mesh

input mesh

required
dim int

The dimension to flatten. If None, the function chooses the dimension which has the smallest variance.

None

Returns:

Type Description
Mesh

the modified input mesh

rotate(mesh, rot, orig=None)

Rotates all vertices of the mesh by a given rotation around a given origin.

Parameters:

Name Type Description Default
mesh Mesh

the input mesh. Can be any mesh data structure

required
rot Rotation | list

The rotation, given as an object or 3 Euler angles

required
orig Vec

The origin of the rotation. If not provided, the function rotates around (0,0,0). Defaults to None.

None

Returns:

Name Type Description
Mesh Mesh

description

scale(mesh, factor, orig=None)

Scales the mesh by a given factor around a given origin (fixed point)

Parameters:

Name Type Description Default
mesh Mesh

the input mesh. Can be any mesh data structure

required
factor float

scale factor. If its magnitude is < 1e-8, will print a warning.

required
orig Vec

Fixed point of the scaling. If not provided, it is set at (0,0,0). Defaults to None.

None

Returns:

Name Type Description
Mesh Mesh

the scaled input mesh.

scale_xyz(mesh, fx=1.0, fy=1.0, fz=1.0, orig=None)

Scales the mesh independently along three axes. If any factor as a magnitude < 1e-8, will print a warning.

Parameters:

Name Type Description Default
mesh Mesh

the input mesh. Can be any mesh data structure

required
fx float

Scale factor along x. Defaults to 1.

1.0
fy float

Scale factor along y. Defaults to 1.

1.0
fz float

Scale factor along z. Defaults to 1.

1.0
orig Vec

Fixed point of the scaling. If not provided, it is set at (0,0,0). Defaults to None.

None

Returns:

Name Type Description
Mesh Mesh

the scaled mesh.

translate(mesh, tr)

Translates all vertices of the mesh by a fixed vector

Parameters:

Name Type Description Default
mesh Mesh

the input mesh. Can be any mesh data structure

required
tr Vec

the translation vector

required

Returns:

Name Type Description
Mesh Mesh

the translated mesh

translate_to_origin(mesh)

Translates all vertices of the mesh so that its barycenter is at origin (0., 0., 0.)

Parameters:

Name Type Description Default
mesh Mesh

the input mesh

required

Returns:

Name Type Description
Mesh Mesh

the translated mesh