snorm=surfacenorm(node,face) or snorm=surfacenorm(node,face,'Normalize',0) compute the normal vectors for a triangular surface author: Qianqian Fang, <q.fang at neu.edu> input: node: a list of node coordinates (nn x 3) face: a surface mesh triangle list (ne x 3) opt: a list of optional parameters, currently surfacenorm supports: 'Normalize': [1|0] if set to 1, the normal vectors will be unitary (default) output: snorm: output surface normal vector at each face -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
0001 function snorm=surfacenorm(node,face,varargin) 0002 % 0003 % snorm=surfacenorm(node,face) 0004 % or 0005 % snorm=surfacenorm(node,face,'Normalize',0) 0006 % 0007 % compute the normal vectors for a triangular surface 0008 % 0009 % author: Qianqian Fang, <q.fang at neu.edu> 0010 % 0011 % input: 0012 % node: a list of node coordinates (nn x 3) 0013 % face: a surface mesh triangle list (ne x 3) 0014 % opt: a list of optional parameters, currently surfacenorm supports: 0015 % 'Normalize': [1|0] if set to 1, the normal vectors will be 0016 % unitary (default) 0017 % 0018 % output: 0019 % snorm: output surface normal vector at each face 0020 % 0021 % -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net) 0022 % 0023 0024 opt=varargin2struct(varargin{:}); 0025 0026 snorm=surfplane(node,face); 0027 snorm=snorm(:,1:3); 0028 0029 if(getoptkey('Normalize',1,opt)) 0030 snorm=snorm./repmat(sqrt(sum(snorm.*snorm,2)),1,3); 0031 end