(Python) Is there a means to compute the centroid of a triangulated volume / mesh? #4830
Answered
by
Grantim
bardiche89
asked this question in
Q&A
-
I executed some Boolean operations and now have a mesh entity, is there a simple API to get its centroid? Thanks for your help. |
Beta Was this translation helpful? Give feedback.
Answered by
Grantim
Jul 15, 2025
Replies: 1 comment 3 replies
-
Hello! The question is what you mean by centroid, there is simple way of calculating bounding box and its center, and a bit more complex way to calculate mass center: from meshlib import mrmeshpy as mm
mesh = mm.makeUVSphere()
boxCenter = mesh.computeBoundingBox().center()
print(boxCenter)
pointAccum = mm.PointAccumulator()
mm.accumulateFaceCenters(pointAccum,mesh)
centroid = mm.Vector3f()
eigenvectors = mm.Matrix3f()
eigenvalues = mm.Vector3f()
pointAccum.getCenteredCovarianceEigen(centroid,eigenvectors,eigenvalues)
print(centroid) |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sure, there was
findCenterFromFaces()
which should be equal togetCenteredCovarianceEigen
result.Face areas in this method are considered as weights, so it should work fine even if triangulation is not uniform.
I think you need
findProjection
function