trimesh.inertia

inertia.py

Functions for dealing with inertia tensors.

Results validated against known geometries and checked for internal consistency.

trimesh.inertia.cylinder_inertia(mass, radius, height, transform=None)

Return the inertia tensor of a cylinder.

Parameters:
  • mass (float) – Mass of cylinder

  • radius (float) – Radius of cylinder

  • height (float) – Height of cylinder

  • transform ((4, 4) float) – Transformation of cylinder

Returns:

inertia – Inertia tensor

Return type:

(3, 3) float

trimesh.inertia.principal_axis(inertia)

Find the principal components and principal axis of inertia from the inertia tensor.

Parameters:

inertia ((3, 3) float) – Inertia tensor

Returns:

  • components ((3,) float) – Principal components of inertia

  • vectors ((3, 3) float) – Row vectors pointing along the principal axes of inertia

trimesh.inertia.radial_symmetry(mesh)

Check whether a mesh has radial symmetry.

Returns:

  • symmetry (None or str) – None No rotational symmetry ‘radial’ Symmetric around an axis ‘spherical’ Symmetric around a point

  • axis (None or (3,) float) – Rotation axis or point

  • section (None or (3, 2) float) – If radial symmetry provide vectors to get cross section

trimesh.inertia.scene_inertia(scene, transform)

Calculate the inertia of a scene about a specific frame.

Parameters:
  • scene (trimesh.Scene) – Scene with geometry.

  • transform (None or (4, 4) float) – Homogeneous transform to compute inertia at.

trimesh.inertia.sphere_inertia(mass, radius)

Return the inertia tensor of a sphere.

Parameters:
  • mass (float) – Mass of sphere

  • radius (float) – Radius of sphere

Returns:

inertia – Inertia tensor

Return type:

(3, 3) float

trimesh.inertia.transform_inertia(transform, inertia_tensor, parallel_axis=False, mass=None)

Transform an inertia tensor to a new frame.

Note that in trimesh mesh.moment_inertia is axis aligned and at mesh.center_mass.

So to transform to a new frame and get the moment of inertia at the center of mass the translation should be ignored and only rotation applied.

If parallel axis is enabled it will compute the inertia about a new location.

More details in the MIT OpenCourseWare PDF:

` MIT16_07F09_Lec26.pdf`

transform(3, 3) or (4, 4) float

Transformation matrix

inertia_tensor(3, 3) float

Inertia tensor.

parallel_axisbool

Apply the parallel axis theorum or not. If the passed inertia tensor is at the center of mass and you want the new post-transform tensor also at the center of mass you DON’T want this enabled as you only want to apply the rotation. Use this to get moment of inertia at an arbitrary frame that isn’t the center of mass.

transformed(3, 3) float

Inertia tensor in new frame.