Jump to content
  • Advertisement
Sign in to follow this  
joohooo

Compute volume from mesh Mathematical demonstration

This topic is 2056 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

I start a new topic from an older because I have a tiebreaker !
the older topic : http://www.gamedev.n...ume-for-a-mesh/

My question is: How can we prove the formula V= sum(each tetrahedron volume with the origin)
[source lang="cpp"]
float volume = 0;
int* index = I;
for (i = 0; i < T; i++)
{
Vector3 v0 = V[*index++];
Vector3 v1 = V[*index++];
Vector3 v2 = V[*index++];
volume += Dot(v0,Cross(v1,v2));
}
volume /= 6;
[/source]

I know I must use 3D integrals and Fourier moments but I don't know how I can do that !
Please someone give me some clues about a possible math proof ?

Thanks by advance

PS: I already try to find this formula with the gauss theorem as said in the older topic but I never find the result but an approximate result! I obtain the formuma here but with some addition in more...

Share this post


Link to post
Share on other sites
Advertisement
Thanks to your response
but I don't see how it is a "simple" result of the divergence theorem because you don't compute with element surface but with tetrahedron where the base is each triangle of the parametrized surface and the common point is the origin of the 3d space (0,0,0).

The divergence theorem said that the volume is equal to the outward flux of the surface, isn't it ?
Here we don't use surface but volume of tetrahedron composed with origin ?

Could you explain me with math if it's possible ?

Share this post


Link to post
Share on other sites
Alright.

Take the vector field: F=(x-x0)/3, x and x0 are in R^3.
Its divergence with respect to x is 1.

So: Volume = Int[Div(F)*dV] = Int[<F,dS>] = Sum[A_i * (d_i - <n_i,x_0>)]/3
Where: A_i = Area of triangle. With its plane equation <n_i,x>=d_i, with unit normal.
If you choose x0=0, then you get Sum[A_i*d_i/3]
For unit n_i, d_i is exactly the distance of the plane from the origin. So what is written in the sum is exactly the volume of the tetrahedron. Edited by max343

Share this post


Link to post
Share on other sites
Hum, I'm really sorry but I don't understand your demonstration.

If you take vector field F (x,y,z) -> (x-x0,0,0)/3 the divergence is 1/3, not 1 ??
Moreover I don't understand how you insert your inner product d_i - <n_i,x0> and directly the area of a triangle after the gauss theorem
=> Int[<F,dS>] = Sum[A_i * (d_i - <n_i,x_0>)]/3 ??

One more time thanks !

Share this post


Link to post
Share on other sites
x and x0 are points in R^3 and not coordinates.
As for the second question:

F*dS is a two-form defined over the boundary of the volume, while <F,n>*dA is the corresponding two-form defined over subset of R^2.
F*dS = <F,n>*dA = (<x,n> - <x0,n>)/3*dA = (d - <x0,n>)/3*dA
Now, d - <x0,n>/3 is a constant within the triangle, so the integral is: A*(d - <x0,n>)/3.

I've been abusing notation here a bit. It makes little sense to do an inner product between 1-forms and vectors, but it should be fairly obvious what I meant in <~,n>.

Does this make more sense? Edited by max343

Share this post


Link to post
Share on other sites
Ok well,

I don't know it was possible to use points in the function F ? I believed it was just vector field ?


I have a last question (in my mind easy but I want to be sure) : I use only vertices in the code above (v0 v1 v2).
Or your variable d is a distance not a point.
How can we say that A*(d-<x0,n>)3 == 1/2 (P1^P2).d/3 where d must be a vertice ? (n is not obligatory (1,1,1)?)
Moreover if i use the formule of area it's also distance and not vertices....

Many thanks Edited by joohooo

Share this post


Link to post
Share on other sites
Well, vector fields assign vectors to points. So it's only natural to use points in them.
As for 'd', then yes, it's the distance from the plane to the origin when unit normal is used. Since during the integration 'x' lies on the plane, <x,n> is constant and it equals exactly to 'd'.

Share this post


Link to post
Share on other sites
Yes So it doesn't prove my formula with vertices ??
The aim of this formula is to not use distance but just vertices to gain time !

Share this post


Link to post
Share on other sites
I haven't been following the thread, but the code posted in the first post seems fine to me. Instead of "Dot(v0,Cross(v1,v2))" I would have written "Determinant(v0,v1,v2)", but other than that it's exactly how I would have written it.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!