Skip to content

Commit

Permalink
rename range-series to series-limit
Browse files Browse the repository at this point in the history
  • Loading branch information
dgtized committed Nov 25, 2024
1 parent 7064dca commit 26a1e3e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
16 changes: 8 additions & 8 deletions src/shimmers/common/sequence.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,11 @@
([pred coll]
(drop-while (complement pred) coll)))

(defn range-series [start end rate-f]
(take-while (fn [t] (<= t end))
(iterate (fn [t] (+ t (rate-f t)))
start)))

(comment (range-series 0 1 (fn [t] (max 0.01 (* 0.1 t))))
(range-series 0 1 (fn [t] (* 0.1 (math/exp (* (- 0.1) t)))))
(range-series 0 100 (fn [t] (math/exp (* 0.02 t)))))
(defn series-limit [start end rate-f]
(->> start
(iterate (fn [t] (+ t (rate-f t))))
(take-while (fn [t] (<= t end)))))

(comment (series-limit 0 1 (fn [t] (max 0.01 (* 0.1 t))))
(series-limit 0 1 (fn [t] (* 0.1 (math/exp (* (- 0.1) t)))))
(series-limit 0 100 (fn [t] (math/exp (* 0.02 t)))))
5 changes: 3 additions & 2 deletions src/shimmers/sketches/pendulum_sway.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@
(defn plot [{:keys [p r]} {:keys [select-fn] :as params}]
(let [limit 100
f (functions select-fn)]
(for [t (cs/range-series 0 (* limit eq/TAU)
(fn [t] (* 0.02 (math/exp (* 0.003 t)))))]
(for [t (cs/series-limit
0 (* limit eq/TAU)
(fn [t] (* 0.02 (math/exp (* 0.003 t)))))]
(gc/circle (tm/+ p (f r t params))
(+ 1.3 (* 0.7
(math/exp (* -0.001 t))
Expand Down

0 comments on commit 26a1e3e

Please sign in to comment.