File Exchange

## Volume of a surface triangulation

version 1.0.0.0 (1.43 KB) by
Given a surface triangulation, compute the volume enclosed using divergence theorem.

Updated 17 Mar 2010

Given a surface triangulation, compute the volume enclosed using divergence theorem.
Assumption:Triangle nodes are ordered correctly, i.e.,computed normal is outwards
Input: p: (3xnPoints), t: (3xnTriangles)
Output: total volume enclosed, and total area of surface

### Cite As

Krishnan Suresh (2020). Volume of a surface triangulation (https://www.mathworks.com/matlabcentral/fileexchange/26982-volume-of-a-surface-triangulation), MATLAB Central File Exchange. Retrieved .

Cherry

The volume computed by the function is not right for some cases, and is right for other cases. If the bounding volume can be a convex hull, using the following MATLAB built-in functions to get the right volumes:

% suppose P is a (n by 3) coordinates matrix of some 3D space points, and coordinates of each row are in the order of (x,y,z)
DT = delaunayTriangulation(P(:,1),P(:,2),P(:,3));
[K,v] = convexHull(DT);

% then v is right volume

Dwayne Bourgoyne

The volume calculation does not appear correct. Application of the divergence theorem to general tri-mesh volumes would be much more involved than a few lines of code. I recommend you run some test cases (eg, a sphere) before using. Area looks correct.

Vikas Kurapati

Can't understand how to run this and what format the input should be and what is n from the triangulation.

Marina Matos

Hi,

Somebody can help me to running this function, I can´t, please.

:)

Lorenzo Luciano

Uwe22

Hej Suresh,

Thank you for your inputs. I think it is equally suitable calculating volume of triangular patches of isosurfaces?

I look forward hearing from you.
Uwe

Pinaki Bhattacharya

Cool application.

Marc Lalancette

Nice application, but here's a cleaned up version (with V = p' and F = f'):
% 'z' coordinate of triangle centers.
FaceCentroidZ = ( V(F(:, 1), 3) + V(F(:, 2), 3) + V(F(:, 3), 3) ) /3;
% Face normal vectors, with length equal to triangle area.
FNdA = cross( (V(F(:, 2), :) - V(F(:, 1), :)), ...
(V(F(:, 3), :) - V(F(:, 2), :)) , 2 ) / 2;
% Volume from divergence theorem (using vector field along z).
V = FaceCentroidZ' * FNdA(:, 3);

Dimid Duchovny

Naoto

Lu

ahmed

Thanks a lot. I have difficult running the code. My input value representing the number of facets if presented in EXCEL file. How can I get the volume and surface area?

Ur response is apprecied in advance.

Matt Kindig

Thanks! This is exactly what I needed!

One thing: I wonder what happens if the volume is not closed? It might be nice if an open volume returned NaN or threw an error or something.

##### MATLAB Release Compatibility
Created with R2008b
Compatible with any release
##### Platform Compatibility
Windows macOS Linux