faceNormal
Unit normal vector of each triangle of a triangulated surface.
Category: Mathematics > Computational Geometry
Syntax
N = faceNormal(TR)
Normals for all triangles.
N = faceNormal(TR, T)
Normals only for the triangles with indices in T.
Description
The normal of a triangle is perpendicular to its plane. Its direction follows the right-hand rule on the vertex order in the connectivity list: curling the fingers from the first vertex to the second to the third, the thumb points along the normal. A planar 2-D mesh with counterclockwise triangles therefore has all normals equal to [0 0 1].
Reversing the vertex order of a triangle flips its normal.
Input arguments
TR- A
triangulationof triangles in 2-D or 3-D space. T- Optional column vector of triangle indices.
Output arguments
N- Matrix with one unit vector per triangle, three columns.
Example
Normals of a tetrahedron's faces
P = [0 0 0; 1 0 0; 0 1 0; 0 0 1];
T = [1 3 2; 1 2 4; 1 4 3; 2 3 4];
tr = triangulation(T, P);
N = faceNormal(tr)
Output
N = 4×3
0 0 -1.0000
0 -1.0000 0
-1.0000 0 0
0.5774 0.5774 0.5774