The "function" method for plot3d simply passes
all arguments to persp3d. Thus this description applies
to both.The first argument x is required to be a function. It
is named x only because of the requirements of the S3
system; in the remainder of this help page, we will assume
that the assignment f <- x has been made, and will
refer to the function f().
persp3d.function evaluates f() on a two-dimensional
grid of values, and displays the resulting surface. The values
on the grid will be passed in as vectors in the
first two arguments to the function, so f() needs
to be vectorized. Other optional arguments to f()
can be specified in the otherargs list.
In the default form where slim and tlim are both
NULL, it is assumed that f(x,y) returns heights,
which will be plotted in the z coordinate.
If slim or tlim is specified, a parametric
surface is plotted. Values of s
f(s,t) must return a 3-column matrix, giving x, y and z
coordinates of points on the surface.
The colour of the surface may be specified as the name of a
colour, or a vector or matrix of colour names. In this case
the colours will be recycled across the points on the grid
of values.
Alternatively, a function may be given: it should be a function
like rainbow that takes an integer argument and
returns a vector of colours. In this case the colours are mapped
to z values.
The normal argument allows specification of a function
to compute normal vectors to the surface. This function is
passed the same arguments as f() (incuding otherargs
if present), and should produce a 3-column matrix containing the
x, y and z coordinates of the normals.
The texture argument is a function similar to normal, but
it produces a 2-column matrix containing texture coordinates.
Both normal and texture may also contain matrices,
with 3 and 2 columns respectively, and rows corresponding to the
points that were passed to f().