Skip to content

Commit

Permalink
add projected cilia along the original function
Browse files Browse the repository at this point in the history
  • Loading branch information
dgtized committed Oct 25, 2024
1 parent 4c76bcc commit 762d42c
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/shimmers/sketches/cilia_phase.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
[shimmers.common.svg :as csvg :include-macros true]
[shimmers.common.ui.controls :as ctrl]
[shimmers.common.ui.svg :as usvg]
[shimmers.math.deterministic-random :as dr]
[shimmers.math.equations :as eq]
[shimmers.sketch :as sketch :include-macros true]
[thi.ng.geom.core :as g]
[thi.ng.geom.line :as gl]
[thi.ng.geom.vector :as gv]
[shimmers.math.deterministic-random :as dr]))
[thi.ng.math.core :as tm]))

;; Concept: generate a random phase-shifted function, and then add cilia along
;; it's path. Specifically interested in trying to make another phase shifted
Expand All @@ -26,14 +29,29 @@
cx' (dr/random)]
(fn [x] (math/sin (* eq/TAU (+ (* rx x) cx (* amp (math/cos (* eq/TAU (+ (* rx' x) cx'))))))))))

(defn screen-space [fx x]
(rv x (+ 0.5 (* 0.35 (fx x)))))

(defn base-spline [fx]
(for [x (range 0 1 0.0025)]
(rv x (+ 0.5 (* 0.35 (fx x))))))
(screen-space fx x)))

;; How to avoid intersecting cilia?
(defn cilias [fx]
(let [spx (spline-fx)]
(for [x (range 0 1 0.005)]
(let [pt (screen-space fx x)
pt' (screen-space fx (+ x 0.0001))
len (+ 12 (* 8 (spx x)))
offset (tm/normalize (g/rotate (tm/- pt' pt) (* eq/TAU 0.25)) len)]
(gl/line2 (tm/+ pt offset) (tm/- pt offset))))))

(defn shapes []
(let [fx (spline-fx)
spline-pts (base-spline fx)]
[(csvg/path (csvg/segmented-path spline-pts))]))
spline-pts (base-spline fx)
cilia (cilias fx)]
(concat [(csvg/path (csvg/segmented-path spline-pts))]
cilia)))

(defn scene [{:keys [scene-id]}]
(csvg/svg-timed
Expand Down

0 comments on commit 762d42c

Please sign in to comment.