MATLAB:根据一组分散的 3D 点计算凹多面体的体积

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

我有 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')

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

关于MATLAB:根据一组分散的 3D 点计算凹多面体的体积,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25487554/

相关文章:

matlab - Matlab 中的数据加载时间长

matlab - 合并Matlab表中具有相同日期的行

matlab - 为 3D 图形添加完整的 6 个边框

python - 如何: CVXPY Matrix Inequality Constraints

c++ - 如何获取某些点的Voronoi图在QT中显示?

algorithm - 到矩形缓存的最短距离

algorithm - Chazelle三角剖分算法的实现

javascript - 使用 JavaScript 建模 3D 多面体

geometry - 如何检查一组平面多边形是否创建一个水密多面体