• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
joohooo

Compute volume from mesh Mathematical demonstration

14 posts in this topic

Hi,

I start a new topic from an older because I have a tiebreaker !
the older topic : [url="http://www.gamedev.net/topic/312027-is-it-possible-to-calculate-the-volume-for-a-mesh/"]http://www.gamedev.n...ume-for-a-mesh/[/url]

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...
0

Share this post


Link to post
Share on other sites
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 ?
0

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
0

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 !
0

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
0

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
0

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'.
0

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 !
0

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.
1

Share this post


Link to post
Share on other sites
[quote name='joohooo' timestamp='1354205457' post='5005341']
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 !
[/quote]

Why not?
For tetrahedron: A*d/3 == Det(v1-v0,v2-v0,v3-v0)/6, where 'A' is the area of some triangle and 'd' is the distance from the opposing vertex to the plane of the triangle. In the Det formula v1,v2,v3 define the same triangle, while v0 is the opposing vertex. Edited by max343
1

Share this post


Link to post
Share on other sites
[quote name='max343' timestamp='1354207366' post='5005355']
[quote name='joohooo' timestamp='1354205457' post='5005341']
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 !
[/quote]

Why not?
For tetrahedron: A*d/3 == Det(v1-v0,v2-v0,v3-v0)/6, where 'A' is the area of some triangle and 'd' is the distance from the opposing vertex to the plane of the triangle. In the Det formula v1,v2,v3 define the same triangle, while v0 is the opposing vertex.
[/quote]

One more time thanks !

But ... I have one more question?? (yes again)
I agree with you for the Det but in the proof we have already use the origin for x0 ! Or in my formula the origin will be your V0 in the det formula as the opposing vertex for each triangle in the mesh. It's not a wrong thing to use the origin for the X0 in F and for the opposing vertex. In my mind , it's look like a ruse... no ?
0

Share this post


Link to post
Share on other sites
I'm not sure whether I got you right, but why is it a bad thing to use the origin? You can choose x0 to be whatever you want, and as long as it's constant this formula will work.

I'll try to rephrase. In the vector field F you can choose x0 as any point in R^3. After some manipulations we can interpret the result as the sum of volumes of multiple tetrahedrons that are comprised of the faces of the mesh and have one vertex in common, that is x0.
Geometrically this makes a lot of sense for sphere-like (or more generally convex) meshes, just choose x0 to be somewhere within the object and the formula should come trivially to you without the divergence theorem. For arbitrary oriented manifolds (or when x0 is not within the enclosed volume) this is not so clear, but the divergence theorem takes care of that. Edited by max343
0

Share this post


Link to post
Share on other sites
Yep,
I understand your last topic and that's why I decided to use this theorem (it's a very interesting thing).
But my worry is completely in the proof because we use the origin in the vector field (make a lot of sense to simplify the formula) AND I use the origin for one of my vertice (opposing vertex) in the Det formula to obtain the dot product of a cross product of three points (after simplification)...

Or in the formula we obtain A*d/3 where d == <x,n> because (<x,n>-<x0,n>)/3==<x,n>/3. To simplify the det formula I use x (opposing vertex)=Origin=xo. And it's here my problem....
0

Share this post


Link to post
Share on other sites
This is not a problem since this is exactly the same point.
Let's recap it by steps:
1. You start with the volume integral.
2. Afterwards, you choose a vector field whose divergence is 1. This vector field is defined up to a constant x0.
3. As any x0 is good, you choose one (for instance the origin) and obtain the flux integral by the divergence theorem.
4. Once finished computing the flux integral, [b]you choose to interpret the formula[/b] as the sum of volumes of tetrahedrons that share the vertex x0.
5. You rewrite the formula from step 4, with an equivalent formulation that uses Det. Again, this is just a change in interpretation.

In steps 2-5 x0 is fixated and chosen exactly once. Hence there's no problem.
1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0