volume_polyhedron

compas.geometry.volume_polyhedron(polyhedron)[source]

Compute the volume of a polyhedron represented by a closed mesh.

Parameters

polyhedron (tuple[sequence[[float, float, float] | Point], sequence[sequence[int]]]) – The vertices and faces of the polyhedron.

Returns

float – The volume of the polyhedron.

Notes

This implementation is based on the divergence theorem, the fact that the area vector is constant for each face, and the fact that the area of each face can be computed as half the length of the cross product of two adjacent edge vectors 1.

\begin{align} V = \int_{P} 1 &= \frac{1}{3} \int_{\partial P} \mathbf{x} \cdot \mathbf{n} \\ &= \frac{1}{3} \sum_{i=0}^{N-1} \int{A_{i}} a_{i} \cdot n_{i} \\ &= \frac{1}{6} \sum_{i=0}^{N-1} a_{i} \cdot \hat n_{i} \end{align}

Warning

The volume computed by this funtion is only correct if the polyhedron is convex, has planar faces, and is positively oriented (all face normals point outwards).

References

1

Nurnberg, R. Calculating the area and centroid of a polygon in 2d. Available at: http://wwwf.imperial.ac.uk/~rn/centroid.pdf