Skip to content

Commit

Permalink
add a new renderer called delta with phase modulation
Browse files Browse the repository at this point in the history
  • Loading branch information
dgtized committed Aug 5, 2024
1 parent b2b9a19 commit 4cfd632
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/shimmers/sketches/pendulum_sway.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,22 @@
(* r dampen1 (math/sin (+ (* 6 dampen2) (* fy t)))))
(v/polar (* 0.04 r dampen2) (* 4 t)))))

(defn delta [r t {:keys [lambda1 lambda2 dx dy gamma-rate]}]
(let [dampen1 (math/exp (* (- lambda1) t))
dampen2 (math/exp (* (- lambda2) t))
fx (+ dx (* 0.00025 (math/sin (* gamma-rate t))))
fy (+ dy (* 0.00025 (math/cos (* gamma-rate t))))]
(tm/+ (gv/vec2 (* r dampen1 (math/cos (+ (* 6 dampen2) (* fx t)
(* 0.005 (math/sin (* 0.2 t))))))
(* r dampen1 (math/sin (+ (* 6 dampen2) (* fy t)
(* 0.005 (math/cos (* 0.2 t)))))))
(v/polar (* 0.04 r dampen2) (* 4 t)))))

(def functions
{:alpha alpha
:beta beta
:gamma gamma})
:gamma gamma
:delta delta})

(defn plot [{:keys [p r]} {:keys [select-fn] :as params}]
(let [limit 100
Expand All @@ -68,7 +80,8 @@
circles))

(defn gen-parameters []
{:select-fn (dr/weighted [[:alpha 1.0] [:beta 2.0] [:gamma 1.5]])
{:select-fn (dr/weighted [[:alpha 1.0] [:beta 2.0]
[:gamma 1.5] [:delta 1.0]])
:dx (+ (dr/random-int 1 6) (dr/random -0.01 0.01))
:dy (+ (dr/random-int 1 6) (dr/random -0.01 0.01))
:lambda1 0.004
Expand Down

0 comments on commit 4cfd632

Please sign in to comment.