Created
February 16, 2021 23:43
-
-
Save georgemsavva/9ad7f698f014e91e3b07b8f833390752 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
pickover <- function(prev, p){ | |
c( | |
sin(p[1]*prev[2])+p[3]*sin(p[1]*prev[1]), | |
sin(p[2]*prev[1])+p[4]*sin(p[2]*prev[2]) | |
) | |
} | |
computeAttractor <- function(params,funs,n=1e4,startX){ | |
X=matrix(NA, nrow=n, ncol=length(startX)) | |
X[1,] <- startX | |
for(i in 2:n) { | |
X[i,] <- funs(prev=X[i-1,], params) | |
} | |
X | |
} | |
pngAttractor <- function(X,filename, | |
width=2000, | |
height=2000, | |
h=.6,s=0,v=1, alpha=0.1, | |
bg="white", | |
mar=rep(5,4), | |
type="p"){ | |
png(filename, width=width, height=height, type="cairo") | |
par(bg=bg,mar=mar) | |
plot(X[,1], X[,2], axes=F, ann=F, | |
pch=".", col=hsv(h=h,s=s,v=v,alpha=alpha), type=type) | |
dev.off() | |
} | |
points=1e6 | |
## Set to 1e8 for very high quality, but takes a few minutes to run | |
paramlist <- list(c(-0.966918, 2.879879, 0.765145, 0.744728)) | |
img1 <- computeAttractor(paramlist[[1]], pickover, startX = c(0.1,0.1),n = points) | |
pngAttractor(img1, "king7.png", width=4000, bg="black", height=4000, h=0,s=0,v=1,alpha=0.5, mar=rep(20,4)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment