TRIMESHMEANBREADTH Mean breadth of a triangular mesh. MB = trimeshMeanBreadth(VERTICES, FACES) Computes the mean breadth (proporitonal to the integral of mean curvature) of a triangular mesh. Example [V, F] = createCube; F2 = triangulateFaces(F); MB = trimeshMeanBreadth(V, F2) MB = 1.5000 See also meshes3d, trimeshSurfaceArea, trimeshEdgeFaces, polyhedronMeanBreadth References Stoyan D., Kendall W.S., Mecke J. (1995) "Stochastic Geometry and its Applications", John Wiley and Sons, p. 26 Ohser, J., Muescklich, F. (2000) "Statistical Analysis of Microstructures in Materials Sciences", John Wiley and Sons, p.352
0001 function mb = trimeshMeanBreadth(vertices, faces) 0002 %TRIMESHMEANBREADTH Mean breadth of a triangular mesh. 0003 % 0004 % MB = trimeshMeanBreadth(VERTICES, FACES) 0005 % Computes the mean breadth (proporitonal to the integral of mean 0006 % curvature) of a triangular mesh. 0007 % 0008 % Example 0009 % [V, F] = createCube; 0010 % F2 = triangulateFaces(F); 0011 % MB = trimeshMeanBreadth(V, F2) 0012 % MB = 0013 % 1.5000 0014 % 0015 % See also 0016 % meshes3d, trimeshSurfaceArea, trimeshEdgeFaces, polyhedronMeanBreadth 0017 % 0018 % References 0019 % Stoyan D., Kendall W.S., Mecke J. (1995) "Stochastic Geometry and its 0020 % Applications", John Wiley and Sons, p. 26 0021 % Ohser, J., Muescklich, F. (2000) "Statistical Analysis of 0022 % Microstructures in Materials Sciences", John Wiley and Sons, p.352 0023 0024 % ------ 0025 % Author: David Legland 0026 % E-mail: david.legland@inrae.fr 0027 % Created: 2015-08-19, using Matlab 8.5.0.197613 (R2015a) 0028 % Copyright 2015-2024 INRA - Cepia Software Platform 0029 0030 %% Check input validity 0031 0032 if size(faces, 2) ~= 3 0033 error('meshes3d:trimeshMeanBreadth:NonTriangularMesh', ... 0034 'Requires a triangular mesh as input'); 0035 end 0036 0037 %% Compute edge and edgeFaces arrays 0038 % Uses the same code as in trimeshEdgeFaces 0039 0040 % compute vertex indices of each edge (in increasing index order) 0041 edges = sort([faces(:,[1 2]) ; faces(:,[2 3]) ; faces(:,[3 1])], 2); 0042 0043 % create an array to keep indices of faces "creating" each edge 0044 nFaces = size(faces, 1); 0045 edgeFaceInds = repmat( (1:nFaces)', 3, 1); 0046 0047 % sort edges, keeping indices 0048 [edges, ia, ib] = unique(edges, 'rows'); %#ok<ASGLU> 0049 nEdges = size(edges, 1); 0050 0051 % allocate memory for result 0052 edgeFaces = zeros(nEdges, 2); 0053 0054 % iterate over edges, to identify incident faces 0055 for iEdge = 1:nEdges 0056 inds = find(ib == iEdge); 0057 edgeFaces(iEdge, 1:length(inds)) = edgeFaceInds(inds); 0058 end 0059 0060 0061 %% Compute dihedral angle for each edge 0062 0063 % compute normal of each face 0064 normals = meshFaceNormals(vertices, faces); 0065 0066 % allocate memory for resulting angles 0067 alpha = zeros(nEdges, 1); 0068 0069 % iterate over edges 0070 for iEdge = 1:nEdges 0071 % indices of adjacent faces 0072 indFace1 = edgeFaces(iEdge, 1); 0073 indFace2 = edgeFaces(iEdge, 2); 0074 0075 % normal vector of adjacent faces 0076 normal1 = normals(indFace1, :); 0077 normal2 = normals(indFace2, :); 0078 0079 % compute dihedral angle of two vectors 0080 alpha(iEdge) = vectorAngle3d(normal1, normal2); 0081 end 0082 0083 0084 %% Compute mean breadth 0085 % integrate the dihedral angles weighted by the length of each edge 0086 0087 % compute length of each edge 0088 lengths = meshEdgeLength(vertices, edges); 0089 0090 % compute product of length by angles 0091 mb = sum(alpha .* lengths) / (4*pi);