Robust way to calculate volume of a 3D polygon given a triangulation

5 views (last 30 days)
I am looking for a way to calculate the volume of this shape. I export this shape to a professional finite element software which gives the volume as 4.0821e-8 so that is the number I am looking for. I currently use the following:
i1 = tri(:,1);
i2 = tri(:,2);
i3 = tri(:,3);
% vectors of triangle base
v1 = [p2(i1,1)-p2(i2,1) p2(i1,2)-p2(i2,2) p2(i1,3)-p2(i2,3)];
v2 = [p2(i1,1)-p2(i3,1) p2(i1,2)-p2(i3,2) p2(i1,3)-p2(i3,3)];
A = 1/2*cross(v1,v2,2); % surface of a triangle
V = 1/3*dot(A,[x(i1) y(i1) z(i1)],2); % volume of a triangle
V = sum(abs(V))
But it gives a different value. How can I find the volume robustly? I have attached a mat file with the variables tri and p2 such that ths plots the shape:
trisurf(tri,p2(:,1),p2(:,2),p2(:,3),'facecolor','c','edgecolor','b')

Answers (0)

Categories

Find more on Triangulation Representation in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!