Hilariously fast volume computation with the divergence theorem (2018)
Article URL: https://alyssarosenzweig.ca/blog/hilariously-fast-volume-computation-with-the-divergence-theorem.html Comments URL: https://news.ycombinator.com/item?id=49476143 Points: 247 # Comments: 65
The article discusses a fast algorithm for calculating the volume of a simple, closed, triangulated 3D mesh based on the Divergence Theorem. This theorem allows the volume to be calculated as a surface integral over the mesh's triangles. The algorithm begins by defining a function 𝐅 whose divergence is equal to one, which simplifies the volume formula to the sum of surface integrals over each triangle in the mesh.
Each triangle is parametrized and its surface integral is calculated using the cross product of two vectors derived from the triangle's vertices. The X component of the cross product is computed as it is the only non-zero component due to the 𝐅 function. This process results in the volume being expressed as the sum of six terms for each triangle, involving vertex coordinates and their X values.
By substituting the parametrization and simplifying the integrals, the algorithm reduces to a straightforward loop over the triangles, with each iteration performing basic arithmetic operations (additions, multiplications, and a single division constant). The final formula for the volume is V=16∑i=0(Δi1×Δi2)x(Ti0x+Ti1x+Ti2x), which requires 8n−1 additions and 3n+1 multiplications for n triangles, totaling 11n floating point operations.
This method is computationally efficient compared to traditional volume computation methods, which often involve rendering and sampling, making it particularly suitable for real-time applications like video games or simulations running on affordable hardware such as a Raspberry Pi. The article concludes by noting that the algorithm's novelty is uncertain, as a similar approach was found in a different paper by Zheng and Chen.
Written by urgent.news from Hacker News Best's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.
This story
This is one outlet's version. Read the fullest account.
- Hilariously Fast Volume Computation with the Divergence Theorem (2018) alyssarosenzweig.ca