Skip to content

Conversation

@lucagrementieri
Copy link
Contributor

@lucagrementieri lucagrementieri commented Dec 12, 2025

The current calculation of the center of mass returns always the origin for flat meshes. This PR replaces the origin with the centroid of the mesh that is the best estimate of the center of mass for an infinitely thin homogenous flat mesh.

For example, running the script

import numpy as np
import trimesh

# Square [100,101] x [100,101] in the XY plane
vertices = np.array([[100, 100, 0], [101, 100, 0], [101, 101, 0], [100, 101, 0]])
faces = np.array([[0, 1, 2], [0, 2, 3]])
square_mesh = trimesh.Trimesh(vertices=vertices, faces=faces)
print("The current center of mass is", square_mesh.center_mass)

the result with the current code is
>>> The current center of mass is [0. 0. 0.]

while the update code gives
>>> The current center of mass is [100.5 100.5 0. ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant