# how can i calculate the volume of my 3d triangular mesh model (surface based mesh)

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

## Recommended Posts

how can i compute the volume of my 3d triangular mesh model (surface based mesh)...

and how can i compute the volume of triangle...

I tried this link

but when i implemented...I got some difference...

the width , height and depth of my rectangle is

width = 120.9
height = 63.6656
Depth = 39.87

so the total volume should be w*h*d = 306898
but with volume of triangle I found is 249042 .

how can i find exact volume through triangle volume.
may be i need to compute voxels but how ?

thanks

##### Share on other sites
Well, I don't know, but some notes about the terms you use:

triangles don't have volumes. "Tetrahedron":s have volumes.

by vowels (the a,e,i,o,u sounds) you mean "voxel":s

##### Share on other sites
oh i need to edit.. thanks for pointing mistake :)

##### Share on other sites
Well, there's an idea, but I haven't though it through.

For every triangles: connect the three vertices with the origin (0,0,0 of your coordinate system), that will be a tetrahedron. Calculate its volume. This has to be a signed volume: if the origin is at the back side of the triangle (if it's CCW) then it's positive; if the origin is on the front side then it's negative. Sum these volumes to get the volume of the whole mesh.

##### Share on other sites
Or maybe the volume of the tetrahedron is signed anyway, if you calculate it using vector algebra (which you should).

##### Share on other sites
I guess that would work for a convex mesh..

##### Share on other sites
Quote:
 Original post by NanookI guess that would work for a convex mesh..

I think not, if you use SIGNED (+/-) volumes for the tetrahedrons. Just like in 2D.

##### Share on other sites
Adding up the signed volumes works just fine.

##### Share on other sites
ya i am also guessing this method could be apply in convex mesh but what about cancave like Teapot...torus...?

##### Share on other sites
Quote:
 Original post by alvaroAdding up the signed volumes works just fine.

##### Share on other sites
My solution may be super slow and not very elegant, but you could try rendering the object wireframed and rendering it multiple times while pushing the near-plane through the object, so you kind of create a voxel-representation. Finally you just have to count the pixels enclosed by the cross-sections (maybe by filling the image with one color and starting at the e.g. upper right corner which isn't inside the object for sure) and add them up. It may neither be exact nor fast, but it works with non-convex meshes (they have to be enclosed though)

##### Share on other sites
The signed sum thing works with concave meshes too, for crying out loud!!!!!!!!!!!!!

##### Share on other sites
Quote:
 Original post by szecsThe signed sum thing works with concave meshes too, for crying out loud!!!!!!!!!!!!!

Take your pill now. :)

##### Share on other sites
Quote:
Original post by alvaro
Quote:
 Original post by szecsThe signed sum thing works with concave meshes too, for crying out loud!!!!!!!!!!!!!

Take your pill now. :)

No!!!!111
I killed some kitties instead [flaming]

##### Share on other sites
Quote:
 Original post by szecsThe signed sum thing works with concave meshes too, for crying out loud!!!!!!!!!!!!!
That it does, but depending on the accuracy of result required, a voxel-approximation might be faster, especially if implemented on the GPU.

##### Share on other sites
guys what i have found from wikipedia is..

For a tetrahedron with vertices a = (a1, a2, a3), b = (b1, b2, b3), c = (c1, c2, c3), and d = (d1, d2, d3), the volume is (1/6)·|det(a−b, b−c, c−d)|, or any other combination of pairs of vertices that form a simply connected graph. This can be rewritten using a dot product and a cross product, yielding

V = ((a-d) dot ((b-d) cross (c-d)))/6

this is important...
If the origin of the coordinate system is chosen to coincide with vertex d, then d = 0, so

V = ((a) dot (b cross c)) / 6

i have implemented on rectangle and got perfect accurate result... but haven't implement on arbitrary or concave model...for this i need to find model with known volume then i will try....

double SetVolumeOfTriangle(GLpoint *p1, GLpoint *p2, GLpoint *p3){	GLpoint  cross;	VectorCrossProduct(p2, p3, &cross);		return VectorDotProduct(p1, &cross)/6.0f;}

##### Share on other sites
Try with two separate cubes or an "L" shape...

Anyway, it's a tetrahedron, not a triangle. A triangle has no volume since it's a 2D shape!

##### Share on other sites
Quote:
Original post by swiftcoder
Quote:
 Original post by szecsThe signed sum thing works with concave meshes too, for crying out loud!!!!!!!!!!!!!
That it does, but depending on the accuracy of result required, a voxel-approximation might be faster, especially if implemented on the GPU.

What? We are talking about a handful of multiplies and additions for each triangle in the mesh. I can't imagine an algorithm that does anything with a mesh that would be significantly faster than this. If you are going to get a GPU involved, implement the same algorithm in the GPU: It will be much faster and much more accurate than any voxel-counting scheme.

##### Share on other sites
Quote:
 Original post by alvaroWhat? We are talking about a handful of multiplies and additions for each triangle in the mesh. I can't imagine an algorithm that does anything with a mesh that would be significantly faster than this.
Fair enough. I had in mind doing something more with the voxel representation after it was generated, but this probably has limited utility for other people [smile]

##### Share on other sites
Why there is some difference in volumes...(Solidwork and OpenGL) ? make guess :)
actually here we just wanted to calculate volume ...so we did..
thanks zec :)

PS:
guys can you guide me to make this model dynamic...I mean when we pick this model to 10 feet from the floor.. after releasing..due to gravity it start moving to floor direction and due to mass it start bouncing when strike to floor.
Here just want floor and object collision ... not object to object...

##### Share on other sites
Look here http://www.melax.com/ for "Volume Integration".

##### Share on other sites
If you are wondering why the two values are different: think about it a bit.
Think about how SolidWorks works (not polygon based, so more realistic for curved objects) and how .obj format works (polygon based, not so realistic for curved objects).

Check volumes of boxy shapes, as I already suggested.

##### Share on other sites
In general finding signed volumes of tetrahedra should be enough. For every tetrahedron you have to count its volume:

http://mathworld.wolfram.com/Tetrahedron.html

In general those problems (about meshes etc) are considered widely in science called 'computational geometry'.

##### Share on other sites

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

## 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

• ### Forum Statistics

• Total Topics
628710
• Total Posts
2984324

• 23
• 11
• 9
• 13
• 14