Learn R Programming

vectools (version 0.3.0)

18_rectangular_grids: Regularly-Spaced Grids

Description

Regularly-spaced or semi-regularly-spaced grids.

These functions take two vectors and a matrix. For more general "grids", you can use the Grid and VImage functions, which take three matrices.

NOTE: INTERNAL STRUCTURE OF OBJECTS IS SUBJECT TO CHANGE. DO NOT USE SLOTS, DIRECTLY.

Usage

rectGrid (x, y, gv=NULL, …, glist = list (),
    vlist=NULL)
rectVImage (x, y, gv=NULL, …, tf=FALSE,
    colm, glist = list () )

Arguments

x, y

Equal length (ascending or descending) numeric vectors, giving the grid points, in x and y directions.

gv

A numeric matrix, giving the "z" value at each "x" and "y" pair. If null, a 2D grid is greated. Can also be a scalar value, but this is mainly for testing and demo purposes.

glist, vlist

Argument lists of graphical parameters using in the plotting functions. glist applies to all polygons, in vlist the elements should be matrices, where each value is applied to separate polygons.

tf

Logical, transpose and flip gv, for rendering raster-style images, using the standard coordinate system.

colm

A character matrix, of colors.

Ignored.

Value

A Grid or VImage object.

Details

Note that vlist and colm arguments should have dimensions one less than the nrow/ncol of gv.

See Also

Grid, VImage

as.Grid Which can be used on FGrid-class objects.

Examples

Run this code
# NOT RUN {
library (png)

#adapted from png package
im0 <- readPNG (system.file ("img", "Rlogo.png", package="png") )

#standard raster object
colm <- as.raster (im0)
headt (colm)

#smaller version
I <- seq (1, nrow (colm), 5)
J <- seq (1, ncol (colm), 5)
colm <- colm [I, J]
headt (colm)

#VImage
x <- seq (-1, 1,, ncol (colm) + 1)
y <- seq (-1, 1,, nrow (colm) + 1)
v <- rectVImage (x, y, 0, tf=TRUE, colm=colm)

if (interactive () )
    spin3d (v %]*% brot3x (pi / 4), t=10)
# }

Run the code above in your browser using DataLab