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.

댓글을 달려면 로그인하십시오.

범주

Find more on Delaunay Triangulation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by