centroid_polyhedron

compas.geometry.centroid_polyhedron(polyhedron)[source]

Compute the center of mass of a polyhedron.

Parameters:
polyhedrontuple[sequence[[float, float, float] | compas.geometry.Point], sequence[sequence[int]]]

The coordinates of the vertices, and the indices of the vertices forming the faces.

Returns:
[float, float, float]

XYZ coordinates of the center of mass.

Warning

This function assumes that the vertex cycles of the faces are such that the face normals are consistently pointing outwards, resulting in a positive polyhedron.

Examples

>>> from compas.geometry import Polyhedron
>>> p = Polyhedron.from_platonicsolid(6)
>>> centroid_polyhedron(p)
[0.0, 0.0, 0.0]