I want to calculate the volume of a 3D mesh object having a surface made up triangles.
相关问题
- d3.js moving average with previous and next data v
- How to get a fixed number of evenly spaced points
- Check if a number is a perfect power of another nu
- How to determine +/- sign when calculating diagona
- Union of many (more than two) polygons without hol
相关文章
- ceil conterpart for Math.floorDiv in Java?
- why 48 bit seed in util Random class?
- Algorithm for partially filling a polygonal mesh
- Robust polygon normal calculation
- Algorithm for maximizing coverage of rectangular a
- Need help generating discrete random numbers from
- How do you create a formula that has diminishing r
- Math.Max vs Enumerable.Max
If I understand you correctly, you're saying you have a surface mesh of triangles already, and you'd like to generate a 3D solid mesh from it.
Triangles mean that you'll have to use tetrahedral elements for the 3D interior. You'll want to search for an octree auto meshing algorithm that can take a surface mesh as a seed.
This is a common problem in the finite element auto meshing literature. I'd look there.
Reading this paper, it is actually a pretty simple calculation.
The trick is to calculate the signed volume of a tetrahedron - based on your triangle and topped off at the origin. The sign of the volume comes from whether your triangle is pointing in the direction of the origin. (The normal of the triangle is itself dependent upon the order of your vertices, which is why you don't see it explicitly referenced below.)
This all boils down to the following simple function:
and then a driver to calculate the volume of the mesh:
The method above is correct for "simple" objects (no intersecting/overlapping triangles) like spheres tetrahedras and so on. For more complex shapes, a good idea could be to segment the mesh (close it) and calculate the volume of each segment separately. Hope this helps.
The GNU Triangulated Surface Library can do this for you. Keep in mind that the surface must be closed. That is not going to be the case for quite a few 3D models.
If you want to implement it yourself, you could start by taking a look at their code.
Yip Frank Kruegers answer works well +1 for that. If you have vector functions available to you you could use this too:
edit .. added impl. for Dot() and Cross() if you are unsure. Most Math libs will have these. If you are using WPF they are implemented as static methods of the Vector3D class.