Hilariously fast volume computation with the divergence theorem (2018)
- Mathematics
- Computer Graphics
- Programming
- Developer Tools
The post derives an efficient algorithm for computing the volume of a simple closed triangulated 3D mesh by applying the divergence theorem, so the answer becomes a sum of per-face terms instead of voxelizing, rendering, or doing heavier volumetric work. In plain terms, it turns volume into a surface accounting problem. Several people pointed out that the final formula is the same old signed-volume trick many graphics, CAD, and computational geometry people already use, usually framed as summing tetrahedra against the origin or as the 3D cousin of the shoelace formula for polygon area. What the post added for them was not novelty but a clean derivation that makes the cancellation obvious.
If you need mesh volume or related mass properties, this is a proven O(number of triangles) family of formulas, not a novelty. The practical work is less about math elegance and more about enforcing mesh preconditions, choosing the numerically convenient variant, and deciding whether exact-on-mesh beats a baked or approximate pipeline for your use case.
-
alyssarosenzweig.ca
- Discuss on HN