Skip to content

Comment on Hilariously fast volume computation with the divergence theorem (2018)

Comments

Isn't the same as just taking every triangle from the mesh, calculating the volume of a prism-like polytope between it and its projection on one the planes, and then taking it with a + sign if its projection is oriented in one direction, and with a - sign if it's oriented in another? This kind of formula works based on the basic geometry.

Yes, this is essentially what the author derived (by means of calculus rather than geometric argument but the result is unsurprisingly the same). The 2D analog is easy to grok: to compute the area of a polygon, find the sum of the signed areas of each of the trapezoids formed by an edge and its projection on the x-axis. Turns out the negative areas of the right-to-left trapezoids cancel precisely out any excess area of the left-to-right trapezoids (or in the case of edges below the x-axis, add precisely the "missing" area).

I'm stupid, consider a quadrilateral with points

    b
  a    c
     d
Then the area needs to be the trapezoids projected to x axis is ab+bc-ad-dc. What is the correct way to keep track of the signs? I.e. what is the definition of "right-to-left"?

Polygon edges are usually considered directed and forming a loop, the edges of said quad being either ab, bc, cd, da (clockwise winding) or ad, dc, cb, ba (counterclockwise winding). They give the same result up to sign, as long as you’re consistent. In the first case ab and bc are left-to-right and cd and da right-to-left, and vice versa in the second case. (Vertical edges of course contribute zero area.) The signed area of a right-to-left trapezoid is automatically negative (if above the x-axis) because the delta-x is negative (eg. a_x - d_x < 0 for the da edge), so there’s no need to worry about whether to add or subtract each individual term.

Yep. Using the same kind of calculus ideas, I can also think about a vector field that has a Dirac mass of divergence at some point and zero divergence everywhere else. Then you get an expression that you can sum over faces to determine if a polyhedron contains some point. Again, for the right vector field there is a simple geometric interpretation, namely the solid angle that a face makes with respect to the point.

calculating the volume of a prism-like polytope between it and its projection

There is the key insight that you don't need to explicitly compute this projection.

More correctly, the insight is that this computation is trivial after you expand it.

I wonder if this could be reversed to give an intuitive “proof” of the divergence theorem.

The divergence theorem can be intuitively summarized in one sentence: "what comes out is whatever went in, plus whatever was produced inside"

Minus whatever went away inside, unless you're implicitly allowing negative production.

Yes, both "production" and "comes out" are signed quantities.

A very intuitive presentation of the divergence theorem is here https://youtu.be/TORt20_HjMY?is=uoJ8-2ToCSwW9rVF

Better still, you calculate the signed volume of the the tetrahedron formed by the triangle and the origin (4th vertex).

Yes I remember doing something like that in 90s for a survey/map engineering cad application. After delaunay triangulation, calculating approximate voulume is easy. But this probably is a more general solution

Yes it goes by a couple of names. Surveyor's formula, shoelace formula.

The Surveyor’s Area Formula Bart Braden The College Mathematics Journal, September 1986, Volume 17, Number 4.

https://web.archive.org/web/20150406152731if_/http://www.maa...

Oh, it is the shoelace formula, but for 3D?

OP's description vaguely triggered memories of the shoelace formula from a decade ago, but geometry was never my strong suit. All I remembered was positive/negative triangles (or was it trapezoids)? make magic happen for area calculation.

Yes, the algorithm and its derivations are elementary and rather obvious for anyone decent at undergraduate level mathematics. But still, I am glad to see more people enjoying math!

reminds me of that 1994 paper that reinvented the trapezoidal rule

Except this one 1) didn't try to name it after themselves, 2) explicitly told us it wasn't new, and linked to an example of prior work, and 3) isn't generally taught in high school.

see, when I say something reminds me of something else I don't mean a one-to-one equivalence at every aspect one can think of.

anyhoo, it's always a great skill to review the state-of-the-art BEFORE investing in a work/write-up/article - one of the very first things that a post-graduate program would teach you.

Nah. Being able to derive and prove easy results like this for yourself is both way faster and more reliable than trying to wade through the literature to find the equation you want.

The article relates that this isn't about the state of the art. It's about insight gained while taking a calculus class.

"The following presents a fast algorithm for volume computation of a simple, closed, triangulated 3D mesh."

- we are presented something

"I would be (pleasantly) surprised if the algorithm is novel. Further research after posting reveals the paper Efficient Feature Extraction for 2D/3D Objects in Mesh Representation by Cha Zheng and Tsuhan Chen, which appears to describe the same algorithm, although the derivation is different. It was fun while it lasted!"

- there was an initial expectation, though slim, that it may be novel. then on the discovery that it wasn't, related fun time was insinuated to be over.

are we reading the same text?

It’s someone’s blog post before a calculus exam. I think it’s fun to do this stuff. On your own site you can write whatever you want.

See, when I was a kid I found something I thought was great and inventive only to find that it was not only long trodden mathematics it was famous long trodden mathematics. I named it after myself for humorous value, the distinction between others who dreamed of finding some novel structure and me being solely that I did not know the famous results and conjectures in the space.

https://wiki.roshangeorge.dev/w/Roshan%27s_Conjecture

I think this is quite entertaining.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.