Skip to content

Commit

Permalink
remove some more redundant nested calls
Browse files Browse the repository at this point in the history
  • Loading branch information
dgtized committed Nov 29, 2024
1 parent e654b6d commit 101195b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/shimmers/math/control.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
(defn angular-acceleration [angle target control angle-vel]
(let [delta (angular-delta angle target)]
(- (* control delta)
(* (* 2 (math/sqrt control)) angle-vel))))
(* 2 (math/sqrt control) angle-vel))))

(defn spin-acceleration [angle-vel target-vel control]
(let [delta (- target-vel angle-vel)]
(- (* control delta)
(* (* 2 (math/sqrt control)) angle-vel))))
(* 2 (math/sqrt control) angle-vel))))

(defn force-accel [pos target control velocity]
(let [dir (tm/- target pos)]
Expand Down
2 changes: 1 addition & 1 deletion src/shimmers/model/mechanism.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
(+ (if (or (= driver-type :ring-gear) (= type :ring-gear))
(+ (* gear-ratio (+ offset (- math/PI angle))) angle)
(+ (* gear-ratio offset)
(* (+ gear-ratio 1) (* dir angle)))))
(* (+ gear-ratio 1) dir angle))))
(mod (/ tm/TWO_PI teeth))))
0))

Expand Down
6 changes: 3 additions & 3 deletions src/shimmers/sketches/display_tree.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@
(defn make-triangle [bounds]
(let [limit (min (g/width bounds) (g/height bounds))
s (if (dr/chance 0.75) (dr/random 0.15 0.66) 0)
radius (* s (* 0.65 limit))
radius (* s 0.65 limit)
n-triangles (dr/weighted {1 1 3 2 5 3 7 2})
angle (* eq/TAU (dr/rand-nth (butlast (tm/norm-range 4))))
spin (* (dr/random-sign)
Expand Down Expand Up @@ -397,10 +397,10 @@
(fn [t _f] (mod (+ (* dir t) v) 1.0)))
:radial
(let [factor (math/pow 2.0 (dr/rand-nth [0 0 6]))]
(fn [t _f] (eq/unit-sin (+ (/ r factor) (* 1.5 (* dir t))))))
(fn [t _f] (eq/unit-sin (+ (/ r factor) (* 1.5 dir t)))))
:sweep
(let [blades (dr/random-int 4)]
(fn [t _f] (eq/unit-sin (+ (+ blades theta) (* dir t))))))))]
(fn [t _f] (eq/unit-sin (+ blades theta (* dir t))))))))]
(fn [p rotation t f]
(doseq [{:keys [value] :as div} divisions]
(q/fill (value t f))
Expand Down

0 comments on commit 101195b

Please sign in to comment.