Volume of 3D polyhedron
15 ビュー (過去 30 日間)
古いコメントを表示
Given a set of 3D coordinates, how can one find the volume of the polyhedron that is not necessarily convex?
7 件のコメント
Iila
2016 年 2 月 25 日
Thank you. But it doesn't. My polyhedra are concave. I also want to calculate the self intersecting volume, if any.
採用された回答
Mike Garrity
2016 年 2 月 24 日
One option you might look at is alphaShape. It's similar to convhull, but more general. It will create non-convex shapes.
You use it like this. First I need a simple cloud of points.
npts = 75;
pts = randn(npts,3);
scatter3(pts(:,1),pts(:,2),pts(:,3),'filled')
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/173011/image.png)
Then I create my alphaShape, and plot it.
shp = alphaShape(pts);
h = plot(shp);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/173012/image.png)
But the reason this might be useful for you, is that it has a method that will return the volume of the shape:
volume(shp)
ans =
27.3914
And another method which will tell you whether other points are inside the shape.
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')
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/173014/image.png)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Bounding Regions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!