vertexNormal

Unit normal vector at the vertices of a triangulated surface.

Category: Mathematics > Computational Geometry

Syntax

N = vertexNormal(TR, vi)

Returns the normal at each vertex listed in vi.

N = vertexNormal(TR)

Returns the normals at all vertices.

Description

The normal at a vertex is an average of the normals of the triangles attached to it, which gives a smooth direction for shading or for offsetting the surface. The orientation follows the vertex order of each triangle (right-hand rule).

Input arguments

TR
A triangulation of a surface in 3-D (triangles with 3-D points).
vi
Vertex indices. Optional.

Output arguments

N
Matrix with one unit vector per row.

Example

Normal of a tilted triangle

P = [0 0 0; 1 0 0; 0 1 1];
TR = triangulation([1 2 3], P);
N = vertexNormal(TR, 1)
Output
N = 1×3

         0   -0.7071    0.7071

See also

triangulation vertexAttachments trisurf cross