We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
An animation of the famous lorenz attractor.
(ns chaos.core (:require [quil.core :as q])) (def screen [1200 800]) (def unit [5 5]) (def n-points 10) (def max-rand-n 50) (def sigma 28) (def rho 46.92) (def beta 4) (def dt 0.0003) (def points (atom (mapv #(into (vector) %) (for [i (range n-points) :let [x (- (rand-int (* 2 max-rand-n)) max-rand-n) y (- (rand-int (* 2 max-rand-n)) max-rand-n) z (- (rand-int (* 2 max-rand-n)) max-rand-n)]] [x y z])))) (defn lorenz-attractor [[x y z]] [(+ x (* dt (* sigma (- y x)))) (+ y (* dt (- (* x (- rho z)) y))) (+ z (* dt (- (* x y) (* beta z))))]) (defn setup [] (q/frame-rate 800) (q/background 20)) (defn draw [] (q/stroke-weight 0.1) (q/stroke 255 255 0) (reset! points (mapv lorenz-attractor @points)) (mapv #(q/point (+ (/ (get screen 0) 2) (* (get % 0) (get unit 0))) (+ (/ (get screen 1) 2) (* (get % 1) (get unit 1)))) @points)) (q/defsketch chaos :title "Chaos Attractor" :setup setup :draw draw :size [(get screen 0) (get screen 1)])
The text was updated successfully, but these errors were encountered:
No branches or pull requests
An animation of the famous lorenz attractor.
The text was updated successfully, but these errors were encountered: