Products & Services Solutions Academia Support User Community Company

Learn more about MATLAB   

surfnorm - Compute and display 3-D surface normals

Example of surfnorm function output

Syntax

surfnorm(Z)
surfnorm(X,Y,Z)
[Nx,Ny,Nz] = surfnorm(...)

Description

The surfnorm function computes surface normals for the surface defined by X, Y, and Z. The surface normals are unnormalized and valid at each vertex. Normals are not shown for surface elements that face away from the viewer. surfnorm does not accept complex inputs.

surfnorm(Z) and surfnorm(X,Y,Z) plot a surface and its surface normals. Z is a matrix that defines the z component of the surface. X and Y are vectors or matrices that define the x and y components of the surface. Reverse the direction of the normals by calling surfnorm with transposed arguments:

surfnorm(X',Y',Z')

[Nx,Ny,Nz] = surfnorm(...) returns the components of the three-dimensional surface normals for the surface.

surfl uses surfnorm to compute surface normals when calculating the reflectance of a surface.

Algorithm

The surface normals are based on a bicubic fit of the data in X, Y, and Z. For each vertex, diagonal vectors are computed and crossed to form the normal.

Examples

Plot the normal vectors for a truncated cone.

[x,y,z] = cylinder(1:10);
surfnorm(x,y,z)
axis([-12 12 -12 12 -0.1 1])

See Also

surf, quiver3

Color Operations for related functions

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS