Created
July 16, 2018 20:57
-
-
Save dill/e122661afad218e96ecd58669fadfcc8 to your computer and use it in GitHub Desktop.
silly experiment with contours
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
n <- 200 | |
add_layer <- function(coords=data.frame(x=0, y=0), layer=0){ | |
so_rad <- seq(0, 2*pi-0.1, len=n) | |
if(layer==0){ | |
lens0 <- 0.1*runif(1, 0.1, 1) | |
lens <- lens0 + runif(n, 0.01, 0.03) | |
}else{ | |
#lens0 <- 0 | |
lens0 <- 0.05*runif(1, 0.1, 1) | |
lens <- lens0 + abs(rnorm(n, 0, 0.02)) | |
} | |
# SOH CAH TOA | |
coords <- data.frame(x = coords$x + sin(so_rad)*lens, | |
y = coords$y + cos(so_rad)*lens) | |
if(layer == 0){ | |
coords <- rbind(coords, coords[1,]) | |
} | |
return(coords) | |
} | |
coords <- add_layer() | |
plot(coords, type="l", xlim=c(-0.25,0.25), ylim=c(-0.25, 0.25)) | |
#coords2 <- add_layer(coords, 1) | |
#lines(coords2) | |
coords_tmp <- coords | |
for(i in 1:10){ | |
coords_tmp <- add_layer(coords_tmp, 1) | |
lines(coords_tmp) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
examples: