TRANSFORMMESH Applies a 3D affine transform to a mesh. MESH2 = transformMesh(MESH1, TRANSFO) MESH2 = transformMesh(VERTICES, FACES, TRANSFO) [V2, F2] = transformMesh(...) Example mesh1 = createOctahedron; transfo = eulerAnglesToRotation3d([30 20 10]); mesh2 = transformMesh(mesh1, transfo); figure; axis equal; hold on; drawMesh(mesh2, 'faceColor', 'g'); view(3); See also meshes3d, transformPoint3d, drawMesh
0001 function varargout = transformMesh(varargin) 0002 %TRANSFORMMESH Applies a 3D affine transform to a mesh. 0003 % 0004 % MESH2 = transformMesh(MESH1, TRANSFO) 0005 % MESH2 = transformMesh(VERTICES, FACES, TRANSFO) 0006 % [V2, F2] = transformMesh(...) 0007 % 0008 % Example 0009 % mesh1 = createOctahedron; 0010 % transfo = eulerAnglesToRotation3d([30 20 10]); 0011 % mesh2 = transformMesh(mesh1, transfo); 0012 % figure; axis equal; hold on; drawMesh(mesh2, 'faceColor', 'g'); view(3); 0013 % 0014 % See also 0015 % meshes3d, transformPoint3d, drawMesh 0016 % 0017 0018 % ------ 0019 % Author: David Legland 0020 % e-mail: david.legland@inra.fr 0021 % Created: 2019-08-08, using Matlab 9.6.0.1072779 (R2019a) 0022 % Copyright 2019 INRA - Cepia Software Platform. 0023 0024 % parses input arguments 0025 [vertices, edges, faces] = parseMeshData(varargin{1:end-1}); 0026 transfo = varargin{end}; 0027 0028 vertices2 = transformPoint3d(vertices, transfo); 0029 0030 % format output 0031 varargout = formatMeshOutput(nargout, vertices2, edges, faces);