rgl.surface {rgl} | R Documentation |
Adds a surface to the current scene. The surface is defined by a matrix defining the height of each grid point and two vectors defining the grid.
rgl.surface(x, z, y, coords=1:3, ...)
x |
values corresponding to rows of y
|
y |
matrix of height values |
z |
values corresponding to columns of y
|
coords |
See details |
... |
Material and texture properties. See rgl.material for details. |
Adds a surface mesh to the current scene. The surface is defined by
the matrix of height values in y
, with rows corresponding
to the values in x
and columns corresponding to the values in
z
.
The coords
parameter can be used to change the geometric
interpretation of x
, y
, and z
. The first entry
of coords
indicates which coordinate (1=X
,
2=Y
, 3=Z
) corresponds to the x
parameter.
Similarly the second entry corresponds to the y
parameter,
and the third entry to the z
parameter. In this way
surfaces may be defined over any coordinate plane.
rgl.surface
always draws the surface with the `front' upwards
(i.e. towards higher y
values). This can be used to render
the top and bottom differently; see rgl.material
and
the example below.
rgl.material
, surface3d
, terrain3d
# # volcano example taken from "persp" # data(volcano) y <- 2 * volcano # Exaggerate the relief x <- 10 * (1:nrow(y)) # 10 meter spacing (S to N) z <- 10 * (1:ncol(y)) # 10 meter spacing (E to W) ylim <- range(y) ylen <- ylim[2] - ylim[1] + 1 colorlut <- terrain.colors(ylen) # height color lookup table col <- colorlut[ y-ylim[1]+1 ] # assign colors to heights for each point rgl.clear() rgl.surface(x, z, y, color=col, back="lines")