Trouble with finding the surface area given surface triangles their vertices and the vertices' normals

2 次查看(过去 30 天)
Hi, I am trying to find the surface area of a figure and as the title suggests and am unable to do so. I have tried a couple ways (a double integration of the surface normals by calling the trapz function within a trapz function) and taking the cross product to find the area of the individual triangles and then adding the areas up. I keep running into errors though and was hoping I could find help here. I think my problems lie in a misunderstanding of the triangle indices data I have and how to use them to find the surface area.
I have 3 matrices, vertices(mx3), triangles((~2*m)x3), and normals(mx3). My understanding is that the columns of vertices are the x, y, and z coordinates respectively, the columns of normals are the x, y, and z coordinates of each vector for each point in vertices, and then triangles is what I am a little confused about. I think it is the indices of the coordinate points in vertices, but am not sure. Could someone shed some light on what it probably is, and if I am right, give an explanation so that I may understand it better?
Further, if you could provide a push in the right direction to getting the surface area, I would greatly appreciate it!
the trapz within a trapz code I tried to use was influenced by the help given for this question: http://www.mathworks.com/matlabcentral/answers/84614-finding-the-surface-area-of-a-3-d-plot
x = linspace(floor(min(conc(:,1))),ceil(max(conc(:,1))));
y = linspace(floor(min(conc(:,2))),ceil(max(conc(:,2))));
S = sqrt(normals(:,1).^2 + normals(:,2).^2 + normals(:,3).^2)./normals(:,3)
SA = trapz(y,trapz(x,S));
where conc is the concatenated matrix of the matrices of vertices (there is more than one vertices matrix, but I just concatenate them vertically), and normals is the vertically concatenated matrices of surface normals.
This leads to the error "Error using trapz (line 58) LENGTH(X) must equal the length of Y in dim 1."
Thanks in advance for any help and insight!

采纳的回答

Roger Stafford
Roger Stafford 2015-2-16
There should be no need to use 'trapz' in this problem. Just sum the areas of the triangles, making sure that you have the positive area of each. Also I see no need to use the normals. You should have a list of all the triangles and for each one, indices into its three vertices. If P1, P2, and P3 are three-element vectors for the three vertices of a triangle, its area is:
A = 1/2*norm(cross(P2-P1,P3-P1));
Take the sum of all of these areas.
  3 个评论
Roger Stafford
Roger Stafford 2015-2-17
I would think each of your three triangle indices is an index into the corresponding row of the m-by-3 'vertices' matrix. Each such row would have the three cartesian coordinates. In other words, for, say, the fourth triangle indices of 5,4,6, you would have P1 = vertices(5,:), P2 = vertices(4,:), and P3 = vertices(6,:) for the three vertices' position vectors.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Numerical Integration and Differentiation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by