VN = vertexNormal(TR,vi)
VN = vertexNormal(TR)
IDs of vertices to query, specified as a column vector. Each element in vi is a Vertex ID.
Vertex normals, returned a matrix. Each row, VN(j,:), is the unit normal vector at the vertex vi(j). The vector at VN(j,:) is the average unit normal of the faces attached to vertex vi(j).
If you do not specify vi, then vertexNormal returns the unit normal information for all vertices in the triangulation. In this case, the normal associated with TR.Points(j,:) is VN(j,:).
A row number of the matrix, TR.Points. Use this ID to refer a specific vertex in the triangulation.
Create a 3-D triangulation representing the volume of a cube.
[X,Y,Z] = meshgrid(1:4); X = X(:); Y = Y(:); Z = Z(:); dt = delaunayTriangulation(X,Y,Z);
Find the surfaces of the cube and isolate them in a 2-D triangulation.
[Tfb,Xfb] = freeBoundary(dt); TR = triangulation(Tfb,Xfb);
Find the unit normal vectors to the triangles on the surface of the cube.
vn = vertexNormal(TR);
Plot the results.
trisurf(TR,'FaceColor', [0.8 0.8 1.0]); axis equal hold on quiver3(Xfb(:,1),Xfb(:,2),Xfb(:,3),... vn(:,1),vn(:,2),vn(:,3),0.5,'color','b'); hold off