我有 20 到 30 个随机生成的 3D 点作为定义多面体的顶点。我已经尝试使用 DelaunayTri(points)
来枚举小平面并使用叉积的行列式来计算和求和四面体体积,但我不确定它是否适用于非凸多面体.
另一种可能的方法是将凹多面体划分为凸多面体(通过检测凸包内部的点),但我没有找到用于这种不相交划分的算法。
此外,如何绘制这样一个凹形外壳?
最佳答案
With thanks to Mike Garrity from MATLAB Answers™
alphaShape
类似于 convhull
, 但更一般。它将创建非凸形状。
样本点云:
npts = 75;
pts = randn(npts,3);
scatter3(pts(:,1),pts(:,2),pts(:,3),'filled')
shp = alphaShape(pts);
h = plot(shp);
Alpha 形状图:
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')
关于MATLAB:根据一组分散的 3D 点计算凹多面体的体积,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25487554/