File: mesh.Rd

package info (click to toggle)
r-cran-plot3d 1.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,588 kB
  • sloc: makefile: 2
file content (66 lines) | stat: -rw-r--r-- 1,570 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
\name{Mesh generation}
\alias{mesh}
\title{
  Rectangular grids. 
}
\description{
  \code{mesh} creates a rectangular full 2-D or 3-D grid.
}
\usage{
mesh (x, y, z = NULL) 
}

\arguments{
  \item{x, y, z }{Vectors with x, y and z-values. 
    They can be of arbitrary length.
    }
}

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

\seealso{
  \link{persp3D}, \link{arrows3D}, \link{slice3D}, \link{surf3D}
   for other examples that use \code{mesh}.
}
\author{Karline Soetaert <karline.soetaert@nioz.nl>}

\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)
}
\keyword{ hplot }