What is the missing factor in the code attached for calculating the area of a 3D surface
2 次查看(过去 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
0 个评论
回答(1 个)
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Delaunay Triangulation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!