CREATEOCTAHEDRON Create a 3D mesh representing an octahedron. [V, E, F] = createOctahedron; Create a 3D mesh representing an octahedron V is a 6-by-3 array with vertices coordinate, E is a 12-by-2 array containing indices of neighbour vertices, and F is a 8-by-3 array containing array of vertex index for each face. [V, F] = createOctahedron; Returns only the vertices and the face vertex indices. MESH = createOctahedron; Returns the data as a mesh structure, with fields 'vertices', 'edges' and 'faces'. Vertices are located on grid vertices: ( ±1, 0, 0 ) ( 0, ±1, 0 ) ( 0, 0, ±1 ) Edge length of returned octahedron is sqrt(2). Surface area of octahedron is 2*sqrt(3)*a^2, approximately 6.9282 in this case. Volume of octahedron is sqrt(2)/3*a^3, approximately 1.3333 in this case. Example [v, e, f] = createOctahedron; drawMesh(v, f); See also meshes3d, drawMesh createCube, createIcosahedron, createDodecahedron, createTetrahedron createCubeOctahedron
0001 function varargout = createOctahedron() 0002 %CREATEOCTAHEDRON Create a 3D mesh representing an octahedron. 0003 % 0004 % [V, E, F] = createOctahedron; 0005 % Create a 3D mesh representing an octahedron 0006 % V is a 6-by-3 array with vertices coordinate, E is a 12-by-2 array 0007 % containing indices of neighbour vertices, and F is a 8-by-3 array 0008 % containing array of vertex index for each face. 0009 % 0010 % [V, F] = createOctahedron; 0011 % Returns only the vertices and the face vertex indices. 0012 % 0013 % MESH = createOctahedron; 0014 % Returns the data as a mesh structure, with fields 'vertices', 'edges' 0015 % and 'faces'. 0016 % 0017 % Vertices are located on grid vertices: 0018 % ( ±1, 0, 0 ) 0019 % ( 0, ±1, 0 ) 0020 % ( 0, 0, ±1 ) 0021 % 0022 % Edge length of returned octahedron is sqrt(2). 0023 % Surface area of octahedron is 2*sqrt(3)*a^2, approximately 6.9282 in 0024 % this case. 0025 % Volume of octahedron is sqrt(2)/3*a^3, approximately 1.3333 in this 0026 % case. 0027 % 0028 % Example 0029 % [v, e, f] = createOctahedron; 0030 % drawMesh(v, f); 0031 % 0032 % See also 0033 % meshes3d, drawMesh 0034 % createCube, createIcosahedron, createDodecahedron, createTetrahedron 0035 % createCubeOctahedron 0036 % 0037 0038 % --------- 0039 % author : David Legland 0040 % e-mail: david.legland@inra.fr 0041 % INRA - TPV URPOI - BIA IMASTE 0042 % created the 10/02/2005. 0043 % 0044 0045 % HISTORY 0046 % 04/01/2007: remove unused variables 0047 0048 nodes = [1 0 0;0 1 0;-1 0 0;0 -1 0;0 0 1;0 0 -1]; 0049 0050 edges = [1 2;1 4;1 5; 1 6;2 3;2 5;2 6;3 4;3 5;3 6;4 5;4 6]; 0051 0052 faces = [1 2 5;2 3 5;3 4 5;4 1 5;1 6 2;2 6 3;3 6 4;1 4 6]; 0053 0054 % format output 0055 varargout = formatMeshOutput(nargout, nodes, edges, faces);