MATLAB: Intersection volume of two 3d alphashapes

alphashapeintersectionMATLABvolume

Hi
I have two alphaShapes in 3d that overlap each other and I would like to know the volume of the overlapsing. I already did it in 2d with polygons (but it was the overlaping area, not volume of course) using the functions intersect and polyarea but I can't find something similar for 3d shapes. I use matlab r2018a.

Best Answer

Let's say you have two shapes that were developed as follows using column vectors as inputs:
shp1=alphaShape(x1,y1,z1);
shp2=alphaShape(x2,y2,z2);
You could determine the points of shp1 that are in shp2 and vica versa the points of shp2 that are in shp1 via the inShape function, then use those to get a new shape, shp3, that represents the intersection:
id1=inShape(shp2,x1,y1,z1);
id2=inShape(shp1,x2,y2,z2);
shp3=alphaShape([x1(id1); x2(id2)], [y1(id1); y2(id2)], [z1(id1); z2(id2)]);
You can then get the volume by:
V=volume(shp3);