Calculate the volume of a CAD part
11 ビュー (過去 30 日間)
古いコメントを表示
Is there a way that I can calcuate the volume and bounding box of an .STL file?
0 件のコメント
回答 (1 件)
Rik
2019 年 5 月 20 日
An example to work with would make this easier to answer.
The bounding box should be fairly straightforward: just take the min and max of all your vertices for each coordinate.
Depending on the geometry of your model calculating the volume is either almost trivial, or extremely difficult. If your model is only convex you can use a point inside your mesh and calculate the volume of each tetrahedron. I believe there is a FEX submission that does that, so if you have a convex shape, I will look it up for you.
2 件のコメント
Rik
2019 年 5 月 20 日
That rubber duck isn't actually simple. It contains a lot of concave parts, making volume calculations difficult.
STL files contain two arrays of information: faces (generally triplets of vertex IDs) and vertices (coordinate points, generally xyz). Once you have loaded that into Matlab (reading as text file works well enough), you can do further processing.
It seems someone else did the hard work already: the mesh2tetra function from the FEX should help you separate your model into tetrahedra.
Does this help? Or do you have questions about how to read your specific stl to a format that functions like patch and mesh2tetra like to work with? I could look up some functions that can help you along there.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!