MATLAB: Calculate the Volume of a Concave Polyhedron from Many Scattered 3D Points

I have 20 to 30 randomly generated 3D points in the form of vertices from which a polyhedron is defined. I tried to use DelaunayTri(points)

to enumerate faces and use the cross product determinant to calculate and sum tetrahedral volumes, but I'm not sure if it works great for polyhedra that are not convex.

Another possible approach would be to partition a concave polyhedron into convex ones (by detecting the points that are inside the convex hull), but the algorithm for such a disjoint partition eludes me.

Also, how can such a concave body be constructed?

+3


source to share


1 answer


Thanks to Mike Garrity of MATLAB Answers ™

alphaShape

similar to convhull

but more general. This will create non-convex shapes.

Point cloud of points:

npts = 75;
pts = randn(npts,3);
scatter3(pts(:,1),pts(:,2),pts(:,3),'filled')

      

Point cloud example

shp = alphaShape(pts);
h = plot(shp);

      

Alpha shape plot:



Alpha shape plot

Alpha Shape Volume:

volume(shp)

ans =
    27.3914

      

Another way to indicate other points within the shape (in green):

testpts = randn(150,3);
inmask = inShape(shp,testpts);
h.FaceColor = [.75 .75 .75];
h.FaceAlpha = .25;
hold on
scatter3(testpts(inmask,1),testpts(inmask,2),testpts(inmask,3),'.','MarkerEdgeColor','green')
scatter3(testpts(~inmask,1),testpts(~inmask,2),testpts(~inmask,3),'.','MarkerEdgeColor','red')

      

Points inside the shape in green

+1


source







All Articles