Skip to content

Instantly share code, notes, and snippets.

@postspectacular
Created June 26, 2016 13:12
Show Gist options
  • Save postspectacular/13ece130bcc31c303064d387d4d6b54d to your computer and use it in GitHub Desktop.
Save postspectacular/13ece130bcc31c303064d387d4d6b54d to your computer and use it in GitHub Desktop.
Peter de Jong Strange Attractor
(defn compute-dejong
"Computes a single DeJong 2d point vector for given params and XY pos"
[a b c d x y]
(v/vec2
(+ (Math/sin (* a y)) (Math/cos (* (* b x) x)))
(+ (Math/sin (* (* c x) x)) (Math/cos (* d y)))))
(->> (range 1e6)
(reduce
(fn [[points [x y]] _]
(let [pos (compute-dejong a b c d x y)]
[(conj points pos) pos]))
[[] [(m/random width) (m/random width)]])
(first))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment