CREATETETRAHEDRON Create a 3D mesh representing a tetrahedron. [V, E, F] = createTetrahedron create a simple tetrahedron, using mesh representation. The tetrahedron is inscribed in the unit cube. V is a 4-by-3 array with vertex coordinates, E is a 6-by-2 array containing indices of neighbour vertices, F is a 4-by-3 array containing vertices array of each (triangular) face. [V, F] = createTetrahedron; Returns only the vertices and the faces. MESH = createTetrahedron; Returns the data as a mesh structure, with fields 'vertices', 'edges' and 'faces'. Example % Create and display a tetrahedron [V, E, F] = createTetrahedron; drawMesh(V, F); See also meshes3d, drawMesh createCube, createOctahedron, createDodecahedron, createIcosahedron
0001 function varargout = createTetrahedron() 0002 %CREATETETRAHEDRON Create a 3D mesh representing a tetrahedron. 0003 % 0004 % [V, E, F] = createTetrahedron 0005 % create a simple tetrahedron, using mesh representation. The tetrahedron 0006 % is inscribed in the unit cube. 0007 % V is a 4-by-3 array with vertex coordinates, 0008 % E is a 6-by-2 array containing indices of neighbour vertices, 0009 % F is a 4-by-3 array containing vertices array of each (triangular) face. 0010 % 0011 % [V, F] = createTetrahedron; 0012 % Returns only the vertices and the faces. 0013 % 0014 % MESH = createTetrahedron; 0015 % Returns the data as a mesh structure, with fields 'vertices', 'edges' 0016 % and 'faces'. 0017 % 0018 % 0019 % Example 0020 % % Create and display a tetrahedron 0021 % [V, E, F] = createTetrahedron; 0022 % drawMesh(V, F); 0023 % 0024 % See also 0025 % meshes3d, drawMesh 0026 % createCube, createOctahedron, createDodecahedron, createIcosahedron 0027 0028 % ------ 0029 % Author: David Legland 0030 % E-mail: david.legland@inrae.fr 0031 % Created: 2005-03-21 0032 % Copyright 2005-2024 INRA - TPV URPOI - BIA IMASTE 0033 0034 x0 = 0; dx= 1; 0035 y0 = 0; dy= 1; 0036 z0 = 0; dz= 1; 0037 0038 nodes = [... 0039 x0 y0 z0; ... 0040 x0+dx y0+dy z0; ... 0041 x0+dx y0 z0+dz; ... 0042 x0 y0+dy z0+dz]; 0043 0044 edges = [1 2;1 3;1 4;2 3;3 4;4 2]; 0045 0046 faces = [1 2 3;1 3 4;1 4 2;4 3 2]; 0047 0048 0049 % format output 0050 varargout = formatMeshOutput(nargout, nodes, edges, faces);