MESHDIHEDRALANGLES Dihedral at edges of a polyhedal mesh. ALPHA = meshDihedralAngles(V, E, F) where V, E and F represent vertices, edges and faces of a mesh, computes the dihedral angle between the two adjacent faces of each edge in the mesh. ALPHA is a column array with as many rows as the number of edges. The i-th element of ALPHA corresponds to the i-th edge. Note: the function assumes that the faces are correctly oriented. The face vertices should be indexed counter-clockwise when considering the supporting plane of the face, with the outer normal oriented outwards of the mesh. Example [v, e, f] = createCube; rad2deg(meshDihedralAngles(v, e, f)) ans = 90 90 90 90 90 90 90 90 90 90 90 90 See also meshes3d, polyhedronMeanBreadth, trimeshMeanBreadth, dihedralAngle, meshEdgeFaces
0001 function alpha = meshDihedralAngles(vertices, edges, faces) 0002 %MESHDIHEDRALANGLES Dihedral at edges of a polyhedal mesh. 0003 % 0004 % ALPHA = meshDihedralAngles(V, E, F) 0005 % where V, E and F represent vertices, edges and faces of a mesh, 0006 % computes the dihedral angle between the two adjacent faces of each edge 0007 % in the mesh. ALPHA is a column array with as many rows as the number of 0008 % edges. The i-th element of ALPHA corresponds to the i-th edge. 0009 % 0010 % Note: the function assumes that the faces are correctly oriented. The 0011 % face vertices should be indexed counter-clockwise when considering the 0012 % supporting plane of the face, with the outer normal oriented outwards 0013 % of the mesh. 0014 % 0015 % Example 0016 % [v, e, f] = createCube; 0017 % rad2deg(meshDihedralAngles(v, e, f)) 0018 % ans = 0019 % 90 0020 % 90 0021 % 90 0022 % 90 0023 % 90 0024 % 90 0025 % 90 0026 % 90 0027 % 90 0028 % 90 0029 % 90 0030 % 90 0031 % 0032 % See also 0033 % meshes3d, polyhedronMeanBreadth, trimeshMeanBreadth, dihedralAngle, meshEdgeFaces 0034 % 0035 0036 % ------ 0037 % Author: David Legland 0038 % E-mail: david.legland@inrae.fr 0039 % Created: 2010-10-04, using Matlab 7.9.0.529 (R2009b) 0040 % Copyright 2010-2024 INRA - Cepia Software Platform 0041 0042 % compute normal of each face 0043 normals = meshFaceNormals(vertices, faces); 0044 0045 % indices of faces adjacent to each edge 0046 edgeFaces = meshEdgeFaces(vertices, edges, faces); 0047 0048 % allocate memory for resulting angles 0049 Ne = size(edges, 1); 0050 alpha = zeros(Ne, 1); 0051 0052 % iterate over edges 0053 for i = 1:Ne 0054 % indices of adjacent faces 0055 indFace1 = edgeFaces(i, 1); 0056 indFace2 = edgeFaces(i, 2); 0057 0058 % normal vector of adjacent faces 0059 normal1 = normals(indFace1, :); 0060 normal2 = normals(indFace2, :); 0061 0062 % compute dihedral angle of two vectors 0063 alpha(i) = vectorAngle3d(normal1, normal2); 0064 end 0065