mesh: Rectangular grids.

View source: R/mesh.R

Mesh generationR Documentation

Rectangular grids.

Description

mesh creates a rectangular full 2-D or 3-D grid.

Usage

mesh (x, y, z = NULL) 

Arguments

x, y, z

Vectors with x, y and z-values. They can be of arbitrary length.

Value

Function mesh returns a list with the expanded x- y- and z arrays (in case z is not NULL) or matrices (in case z = NULL). The dimensions of these list elements are the same and equal to c(length(x), length(y), length(z)).

Author(s)

Karline Soetaert <karline.soetaert@nioz.nl>

See Also

persp3D, arrows3D, slice3D, surf3D for other examples that use mesh.

Examples


## ========================================================================
## 2-D mesh
## ========================================================================

 x <- c(-1 , 0, 1)
 y <- 1 : 4

# 2-D mesh
 (M <- mesh(x, y))

# calculate with this mesh
 V <- with (M, x/2 * sin(y))

# same as:
 V2 <- outer(x, y, FUN = function(x, y) x/2*sin(y))

## ========================================================================
## 3-D mesh
## ========================================================================

 x <- y <- z <- c(-1 , 0, 1)

# 3-D mesh
 (M <- mesh(x, y, z))

# calculate with 3-D mesh
 V <- with (M, x/2 * sin(y) *sqrt(z+2))
  
# plot result
 scatter3D(M$x, M$y, M$z, V, pch = "+", cex = 3, colkey = FALSE)

plot3D documentation built on May 29, 2024, 5:46 a.m.

Related to mesh in plot3D...