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
Can't understand how to run this and what format the input should be and what is n from the triangulation.
Somebody can help me to running this function, I can´t, please.
Thank you for your inputs. I think it is equally suitable calculating volume of triangular patches of isosurfaces?
I look forward hearing from you.
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);
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.
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.