[R] Inverting polygon

Ernesto Jardim ernesto at ipimar.pt
Tue Oct 1 12:05:07 CEST 2002


Hi

Thanks for your help.

EJ

On Mon, 2002-09-30 at 16:28, white.denis at epamail.epa.gov wrote:
> An even better solution, obviating the extra call to lines is:
> 
> n <- 50 * 3
> x <- runif (n)
> y <- runif (n)
> x[(seq(n) %% 3) == 0] <- NA
> y[(seq(n) %% 3) == 0] <- NA
> 
> plot.new ()
> range.x <- range (x, na.rm=TRUE)
> range.y <- range (y, na.rm=TRUE)
> plot.window (range.x, range.y, asp=1)
> lines (x, y)
> 
> wind.x <- c(range.x, rev (range.x), range.x[1])
> wind.y <- c(range.y[1], range.y, rev (range.y))
> 
> # example polygon
> poly.x <- wind.x / 2 + 0.25
> poly.y <- wind.y / 2 + 0.25
> 
> mask.x <- c(wind.x, poly.x)
> mask.y <- c(wind.y, poly.y)
> polygon (mask.x, mask.y, col="white", border="white")


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list