layer3D.surface {ivue}R Documentation

An Independently Positioned Gridded Surface

Description

Add a reference surface with its own coordinates to any plot3D scene. Unlike layer3D.mesh(), the surface does not use the plotted observations as its vertices and stays fixed when reused with another configuration.

Usage

layer3D.surface(
  x,
  y,
  z,
  col = "gray75",
  alpha = 0.2,
  edges = FALSE,
  edge.col = "gray45",
  edge.alpha = 0.35,
  edge.width = 1,
  lit = FALSE
)

Arguments

x, y

Finite numeric coordinate vectors, each of length at least two, strictly increasing or strictly decreasing.

z

Finite numeric matrix with length(x) rows and length(y) columns. Entry z[i, j] is the height at ⁠(x[i], y[j])⁠; use outer(x, y, fun) to evaluate a height function on the grid. Missing values are not supported.

col

Face color, length one or one per grid cell. Cell order has the x index varying fastest, then the y index. Both triangles in a cell have the same color; colors do not inherit the plot's point color scale.

alpha

Face opacity multiplier, length one or one per grid cell, in ⁠[0, 1]⁠. Multiplies any opacity in col. Zero hides the faces.

edges

Draw grid lines, without the triangulation diagonals.

edge.col

Single grid-line color.

edge.alpha

Grid-line opacity multiplier in ⁠[0, 1]⁠.

edge.width

Positive grid-line width in screen units.

lit

Apply lighting to faces. FALSE keeps colors independent of orientation; TRUE helps reveal surface shape. Both sides are drawn.

Details

Each rectangular parameter cell is split along the diagonal from (i, j) to (i+1, j+1). The result is a piecewise-planar approximation, not an exact smooth surface. A finer grid improves the approximation. The surface contributes to the scene bounds, but automatic layer3D.axes limits are based on the plotted observations; supply explicit axis limits if needed. No alignment or rescaling of either set of coordinates is done. Align an embedding to the reference coordinates before interpreting their spatial agreement. Transparent intersecting surfaces can have rendering order artifacts. Construction requires neither rgl nor geometry; rendering uses rgl on the plot's private device.

Value

An ivue_layer specification for the layers argument.

See Also

layer3D.mesh(), layer3D.axes(), plot3D.cont()

Examples

x <- y <- seq(-1, 1, length.out = 31)
z <- outer(x, y, function(x, y) 0.8 * (x^2 - y^2))
reference <- layer3D.surface(x, y, z, col = "lightblue", alpha = 0.3)
if (nzchar(system.file(package = "rgl"))) {
  X <- rbind(c(-0.5, 0, 0.2), c(0, 0.5, -0.2), c(0.5, 0.5, 0))
  w <- plot3D.plain(X, point.type = "sphere", sphere.radius = 0.03,
      layers = list(reference, layer3D.axes()), camera = camera.zup())
}

[Package ivue version 0.1.0 Index]