Revision 56d752cf6d1a8e2775e1acc46482c206cfd5b269 authored by Adrian Baddeley on 14 March 2012, 07:09:51 UTC, committed by cran-robot on 14 March 2012, 07:09:51 UTC
1 parent a4d492a
disc.R
#
# disc.R
#
# $Revision: 1.4 $ $Date: 2011/05/18 01:43:54 $
#
#
disc <- function(radius=1, centre=c(0,0), ..., mask=FALSE, npoly=128) {
stopifnot(length(centre) == 2)
stopifnot(length(radius) == 1)
stopifnot(radius > 0)
stopifnot(length(npoly) == 1)
stopifnot(npoly > 2)
if(!mask) {
theta <- seq(from=0, to=2*pi, length.out=npoly+1)[-(npoly+1)]
x <- centre[1] + radius * cos(theta)
y <- centre[2] + radius * sin(theta)
W <- owin(poly=list(x=x, y=y))
} else {
B <- owin(c(-1,1),c(-1,1))
B <- as.mask(B, ...)
indic <- function(x,y,x0,y0,r) ifelse((x-x0)^2 + (y-y0)^2 < r^2, 1, 0)
IW <- as.im(indic, B, x0=centre[1], y0=centre[2], r=radius)
W <- levelset(IW, 1, "==")
}
return(W)
}
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...