gridcentres | R Documentation |
Generates a rectangular grid of points in a window
gridcentres(window, nx, ny)
window |
A window.
An object of class |
nx |
Number of points in each row of the rectangular grid. |
ny |
Number of points in each column of the rectangular grid. |
This function creates a rectangular grid of points in the window.
The bounding rectangle of the window
is divided into
a regular nx \times ny
grid of rectangular tiles.
The function returns the x,y
coordinates of the
centres of these tiles.
Note that some of these grid points may lie outside the window,
if window
is not of type "rectangle"
. The function
inside.owin
can be used to select those grid points
which do lie inside the window. See the examples.
This function is useful in creating dummy points for quadrature
schemes (see quadscheme
) and for other miscellaneous
purposes.
A list with two components x
and y
, which are numeric
vectors giving the coordinates of the points of the
rectangular grid.
and \rolf
quad.object
,
quadscheme
,
inside.owin
,
stratrand
w <- unit.square()
xy <- gridcentres(w, 10,15)
if(human <- interactive()) {
plot(w)
points(xy)
}
bdry <- list(x=c(0.1,0.3,0.7,0.4,0.2),
y=c(0.1,0.1,0.5,0.7,0.3))
w <- owin(c(0,1), c(0,1), poly=bdry)
xy <- gridcentres(w, 30, 30)
ok <- inside.owin(xy$x, xy$y, w)
if(human) {
plot(w)
points(xy$x[ok], xy$y[ok])
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.