Skip to content

Commit

Permalink
extract impaled-circle? and intersected-segment?
Browse files Browse the repository at this point in the history
  • Loading branch information
dgtized committed Jul 19, 2024
1 parent b57ff01 commit 8a87b66
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/shimmers/sketches/ring_impressions.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,22 @@
(defn rv [x y]
(gv/vec2 (* width x) (* height y)))

(defn intersected-segment? [segment]
(fn [line]
(when (isec/segment-intersect line segment)
segment)))

(defn impaled-circle? [segment]
(let [[p q] segment]
(fn [circle]
(when-let [isec (isec/circle-ray (g/scale-size circle 1.1) p q)]
(when (= :impale (:type isec))
circle)))))

(defn planar-pairs [circles pairs]
(letfn [(planar? [circles xs segment]
(let [[p q] segment]
(and (not-any? (fn [line] (when (isec/segment-intersect line segment)
segment))
xs)
(not-any? (fn [circle]
(when-let [isec (isec/circle-ray (g/scale-size circle 1.1) p q)]
(when (= :impale (:type isec))
circle)))
circles))))]
(and (not-any? (intersected-segment? segment) xs)
(not-any? (impaled-circle? segment) circles)))]
(reduce (fn [xs segment]
(if (planar? circles xs segment)
(conj xs segment)
Expand Down

0 comments on commit 8a87b66

Please sign in to comment.