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

1 次查看(过去 30 天)
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

回答(1 个)

Prudhvi Peddagoni
Prudhvi Peddagoni 2020-8-31
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 个评论
Anand S
Anand S 2020-8-31
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Delaunay Triangulation 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by