Skip to content

Commit

Permalink
convert a subset of the output circles into equilateral triangles
Browse files Browse the repository at this point in the history
  • Loading branch information
dgtized committed Aug 3, 2024
1 parent 9b3002d commit eced747
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/shimmers/sketches/pendulum_sway.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
[shimmers.common.ui.svg :as usvg]
[shimmers.math.deterministic-random :as dr]
[shimmers.math.equations :as eq]
[shimmers.math.geometry.triangle :as triangle]
[shimmers.math.vector :as v]
[shimmers.sketch :as sketch :include-macros true]
[thi.ng.geom.circle :as gc]
[thi.ng.geom.core :as g]
[thi.ng.geom.vector :as gv]
[thi.ng.math.core :as tm]))

Expand Down Expand Up @@ -58,6 +60,13 @@
(math/exp (* -0.001 t))
(math/sin (+ (* 9 t)))))))))

(defn triangulate [circles]
(map-indexed (fn [i {:keys [p] :as c}]
(if (or (= 0 (mod i 5)) (= 0 (mod i 7)))
(triangle/inscribed-equilateral c (g/heading (tm/- (rv 0.5 0.5) p)))
c))
circles))

(defn gen-parameters []
{:select-fn (dr/weighted [[:alpha 1.0] [:beta 2.0] [:gamma 1.0]])
:dx (+ (dr/random-int 1 6) (dr/random -0.01 0.01))
Expand All @@ -74,7 +83,7 @@
:stroke "black"
:fill "none"
:stroke-width 0.5}
(plot {:p (rv 0.5 0.5) :r (* 0.475 height)} params)))
(triangulate (plot {:p (rv 0.5 0.5) :r (* 0.475 height)} params))))

(defn ui-controls [{:keys [params]}]
[:div
Expand Down

0 comments on commit eced747

Please sign in to comment.