Skip to content

Instantly share code, notes, and snippets.

@dill
Created July 16, 2018 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dill/e122661afad218e96ecd58669fadfcc8 to your computer and use it in GitHub Desktop.
Save dill/e122661afad218e96ecd58669fadfcc8 to your computer and use it in GitHub Desktop.
silly experiment with contours
###
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)
}
@dill
Copy link
Author

dill commented Jul 16, 2018

examples:

screen shot 2018-07-16 at 21 50 11
screen shot 2018-07-16 at 21 50 15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment