Compute and display 3-D surface normals
[Nx,Ny,Nz] = surfnorm(___)
surfnorm(Z) plots a surface of the matrix Z with surf and displays its surface normals as radiating vectors.
[Nx,Ny,Nz] = surfnorm(___) returns the components of the 3-D surface normals for the surface without plotting the surface or surface normals.
2–D array of real numbers representing a surface
2–D array of real numbers that defines the x component of the surface grid
2–D array of real numbers that defines the y component of the surface grid
Handle to the target axes in which to plot the surface
If you do not specify axes_handle, MATLAB® uses current axes.
Specify optional comma-separated pairs of Name,Value arguments, where Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.
Property names and values of the surface object
See Surface Properties for description of property names and values.
x, y, and z components of the three-dimensional surface normals for the surface
Compute and plot the normal vectors for a truncated cone. Set the axis limits using the axis function.
[x,y,z] = cylinder(1:10); figure surfnorm(x,y,z) axis([-12 12 -12 12 -0.1 1])
Compute the normal vectors of an expression representing a surface.
[nx, ny, nz] = surfnorm(peaks);
Assign these normals to the VertexNormals property which MATLAB® uses to calculate the surface lighting. Set the lighting algorithm to gouraud and add a light using camlight.
b = reshape([nx ny nz], 49,49,3); figure surf(ones(49),'VertexNormals',b,'EdgeColor','none'); lighting gouraud camlight
An imaginary line perpendicular to a flat surface or perpendicular to the tangent plane at a point on a non-flat surface
surfnorm does not accept complex inputs.
Reverse the direction of the normals by calling surfnorm with transposed arguments:
The surface normals represent conditions at vertices and are not normalized. Normals for surface elements that face away from the viewer do not display.
surfl uses surfnorm to compute surface normals when calculating the reflectance of a surface.
After performing a bicubic fit of the data in the x, y, and z directions, diagonal vectors are computed and crossed to form the normal at each vertex.