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])
}
Run the code above in your browser using DataLab