A new algorithm leverages the divergence theorem to compute volume of simple, closed, triangulated 3D meshes efficiently. According to the source, the method works by converting a volume integral into a surface integral over the mesh’s triangular faces, then evaluating it using vertex data.

The approach begins with the divergence theorem, which relates volume integrals to surface integrals. By selecting a function whose divergence equals one, the volume integral simplifies to a surface integral over the mesh surface. This surface integral can then be expressed as a sum of contributions from individual triangles.
Each triangle is parametrized using its three vertices, allowing the surface integral to be rewritten in terms of vertex positions. The cross product of two edge vectors derived from the vertices yields a constant value across each triangle that is straightforward to calculate from vertex data. According to the source, only the X component of the cross product needs computation due to the dot product with zero components.
The resulting algorithm contains no numerical integration or differentiation. Instead, it requires a single loop over all triangles in the mesh. For each triangle, the computation involves seven additions and three multiplications, with a single multiplication occurring outside the loop.
Computationally, this approach is O(n) relative to the number of triangles, requiring 7n additions and 3n multiplications—or approximately 10n floating point operations total. According to the source, this is significantly faster than naive volume computation methods that rely on rendering the mesh and sampling the render, which represents a much more expensive operation.
To illustrate the performance gain, the source notes that on a $35 Raspberry Pi running at 60 frames per second without GPU acceleration, approximately 30 million triangles could be measured per frame. The author notes that further research revealed a prior paper, “Efficient Feature Extraction for 2D/3D Objects in Mesh Representation” by Cha Zheng and Tsuhan Chen, describing what appears to be the same algorithm, though with a different derivation.
Key facts
- The algorithm applies the divergence theorem to convert volume integrals to surface integrals over triangle meshes
- Computational complexity is O(n) relative to triangle count, requiring approximately 10n floating point operations
- Per-triangle calculation requires seven additions and three multiplications
- A Raspberry Pi could process roughly 30 million triangles per frame at 60 fps using only CPU
- The method requires no numerical integration or differentiation, only basic arithmetic on vertex data
