periodify(X, ...)
"periodify"(X, nx = 1, ny = 1, ..., combine=TRUE, warn=TRUE, check=TRUE, ix=(-nx):nx, iy=(-ny):ny, ixy=expand.grid(ix=ix,iy=iy))
"periodify"(X, nx = 1, ny = 1, ..., combine=TRUE, warn=TRUE, check=TRUE, ix=(-nx):nx, iy=(-ny):ny, ixy=expand.grid(ix=ix,iy=iy))
"periodify"(X, nx = 1, ny = 1, ..., combine=TRUE, warn=TRUE, ix=(-nx):nx, iy=(-ny):ny, ixy=expand.grid(ix=ix,iy=iy))
X
in each direction.
The result will be a grid of 2 * nx + 1
by 2 * ny + 1
copies of the original object.
(Overruled by ix, iy, ixy
).
X
(if combine=TRUE
) or
simply returned as a list of objects (combine=FALSE
).
X
. (Overruled by ixy
).
X
.
combine=TRUE
, an object of the same class as X
.
If combine=FALSE
, a list of objects of the same class as X
.
periodify
is
generic, with methods for various kinds of spatial objects. The default is to make a 3 by 3 array of copies of X
and
combine them into a single pattern of the same kind as X
.
This can be used (for example) to compute toroidal or periodic
edge corrections for various operations on X
.
If the arguments nx
, ny
are given
and other arguments are missing,
the original object will be copied nx
times to the right
and nx
times to the left, then ny
times upward and
ny
times downward, making (2 * nx + 1) * (2 * ny + 1)
copies altogether, arranged in a grid, centred on the original object.
If the arguments ix
, iy
or ixy
are specified,
then these determine the grid positions of the copies of X
that will be made. For example (ix,iy) = (1, 2)
means a
copy of X
shifted by the vector (ix * w, iy * h)
where
w,h
are the width and height of the bounding rectangle of X
.
If combine=TRUE
(the default) the copies of X
are
superimposed to create an object of the same kind as X
.
If combine=FALSE
the copies of X
are returned as a list.
shift
data(cells)
plot(periodify(cells))
a <- lapply(periodify(Window(cells), combine=FALSE),
plot, add=TRUE,lty=2)
Run the code above in your browser using DataLab