How to get the volume of a 3D concave shape?

Hi smart guys,
I am wondering if anyone knows how to get the volume of a 3D concave shape? The Matlab build-in function can only calculate the volume of a convex shape. For example,
[K, V] = convhulln(shape.vertices);
V is the volume. Here the shape is defined by a mesh with vertices and faces.
Thanks very much.
Best, Aaronne.

 Akzeptierte Antwort

Sean de Wolski
Sean de Wolski am 10 Jan. 2013
Bearbeitet: Sean de Wolski am 10 Jan. 2013

0 Stimmen

I would recommend voxelizing it and then just summing the resulting three dimensional volumetric image. There are a few utilities on the FEX that do this:

Weitere Antworten (2)

Image Analyst
Image Analyst am 10 Jan. 2013

1 Stimme

If you have a 3D image, one way is to just add up all the voxels in the 3D image. It gets more complicated if you don't want a stack of cubes (like a voxelized image) and you want a volume defined by triangulation. And I'm not sure the volume difference would be very significant. Exactly what is the form of the data you are starting with? Do you have a list of (x,y,z) locations for every quantized point in the volume? Or do you only have a few vertices that are scattered around?
José-Luis
José-Luis am 10 Jan. 2013
Bearbeitet: José-Luis am 10 Jan. 2013

1 Stimme

Not automagically. You could try the file exchange. In 3D you could use the delaunay() function and sum up the volumes of all the tetrahedrons.
The volume of a tetrahedron is, in pseudo-code:
V = 1/6 *|det(V1,V2,V3)|
with
V1 := P2-P1
V2 := P3-P2
V3 := P4-P3

5 Kommentare

Sean de Wolski
Sean de Wolski am 10 Jan. 2013
Bearbeitet: Sean de Wolski am 10 Jan. 2013
You would need to remove resulting tetrahedra that have edges outside of the polyhedron. This could work well though - combine the result of the Delaunay Triangulation with something like inpolyhedron in my answer. You would only need to test the mid point on every edge on the convex hull. If it fails, throw that tetrahedron a way.
Sean de Wolski
Sean de Wolski am 10 Jan. 2013
@Jose, best Professional Interest ever!
José-Luis
José-Luis am 10 Jan. 2013
Totally right. The best possible approach though would depend on whether the OP has information about the connectivity. If it is a triangulated surface then the sum of the signed volumes (taking a point outside the polyhedron) would work. Considerably more difficult with a point cloud. Maybe alpha shapes then.
Sean de Wolski
Sean de Wolski am 10 Jan. 2013
Judging by the shape.vertices, I was dangerously assuming there would also be a faces or connectivities matrix as well.
José-Luis
José-Luis am 10 Jan. 2013
@Sean: thanks!

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by