Skip to Main Content Skip to Search
Product Documentation

faceNormals - Class: TriRep

Unit normals to specified triangles

Syntax

FN = faceNormals(TR, TI)

Description

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

Input Arguments

TRTriangulation representation.
TIColumn vector of indices that index into the triangulation matrix TR.Triangulation.

Output Arguments

FN

m-by-3 matrix. m = length(TI), the number of triangles to be queried. Each row FN(i,:) represents the unit normal vector to triangle TI(i).

If TI is not specified the unit normal information for the entire triangulation is returned, where the normal associated with triangle i is the i'th row of FN.

Examples

Triangulate a sample of random points on the surface of a sphere and use the TriRep to compute the normal to each triangle:

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);
P = incenters(tr);
fn = faceNormals(tr);
trisurf(tri,Xb(:,1),Xb(:,2),Xb(:,3), ...
     'FaceColor', 'cyan', 'faceAlpha', 0.8);
axis equal;
hold on;

Display the result using a quiver plot:

quiver3(P(:,1),P(:,2),P(:,3), ...
     fn(:,1),fn(:,2),fn(:,3),0.5, 'color','r');
hold off;

See Also

DelaunayTri | TriRep.freeBoundary

  


Free MATLAB Interactive Kit

Explore how to use MATLAB to make advancements in engineering and science.


Download free kit

Trials Available

Try the latest version of MATLAB and other MathWorks products.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS