Skip to content

Commit

Permalink
Finish off converting Math/ to clojure.math
Browse files Browse the repository at this point in the history
  • Loading branch information
dgtized committed May 18, 2024
1 parent 753de01 commit 0b95e80
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 15 deletions.
3 changes: 2 additions & 1 deletion src/shimmers/sketches/along_the_curve.cljs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(ns shimmers.sketches.along-the-curve
(:require
[clojure.math :as math]
[quil.core :as q :include-macros true]
[quil.middleware :as m]
[shimmers.common.framerate :as framerate]
Expand Down Expand Up @@ -46,7 +47,7 @@
fx' (fp x')
b (gv/vec2 x fx)
perp (gv/vec2 (tm/cross (gv/vec3 (tm/- (gv/vec2 x' fx') b))
(gv/vec3 0 0 (* 20 (Math/cos (+ (/ x 5) (* 0.5 t)))))))]
(gv/vec3 0 0 (* 20 (math/cos (+ (/ x 5) (* 0.5 t)))))))]
(q/curve-vertex x fx)
(q/line b (tm/+ b perp))))
(q/end-shape)))
Expand Down
3 changes: 2 additions & 1 deletion src/shimmers/sketches/balloon.cljs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(ns shimmers.sketches.balloon
(:require
[clojure.math :as math]
[quil.core :as q :include-macros true]
[quil.middleware :as m]
[shimmers.common.framerate :as framerate]
Expand Down Expand Up @@ -59,7 +60,7 @@
(-> state
(update :balloon (pressurize pressure mass dt))
(update :t + dt)
(assoc :pressure (+ 15.0 (* 5.0 (Math/cos (* 0.05 t))))))))
(assoc :pressure (+ 15.0 (* 5.0 (math/cos (* 0.05 t))))))))

