MATLAB:从一组散射的3D点计算凹面多面体的体积

时间:2014-08-25 13:55:34

标签: matlab computational-geometry polyhedra non-convex concave-hull

我有20到30个随机生成的3D点作为定义多面体的顶点。我已经尝试使用DelaunayTri(points)枚举小平面并使用交叉乘积的行列式来计算和求和四面体体积,但我不确定它对于非凸的多面体是否正常。

另一种可能的方法是将凹面多面体划分为凸面(通过检测凸面内部的点),但是这种不相交划分的算法不适合我。

另外,如何绘制如此凹陷的船体?

1 个答案:

答案 0 :(得分:1)

  

感谢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

相关问题