Main Content

faceNormals

(Not recommended) Unit normals to specified triangles

faceNormals(TriRep) is not recommended. Use faceNormal(triangulation) instead.

TriRep is not recommended. Use triangulation instead.

Description

example

FN = faceNormals(TR) returns the unit normal vector to each triangle in the triangulation. The normal associated with triangle i is the i'th row of FN.

Note

This query is only applicable to triangular surface meshes.

FN = faceNormals(TR,TI) returns the unit normal vector to each of the specified triangles TI.

Examples

collapse all

Triangulate a sample of random points on the surface of a sphere.

numpts = 100;
thetha = rand(numpts,1)*2*pi;
phi = rand(numpts,1)*pi;
x = cos(thetha).*sin(phi);
y = sin(thetha).*sin(phi);
z = cos(phi);
dt = DelaunayTri(x,y,z);
[tri,Xb] = freeBoundary(dt);
tr = TriRep(tri,Xb);

Use the TriRep object to compute the normal vectors for each triangle.

fn = faceNormals(tr);

Display the results by plotting the triangulation with an overlaid quiver plot of the normal vectors. Use incenters to place the vectors at the center of each triangle.

P = incenters(tr);
trisurf(tri,Xb(:,1),Xb(:,2),Xb(:,3), ...
     'FaceColor','cyan','faceAlpha',0.8)
axis equal
hold on
quiver3(P(:,1),P(:,2),P(:,3), ...
     fn(:,1),fn(:,2),fn(:,3),0.5,'color','r')
hold off

Input Arguments

collapse all

Triangulation representation, specified as a TriRep or DelaunayTri object.

Triangle indices, specified as a column vector. TI contains indices into the triangulation matrix TR.Triangulation.

Output Arguments

collapse all

Face normal vectors, returned as a matrix. FN is an m-by-3 matrix, where m = length(TI), the number of triangles to be queried. Each row FN(i,:) represents the unit normal vector to triangle TI(i).

Version History

Introduced in R2009a