Home > matGeom > meshes3d > createTetrahedron.m

createTetrahedron

PURPOSE ^

CREATETETRAHEDRON Create a 3D mesh representing a tetrahedron.

SYNOPSIS ^

function varargout = createTetrahedron()

DESCRIPTION ^

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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@inra.fr
0031 %   INRA - TPV URPOI - BIA IMASTE
0032 %   created the 21/03/2005.
0033 %
0034 
0035 %   HISTORY
0036 %   04/01/2007: remove unused variables
0037 
0038 x0 = 0; dx= 1;
0039 y0 = 0; dy= 1;
0040 z0 = 0; dz= 1;
0041 
0042 nodes = [...
0043     x0 y0 z0; ...
0044     x0+dx y0+dy z0; ...
0045     x0+dx y0 z0+dz; ...
0046     x0 y0+dy z0+dz];
0047 
0048 edges = [1 2;1 3;1 4;2 3;3 4;4 2];
0049 
0050 faces = [1 2 3;1 3 4;1 4 2;4 3 2];
0051 
0052 
0053 % format output
0054 varargout = formatMeshOutput(nargout, nodes, edges, faces);

Generated on Wed 16-Feb-2022 15:10:47 by m2html © 2003-2019