# How to calculate volume of any given 3D mesh

Given 3D mesh with a closed surface. (solid object without hole).

I'm looking for an algorithm to calculate its volume.

There are several ideas, Such as

• Voxelized and count voxels
• Point cloud and Monte-carlo integration to find the point inside the mesh.

I didn't know yet if these are possible but it would give me a pretty rough estimation.
So I'd like to have an accurate analysis approach.

Any suggestion?

## 1 Answer

The triangle form of the Shoelace Formula can be extended to 3D by using tetrahedrons instead of triangles.

1. Pick a point, Any point can be used, even one of the original vertices of the mesh (personally I tend to use the x,y,z min of the mesh AABB).
2. For each triangle, construct a tetrahedron using the triangle vertices and this chosen point, and calculate the volume of this tetrahedron.
3. Assuming mesh triangles are CCW wound, sum all the volumes of tets with CCW winding, and subtract the volumes of the tetrahedrons with CW winding (if your mesh uses CW winding, then add all the CW tet volumes together and subtract volumes of tets which are CCW).

Calculating the determinent of the tetrahedron is useful since it can be used to deduce both the volume, and winding of a tetrahedron.