Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
n <- 10000000
x <- vector("numeric", n)
y <- vector("numeric", n)
x[1] <- 0
y[1] <- 0
t1 <- proc.time()
for(i in 2:n) {
x[i] <- sin(a * y[i-1] + c * cos(a * x[i-1]))
y[i] <- sin(b * x[i-1] + d * cos(b * y[i-1]))
df <- data.frame(x = x, y = y)
proc.time() - t1
# user system elapsed
# 4.483 0.065 4.876

This comment has been minimized.

Copy link

@harnagpal harnagpal commented Jul 11, 2019

Hi Davis, thanks for sharing this. I have interest in maths art and R/GGPLOT visualizations. I have got one query. How did you get the value of a,b,c and d variables! What if we change these values!



This comment has been minimized.

Copy link

@davidomarf davidomarf commented Sep 3, 2019

Hi, harnagpal.
Currently I'm developing a tool to produce those a, b, c, d values automatically.

I found this gist looking for a more efficient way of drawing them.
It is a WIP, it has not a very good UI so far, but you can use it:

Just click on the "Generate" button. To generate new values, press space bar one time.
To avoid a certain attractor from being re-drawn, click the lock button that appears when you hover the attractor.
To copy the a, b, c, d values, click the clipboard icon.
To draw the attractor in a higher-quality image, click the "external link" icon.

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