DRAWFACENORMALS Draw normal vector of each face in a mesh. drawFaceNormals(V, E, F) Compute and draw the face normals of the mesh defined by vertices V, edges E and faces F. See meshes3d for format of each argument. H = drawFaceNormals(...) Return handle array to the created objects. Example % draw face normals of a cube [v, f] = createCubeOctahedron; figure; drawMesh(v, f) axis([-2 2 -2 2 -2 2]); axis equal; hold on; drawFaceNormals(v, f) view(3); See also meshes3d, drawMesh, drawVector3d, meshFaceNormals, meshFaceCentroids
0001 function varargout = drawFaceNormals(varargin) 0002 %DRAWFACENORMALS Draw normal vector of each face in a mesh. 0003 % 0004 % drawFaceNormals(V, E, F) 0005 % Compute and draw the face normals of the mesh defined by vertices V, 0006 % edges E and faces F. See meshes3d for format of each argument. 0007 % 0008 % H = drawFaceNormals(...) 0009 % Return handle array to the created objects. 0010 % 0011 % Example 0012 % % draw face normals of a cube 0013 % [v, f] = createCubeOctahedron; 0014 % figure; drawMesh(v, f) 0015 % axis([-2 2 -2 2 -2 2]); axis equal; hold on; 0016 % drawFaceNormals(v, f) 0017 % view(3); 0018 % 0019 % See also 0020 % meshes3d, drawMesh, drawVector3d, meshFaceNormals, meshFaceCentroids 0021 % 0022 0023 % ------ 0024 % Author: David Legland 0025 % e-mail: david.legland@inra.fr 0026 % Created: 2010-10-06, using Matlab 7.9.0.529 (R2009b) 0027 % Copyright 2010 INRA - Cepia Software Platform. 0028 0029 % extract vertices and faces 0030 mesh = parseMeshData(varargin{:}); 0031 0032 % compute vector data 0033 c = meshFaceCentroids(mesh); 0034 n = meshFaceNormals(mesh); 0035 0036 % display an arrow for each normal 0037 h = quiver3(c(:,1), c(:,2), c(:,3), n(:,1), n(:,2), n(:,3)); 0038 0039 % format output 0040 if nargout > 0 0041 varargout{1} = h; 0042 end