MATLAB:从分散的3D点集计算凹多面体的体积

4
我有20到30个随机生成的三维点作为顶点,用以定义一个多面体。我已经尝试使用DelaunayTri(points)来列举面,并使用叉积的行列式计算和求和四面体的体积,但我不确定它是否适用于非凸多面体。
另一种可能的方法是将凹多面体划分为凸多面体(通过检测在凸包内的点),但是我缺乏这种不相交分区的算法。
此外,如何绘制这样的凹壳?
1个回答

2
感谢Mike Garrity来自MATLAB Answers™alphaShapeconvhull相似,但更加通用。它可以创建非凸形状。
样本点云:
npts = 75;
pts = randn(npts,3);
scatter3(pts(:,1),pts(:,2),pts(:,3),'filled')

Sample point cloud

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

Alpha形状图:

Alpha shape plot

Alpha形状的体积:
volume(shp)

ans =
    27.3914

另一种指示形状内其他点的方法(用绿色表示):
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 shape in green


你是否知道任何计算 n 维数据的方法? - Dr. No
1
@JohnD,恐怕我不是,但如果convhulln不够用的话,这个摘录可能会有你需要的东西。祝你好运,并且如果你成功了,请随时在这里更新。 - Slaiyer

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接