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@inra.fr 0027 % Created: 2015-08-19, using Matlab 8.5.0.197613 (R2015a) 0028 % Copyright 2015 INRA - Cepia Software Platform. 0029 0030 0031 %% Check input validity 0032 0033 if size(faces, 2) ~= 3 0034 error('meshes3d:trimeshMeanBreadth:NonTriangularMesh', ... 0035 'Requires a triangular mesh as input'); 0036 end 0037 0038 %% Compute edge and edgeFaces arrays 0039 % Uses the same code as in trimeshEdgeFaces 0040 0041 % compute vertex indices of each edge (in increasing index order) 0042 edges = sort([faces(:,[1 2]) ; faces(:,[2 3]) ; faces(:,[3 1])], 2); 0043 0044 % create an array to keep indices of faces "creating" each edge 0045 nFaces = size(faces, 1); 0046 edgeFaceInds = repmat( (1:nFaces)', 3, 1); 0047 0048 % sort edges, keeping indices 0049 [edges, ia, ib] = unique(edges, 'rows'); %#ok<ASGLU> 0050 nEdges = size(edges, 1); 0051 0052 % allocate memory for result 0053 edgeFaces = zeros(nEdges, 2); 0054 0055 % iterate over edges, to identify incident faces 0056 for iEdge = 1:nEdges 0057 inds = find(ib == iEdge); 0058 edgeFaces(iEdge, 1:length(inds)) = edgeFaceInds(inds); 0059 end 0060 0061 0062 %% Compute dihedral angle for each edge 0063 0064 % compute normal of each face 0065 normals = meshFaceNormals(vertices, faces); 0066 0067 % allocate memory for resulting angles 0068 alpha = zeros(nEdges, 1); 0069 0070 % iterate over edges 0071 for iEdge = 1:nEdges 0072 % indices of adjacent faces 0073 indFace1 = edgeFaces(iEdge, 1); 0074 indFace2 = edgeFaces(iEdge, 2); 0075 0076 % normal vector of adjacent faces 0077 normal1 = normals(indFace1, :); 0078 normal2 = normals(indFace2, :); 0079 0080 % compute dihedral angle of two vectors 0081 alpha(iEdge) = vectorAngle3d(normal1, normal2); 0082 end 0083 0084 0085 %% Compute mean breadth 0086 % integrate the dihedral angles weighted by the length of each edge 0087 0088 % compute length of each edge 0089 lengths = meshEdgeLength(vertices, edges); 0090 0091 % compute product of length by angles 0092 mb = sum(alpha .* lengths) / (4*pi);