필터 지우기
필터 지우기

Calculate area within mesh plot

조회 수: 29 (최근 30일)
Adam Levschuk
Adam Levschuk 2020년 8월 4일
댓글: mengchao chen 2021년 10월 18일
Hello all, i am looking to calculate the area of a section of mesh plot. I have attahced a photo of the mesh plot for your sake. You will see that the mesh plot is a bowl shape and i want to calcualte the area (or volume, but ideally area) of the dark blue region at the bottom of the bowl. I am looking to calaculte the area of the plot when Z < 0.01 (for example).
Any ideas on how to do this?
Adam

채택된 답변

Uday Pradhan
Uday Pradhan 2020년 8월 7일
편집: Uday Pradhan 2020년 8월 7일
Hi Adam,
According to my understanding, you want to calculate the surface area of a certain portion of your graph. I have made an assumption that you will be identifying this portion by limiting the z - values of the plot as you have stated taking Z < 0.01 as an example. In that case, we can divide the plot into triangles and then sum the areas of the smaller triangles to find the area of the plot.
To do this, I would suggest plotting your data in the form of a 3 - D triangular mesh and create a triangulation object to plot. This is because we can leverage some properties of the triangulation object to calculate the areas of the triangles that form the plot. I am sharing a simple example to demonstrate my point.
[X,Y] = meshgrid(-8:.05:8);
R = sqrt(X.^2 + Y.^2) + eps;
Z = sin(R)./R; %the function to be plotted
T = delaunay(X,Y); %creates a 2-D Delaunay triangulation from the points in X and Y
TO = triangulation(T,X(:),Y(:),Z(:)); %creates a 3-D triangulation representation with the point coordinates specified as column vectors X, Y, and Z
trimesh(TO) %plots the triangular mesh
The triangulation object TO has two properties TO.Points and TO.ConnectivityList.
Triangulation connectivity list, specified as an m-by-3 matrix, where m is the number of triangles in the plot. Each row of T contains the vertex IDs that define a triangle.
Points, specified as a matrix whose columns are the x-coordinates, y-coordinates, and z-coordinates of the triangulation points. The row numbers of P are the vertex IDs in the triangulation.
The code below calculates the surface area of the graph of the function defined above but ignores those where the functional value is greater than 0.4 (you can replace this with your threshold value and function).
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 triangle
if any(a(:,3) > 0.4)
continue; %if the triangle has a vertex whose z - coordinate is > 0.4 ignore it
end
%extract the three vertices
p1 = a(1,:);
p2 = a(2,:);
p3 = a(3,:);
area = area + 0.5 * norm(cross(p2-p1,p3-p1)); %calculate the area of the small triangle and add with previous result
end
You may use these ideas to calculate the area of the graph that satisfies certain conditons on the function range.
See [1],[2] and [3] to learn more about the concepts used above.
  댓글 수: 3
M.S. Khan
M.S. Khan 2020년 8월 25일
Hi Uday, how can we add all area, please guide
mengchao chen
mengchao chen 2021년 10월 18일
maybe you could delet "if any(a(:,3) > 0.4)
continue; %if the triangle has a vertex whose z - coordinate is > 0.4 ignore it
end"

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by