MATLAB Answers

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

2 views (last 30 days)
David Winthrop
David Winthrop on 31 Jan 2020
Commented: KSSV on 1 Feb 2020
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')

  1 Comment

KSSV
KSSV on 1 Feb 2020
Try:
dt = delaunayTriangulation(x,y,z) ;
[C,v] = convexHull(dt);
v

Sign in to comment.

Answers (0)

Sign in to answer this question.

Tags