Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,16 +1,13 @@
|
|||
#install.packages("caTools") # install external package (if missing)
|
||||
library(caTools) # external package providing write.gif function
|
||||
jet.colors <- colorRampPalette(c("red", "blue", "#007FFF", "cyan", "#7FFF7F",
|
||||
"yellow", "#FF7F00", "red", "#7F0000"))
|
||||
dx <- 800 # define width
|
||||
dy <- 600 # define height
|
||||
C <- complex(real = rep(seq(-2.5, 1.5, length.out = dx), each = dy),
|
||||
imag = rep(seq(-1.5, 1.5, length.out = dy), dx))
|
||||
C <- matrix(C, dy, dx) # reshape as square matrix of complex numbers
|
||||
Z <- 0 # initialize Z to zero
|
||||
X <- array(0, c(dy, dx, 20)) # initialize output 3D array
|
||||
for (k in 1:20) { # loop with 20 iterations
|
||||
Z <- Z^2 + C # the central difference equation
|
||||
X[, , k] <- exp(-abs(Z)) # capture results
|
||||
dx=800; dy=600 # define grid size
|
||||
C = complex(real=rep(seq(-2.2, 1.0, length.out=dx), each=dy),
|
||||
imag=rep(seq(-1.2, 1.2, length.out=dy), dx))
|
||||
C = matrix(C, dy, dx) # convert from vector to matrix
|
||||
Z = 0 # initialize Z to zero
|
||||
X = array(0, c(dy, dx, 20)) # allocate memory for all the frames
|
||||
for (k in 1:20) { # perform 20 iterations
|
||||
Z = Z^2+C # the main equation
|
||||
X[, , k] = exp(-abs(Z)) # store magnitude of the complex number
|
||||
}
|
||||
write.gif(X, "Mandelbrot.gif", col = jet.colors, delay = 100)
|
||||
library(caTools) # load library with write.gif function
|
||||
jetColors = colorRampPalette(c("#00007F", "blue", "#007FFF", "cyan", "#7FFF7F", "yellow", "#FF7F00", "red", "#7F0000"))
|
||||
write.gif(X, "Mandelbrot.gif", col=jetColors, delay=100, transparent=0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue