![matlab logo matlab logo](https://1.bp.blogspot.com/-nwsgA1WW1d4/XXg9z9S3i3I/AAAAAAAA6gA/NKjBQhzmgMIJg1h6lT6h-Eik-twGJ7hcACLcBGAsYHQ/s1600/unnamed.jpg)
This did not pose a problem in our original surface because the boundaries consisted of a square, which is its own convex hull. These arise from the 2D Delaunay triangulation, which connects vertices contained within the convex hull of the whole set of vertices by default.
![matlab logo matlab logo](https://i.pinimg.com/originals/56/50/25/56502503a4d062682cc2b36e9ccd7d1d.png)
Notice that there are some extra facets that we did not intend. underFaces = delaunay(underVertices(:,1),underVertices(:,2)) UnderVertices = vertices - shellThickness*meanNormal' we will call these new vertices ‘underVertices’. Now we merely need to copy and shift all of the vertices downward along their normals. MeanNormal(:,k) = mean(normals(:,sharedFaces),2) ġ. % Compute the mean normal of all faces shared by a vertex meanNormal = zeros(3,length(vertices)) % pre-allocate memory. We can compute the normal at each vertex by averaging the normals of its neighboring facets. We can calculate the normals of each facet by taking the cross-product of two edges of the facet, taking note of their orientation to ensure that the normals of the whole surface are consistent. So, we will need to know the normals for each facet. We will say that the normal at a vertex is the average of the normals to the facets that share this vertex. vertices = get(patches, 'vertices') įacets = reshape(facets(:,faces'), 3, 3, ) Let us begin by creating a 3-by-3-by-n tensor called ‘facets’ that will allow us to easily index through the 3 cartesian coordinates of the 3 vertices of the n triangles that make up our surface. Then connect the two surfaces along their boundaries to define a third surface. First, project all the vertices of the triangles downward along normal vectors to create a second surface with no thickness beneath the original.
![matlab logo matlab logo](https://keygenstore.com/wp-content/uploads/2019/12/matlab-logo-AE6C96A5DD-seeklogo.com_.png)
We can make a shell out of this surface as follows. Notice that this mesh has no thickness, so it cannot yet be used to make a solid 3D print. We can make use of the function DELAUNAY to create a Delaunay triangulation of the rectilinear mesh. The first step in translating a matrix-based plot into an STL-file is to break up each square element in the mesh into two triangular elements.
![matlab logo matlab logo](https://jp.mathworks.com/matlabcentral/answers/assets/msft_logo-84facabdbcb7364f69f530c60b586f1edbe02962ff036a942b561878d14dc851.png)
n = 12 % number of partitions in each dimension. Consider the surface plot of the MathWorks logo, based on the L-shaped membrane. The most natural way to create surface plots in MATLAB is to use a matrix of height values. It is worth noting that depending upon the type of printer being used, the orientation of the surface may factor into the quality of the print. Many 3D printers come with their own slicing program to perform this translation, so we will not address this stage. Vertex 7.9166667E-01 2.0833333E-01 8.6090207E-01īefore being useful for a 3D printer, a surface described by an STL-file must be sliced into layers defining the path traced out by the printer. Here is an excerpt from an ASCII STL-file: facet normal nx ny nz These files consist of a list of triangles, with each triangle described by the cartesian coordinates of its three vertices and a normal vector oriented outward from the closed surface. STL-files describe a closed surface in terms of triangular faces.