w <- unit.square()
area.owin(w)
# returns 1.00000
k <- 6
theta <- 2 * pi * (0:(k-1))/k
co <- cos(theta)
si <- sin(theta)
mas <- owin(c(-1,1), c(-1,1), poly=list(x=co, y=si))
area.owin(mas)
# returns approx area of k-gon
mas <- as.mask(square(2), eps=0.01)
X <- raster.x(mas)
Y <- raster.y(mas)
mas$m <- ((X - 1)^2 + (Y - 1)^2 <= 1)
area.owin(mas)
# returns 3.14 approx
Run the code above in your browser using DataLab