Navigation

Operators and Keywords

Function List:

C++ API

: surfl (z)
: surfl (x, y, z)
: surfl (…, lsrc)
: surfl (x, y, z, lsrc, P)
: surfl (…, "cdata")
: surfl (…, "light")
: surfl (hax, …)
: h = surfl (…)

Plot a 3-D surface using shading based on various lighting models.

The surface mesh is plotted using shaded rectangles. The vertices of the rectangles [x, y] are typically the output of meshgrid. over a 2-D rectangular region in the x-y plane. z determines the height above the plane of each vertex. If only a single z matrix is given, then it is plotted over the meshgrid x = 1:columns (z), y = 1:rows (z). Thus, columns of z correspond to different x values and rows of z correspond to different y values.

The default lighting mode "cdata", changes the cdata property of the surface object to give the impression of a lighted surface. Warning: The alternative mode "light" mode which creates a light object to illuminate the surface is not implemented (yet).

The light source location can be specified using lsrc. It can be given as a 2-element vector [azimuth, elevation] in degrees, or as a 3-element vector [lx, ly, lz]. The default value is rotated 45 degrees counterclockwise to the current view.

The material properties of the surface can specified using a 4-element vector P = [AM D SP exp] which defaults to p = [0.55 0.6 0.4 10].

"AM" strength of ambient light
"D" strength of diffuse reflection
"SP" strength of specular reflection
"EXP" specular exponent

If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.

The optional return value h is a graphics handle to the created surface object.

Example:

colormap (bone (64));
surfl (peaks);
shading interp;

See also: diffuse, specular, surf, shading, colormap, caxis.

Demonstration 1

The following code

 clf;
 [X,Y,Z] = sombrero ();
 colormap (copper (64));
 surfl (X,Y,Z);
 shading interp;
 title ("surfl() with defaults");

Produces the following figure

Figure 1

Demonstration 2

The following code

 clf;
 [X,Y,Z] = sombrero ();
 colormap (copper (64));
 surfl (X,Y,Z, [62.50,30], [0.2 0.6 0.4 25]);
 shading interp;
 title ("surfl() with lighting vector and material properties");

Produces the following figure

Figure 1

Package: octave