Reverse the normal of each face in the mesh. [V2, F2] = meshComplement(V, F) Example [v, f] = createOctahedron; meshVolume(v, f) ans = 1.3333 [v2, f2] = meshComplement(v, f); meshVolume(v2, f2) ans = -1.3333 See also meshes3d, meshVolume
0001 function varargout = meshComplement(varargin) 0002 % Reverse the normal of each face in the mesh. 0003 % 0004 % [V2, F2] = meshComplement(V, F) 0005 % 0006 % Example 0007 % [v, f] = createOctahedron; 0008 % meshVolume(v, f) 0009 % ans = 0010 % 1.3333 0011 % [v2, f2] = meshComplement(v, f); 0012 % meshVolume(v2, f2) 0013 % ans = 0014 % -1.3333 0015 % 0016 % See also 0017 % meshes3d, meshVolume 0018 0019 % ------ 0020 % Author: David Legland 0021 % e-mail: david.legland@inrae.fr 0022 % INRAE - BIA Research Unit - BIBS Platform (Nantes) 0023 % Created: 2020-01-22, using Matlab 9.7.0.1247435 (R2019b) Update 2 0024 % Copyright 2020 INRAE. 0025 0026 % extract mesh data 0027 mesh = parseMeshData(varargin{:}); 0028 faces = mesh.faces; 0029 0030 % iterate over faces to invert order of vertex indices 0031 if isnumeric(faces) 0032 for i = 1:size(faces, 1) 0033 faces(i,:) = faces(i, end:-1:1); 0034 end 0035 else 0036 for i = 1:size(faces, 1) 0037 faces{i} = faces{i}(end:-1:1); 0038 end 0039 end 0040 0041 % create new mesh data 0042 varargout = formatMeshOutput(nargout, mesh.vertices, faces);