Skip to content

Instantly share code, notes, and snippets.

@DavisVaughan
Created November 8, 2017 13:14
Show Gist options
  • Save DavisVaughan/549334145e3f38bf31c205295f59e788 to your computer and use it in GitHub Desktop.
Save DavisVaughan/549334145e3f38bf31c205295f59e788 to your computer and use it in GitHub Desktop.
a=-1.24458046630025
b=-1.25191834103316
c=-1.81590817030519
d=-1.90866735205054
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
@davidomarf
Copy link

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: https://davidomarf.github.io/attractor-seeder/

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