CREATECUBEOCTAHEDRON Create a 3D mesh representing a cube-octahedron. [V, E, F] = createCubeOctahedron; Cubeoctahedron can be seen either as a truncated cube, or as a truncated octahedron. V is the 12-by-3 array of vertex coordinates E is the 27-by-2 array of edge vertex indices F is the 1-by-14 cell array of face vertex indices [V, F] = createCubeOctahedron; Returns only the vertices and the face vertex indices. MESH = createCubeOctahedron; Returns the data as a mesh structure, with fields 'vertices', 'edges' and 'faces'. Example [n, e, f] = createCubeOctahedron; drawMesh(n, f); See also meshes3d, drawMesh, createCube, createOctahedron
0001 function varargout = createCubeOctahedron() 0002 %CREATECUBEOCTAHEDRON Create a 3D mesh representing a cube-octahedron. 0003 % 0004 % [V, E, F] = createCubeOctahedron; 0005 % Cubeoctahedron can be seen either as a truncated cube, or as a 0006 % truncated octahedron. 0007 % V is the 12-by-3 array of vertex coordinates 0008 % E is the 27-by-2 array of edge vertex indices 0009 % F is the 1-by-14 cell array of face vertex indices 0010 % 0011 % [V, F] = createCubeOctahedron; 0012 % Returns only the vertices and the face vertex indices. 0013 % 0014 % MESH = createCubeOctahedron; 0015 % Returns the data as a mesh structure, with fields 'vertices', 'edges' 0016 % and 'faces'. 0017 % 0018 % Example 0019 % [n, e, f] = createCubeOctahedron; 0020 % drawMesh(n, f); 0021 % 0022 % See also 0023 % meshes3d, drawMesh, createCube, createOctahedron 0024 % 0025 0026 % --------- 0027 % author : David Legland 0028 % e-mail: david.legland@inra.fr 0029 % INRA - TPV URPOI - BIA IMASTE 0030 % created the 10/02/2005. 0031 % 0032 0033 % HISTORY 0034 % 04/01/2007: remove unused variables 0035 0036 nodes = [... 0037 0 -1 1;1 0 1;0 1 1;-1 0 1; ... 0038 1 -1 0;1 1 0;-1 1 0;-1 -1 0;... 0039 0 -1 -1;1 0 -1;0 1 -1;-1 0 -1]; 0040 0041 edges = [... 0042 1 2; 1 4; 1 5; 1 8; ... 0043 2 3; 2 5; 2 6; ... 0044 3 4; 3 6; 3 7; ... 0045 4 7; 4 8; ... 0046 5 9; 5 10; ... 0047 6 10; 6 11; ... 0048 7 11; 7 12; ... 0049 8 9; 8 12; ... 0050 9 10; 9 12; ... 0051 10 11; 11 12]; 0052 0053 faces = {... 0054 [1 2 3 4], [1 5 2], [2 6 3], [3 7 4], [4 8 1], ... 0055 [5 10 6 2], [3 6 11 7], [4 7 12 8], [1 8 9 5], ... 0056 [5 9 10], [6 10 11], [7 11 12], [8 12 9], [9 12 11 10]}; 0057 0058 % format output 0059 varargout = formatMeshOutput(nargout, nodes, edges, faces); 0060