(defn draw [{:keys [balloon]}]
(q/background 1.0)
Expand Down
3 changes: 2 additions & 1 deletion src/shimmers/sketches/chaos_cuts.cljs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(ns shimmers.sketches.chaos-cuts
(:require
[clojure.math :as math]
[quil.core :as q :include-macros true]
[quil.middleware :as m]
[shimmers.algorithm.lines :as lines]
Expand Down Expand Up @@ -49,7 +50,7 @@
(cline [-3 0.5] 0.8
[2.5 0.5] 1.1
(+ 1 (* 0.03 t)) (+ 2 (* 0.04 t)))
(cline [-2.5 (+ 0.5 (* 0.3 (Math/sin (* 0.01 t))))] 1.1
(cline [-2.5 (+ 0.5 (* 0.3 (math/sin (* 0.01 t))))] 1.1
[2.25 0.5] 0.8
(+ 2 (* 0.03 t)) (+ 3 (* 0.035 t)))])

Expand Down
3 changes: 2 additions & 1 deletion src/shimmers/sketches/concentric_moire.cljs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(ns shimmers.sketches.concentric-moire
(:require
[clojure.math :as math]
[quil.core :as q :include-macros true]
[quil.middleware :as m]
[shimmers.common.framerate :as framerate]
Expand All @@ -26,7 +27,7 @@
(q/background 1.0)
(q/no-fill)
(q/ellipse-mode :radius)
(let [change (* 0.5 (+ 1 (Math/sin (/ (q/frame-count) 40))))]
(let [change (* 0.5 (+ 1 (math/sin (/ (q/frame-count) 40))))]
(doseq [{:keys [pos spacing upper weight]} circles]
(q/stroke-weight weight)
(doseq [r (range 0 upper)]
Expand Down
13 changes: 7 additions & 6 deletions src/shimmers/sketches/concentric_orbits.cljs
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
(ns shimmers.sketches.concentric-orbits
(:require
[clojure.math :as math]
[shimmers.common.svg :as csvg :include-macros true]
[shimmers.common.ui.controls :as ctrl]
[shimmers.math.deterministic-random :as dr]
[shimmers.math.equations :as eq]
[shimmers.math.vector :as v]
[shimmers.sketch :as sketch :include-macros true]
[shimmers.view.sketch :as view-sketch]
[thi.ng.geom.vector :as gv]
[thi.ng.geom.circle :as gc]
[thi.ng.math.core :as tm]
[shimmers.math.vector :as v]
[shimmers.math.equations :as eq]
[shimmers.math.deterministic-random :as dr]))
[thi.ng.geom.vector :as gv]
[thi.ng.math.core :as tm]))

(def width 800)
(def height 600)
(defn rv [x y]
(gv/vec2 (* width x) (* height y)))

(defn max-radius [r n]
(/ r (+ Math/E (Math/sin (/ eq/TAU n)))))
(/ r (+ math/E (math/sin (/ eq/TAU n)))))

(defn orbit [{:keys [p r]} n phase]
(for [t (butlast (tm/norm-range n))]
Expand Down
3 changes: 2 additions & 1 deletion src/shimmers/sketches/intersecting_chords.cljs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(ns shimmers.sketches.intersecting-chords
(:require
[clojure.math :as math]
[quil.core :as q :include-macros true]
[quil.middleware :as m]
[shimmers.algorithm.circle-packing :as pack]
Expand Down Expand Up @@ -62,7 +63,7 @@

(defn rescale [bounds t {:keys [r] :as circle}]
(or (when-let [{:keys [R dr t0 dt]} (:R circle)]
(let [circle' (assoc circle :r (+ R (* dr (Math/sin (+ (* t dt) t0)))))]
(let [circle' (assoc circle :r (+ R (* dr (math/sin (+ (* t dt) t0)))))]
(if (geometry/contains-circle? bounds circle')
circle'
(update circle' :p
Expand Down
3 changes: 2 additions & 1 deletion src/shimmers/sketches/liminal_tension.cljs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(ns shimmers.sketches.liminal-tension
(:require
[clojure.math :as math]
[quil.core :as q :include-macros true]
[quil.middleware :as m]
[shimmers.algorithm.lines :as lines]
Expand All @@ -23,7 +24,7 @@
(let [v (tm/- pos dest)
wobble (* wiggle
(/ (tm/mag v) (inc t))
(Math/sin (/ t tm/PHI)))]
(math/sin (/ t tm/PHI)))]
(g/rotate (tm/normalize v wobble) (* 0.25 eq/TAU))))

(defn move [dt t pos-c angle-c drag]
Expand Down
3 changes: 2 additions & 1 deletion src/shimmers/sketches/triangle_intersections.cljs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(ns shimmers.sketches.triangle-intersections
(:require
[clojure.math :as math]
[shimmers.algorithm.random-points :as rp]
[shimmers.common.sequence :as cs]
[shimmers.common.svg :as csvg :include-macros true]
Expand Down Expand Up @@ -28,7 +29,7 @@
(partition 3 1))]
(let [p (tm/- a b)
q (tm/- c b)]
(Math/acos (/ (tm/dot p q)
(math/acos (/ (tm/dot p q)
(* (abs (tm/mag p))
(abs (tm/mag q)))))))))

Expand Down
3 changes: 2 additions & 1 deletion src/shimmers/sketches/trigonometry_boxes.cljs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(ns shimmers.sketches.trigonometry-boxes
(:require
[clojure.math :as math]
[quil.core :as q :include-macros true]
[quil.middleware :as m]
[shimmers.common.framerate :as framerate]
Expand Down Expand Up @@ -56,7 +57,7 @@
(update :height + (* dy (f (+ t0 (* t dt))))))))

(defn gen-time-function []
(dr/weighted [[Math/sin 4.0] [Math/cos 4.0] [Math/tan 1.0]
(dr/weighted [[math/sin 4.0] [math/cos 4.0] [math/tan 1.0]
[(partial wave/triangle eq/TAU) 2.0]
[(partial wave/square (dr/random 0.75 3.5)) 1.0]
[(partial wave/sawtooth eq/TAU) 2.0]
Expand Down
3 changes: 2 additions & 1 deletion src/shimmers/sketches/under_the_surface.cljs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(ns shimmers.sketches.under-the-surface
(:require
[clojure.math :as math]
[quil.core :as q :include-macros true]
[quil.middleware :as m]
[shimmers.algorithm.random-points :as rp]
Expand Down Expand Up @@ -67,7 +68,7 @@
(update :t + (dr/random 0.05))))

(defn draw-frame [{:keys [storms t]}]
(q/background 1.0 (+ 0.08 (* 0.05 (Math/cos t))))
(q/background 1.0 (+ 0.08 (* 0.05 (math/cos t))))
(q/ellipse-mode :radius)
(q/stroke 0.0)
(q/stroke-weight 3.0)
Expand Down

0 comments on commit 0b95e80

Please sign in to comment.