What is the missing factor in the code attached for calculating the area of a 3D surface

1 view (last 30 days)
The below code is supposed to find the area of a surface by summing the area of each triangles. But while running the code the area id always turning out to be zero. Kindly suggest some solution to resolve this issue
T = delaunay(X,Y);
TO = triangulation(T,X(:),Y(:),Z(:));
trimesh(TO)
area = 0; %initialize the area
%loop over all the desired small triangles and accumulate the areas
for i = 1:size(TO.ConnectivityList,1) %the number of rows gives the number of triangles produced
a = TO.Points(TO.ConnectivityList(i,:),:); %this gives the 3 vertices of the ith triangl%e
if (a(:,3) > 0.000015 ) % for z>15 micron
if (a(:,1:2) > 0.000075) % for x & y > 75 micron
if (any((0.383*a(:,1)+ a(:,2) < 0.0000128725) & (0.383*a(:,2)+ a(:,1)) < 0.0000128725))
p1 = a(1,:);
p2 = a(2,:);
p3 = a(3,:);
area = area + 0.5 * norm(cross(p2-p1,p3-p1));
end
end
end
end

Answers (1)

Prudhvi Peddagoni
Prudhvi Peddagoni on 31 Aug 2020
Hi Anand S,
It seems that 2nd and 3rd if conditions are cancelling each other in the above code.
The second if condition is that the values of a(: ,1:2) should be greater than 0.000075 while the third if condition is that the value 0.383*a(: ,1) + a(: ,2) should be less than 0.0000128725.
But it shouldn’t be possible according to the second if condition as a(: ,2) alone has a value greater than 0.000075 which is greater than 0.0000128725. So the area is not getting updated.
Hope this helps.
  1 Comment
Anand S
Anand S on 31 Aug 2020
Thanks for your input. I have updated the third condition like this
if (any((a(:,2) < -2.589970505*a(:,1)+ 0.0003212305608) & (a(:,2) < -0.386104783*a(:,1)+ 0.000124028656)))
Now I am getting non zero value for area.

Sign in to comment.

Categories

Find more on Delaunay Triangulation in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!