我有20到30个随机生成的三维点作为顶点,用以定义一个多面体。我已经尝试使用DelaunayTri(points)来列举面,并使用叉积的行列式计算和求和四面体的体积,但我不确定它是否适用于非凸多面体。
另一种可能的方法是将凹多面体划分为凸多面体(通过检测在凸包内的点),但是我缺乏这种不相交分区的算法。
此外,如何绘制这样的凹壳?
另一种可能的方法是将凹多面体划分为凸多面体(通过检测在凸包内的点),但是我缺乏这种不相交分区的算法。
此外,如何绘制这样的凹壳?
alphaShape
与convhull
相似,但更加通用。它可以创建非凸形状。npts = 75;
pts = randn(npts,3);
scatter3(pts(:,1),pts(:,2),pts(:,3),'filled')
shp = alphaShape(pts);
h = plot(shp);
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')
convhulln
不够用的话,这个摘录可能会有你需要的东西。祝你好运,并且如果你成功了,请随时在这里更新。 - Slaiyer