Skip to content

Commit

Permalink
life out create-osc and R into wobble ns for sharing
Browse files Browse the repository at this point in the history
  • Loading branch information
dgtized committed Mar 16, 2024
1 parent 37986f2 commit 8edefe9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
16 changes: 14 additions & 2 deletions src/shimmers/math/wobble.cljc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
(ns shimmers.math.wobble
(:require [shimmers.math.deterministic-random :as dr]
[shimmers.math.equations :as eq]))
(:require
[shimmers.math.deterministic-random :as dr]
[shimmers.math.equations :as eq]
[shimmers.math.vector :as v]))

(defn create
([r] (create r (dr/random-tau)))
Expand Down Expand Up @@ -29,3 +31,13 @@

(defn cube-tcos [osc p t]
(eq/cube (tcos osc p t)))

(defn R [f p a s]
(v/polar a (* eq/TAU (+ (* s f) p))))

(defn O [f p v d s]
(+ v (* d (Math/sin (* eq/TAU (+ (* s f) p))))))

(defn create-osc [f v d]
{:f f :v v :d d
:fe (fn [p s] (O f p v d s))})
12 changes: 1 addition & 11 deletions src/shimmers/sketches/display_tree.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
[shimmers.math.geometry.collisions :as collide]
[shimmers.math.geometry.triangle :as triangle]
[shimmers.math.vector :as v]
[shimmers.math.wobble :as mw]
[shimmers.math.wobble :as mw :refer [create-osc R]]
[shimmers.sketch :as sketch :include-macros true]
[thi.ng.geom.circle :as gc]
[thi.ng.geom.core :as g]
Expand Down Expand Up @@ -272,16 +272,6 @@
(g/scale-size (scale t))
(qdg/draw)))))

(defn R [f p a s]
(v/polar a (* eq/TAU (+ (* s f) p))))

(defn O [f p v d s]
(+ v (* d (Math/sin (* eq/TAU (+ (* s f) p))))))

(defn create-osc [f v d]
{:f f :v v :d d
:fe (fn [p s] (O f p v d s))})

(defn make-spinner [bounds]
(let [radius (min (g/width bounds) (g/height bounds))
direction (* (dr/random-sign) (dr/gaussian 0.7 0.06))
Expand Down

0 comments on commit 8edefe9

Please sign in to comment.