Skip to content

Commit

Permalink
clarify planar-pairs by extracting planar? helper internally
Browse files Browse the repository at this point in the history
  • Loading branch information
dgtized committed Jul 19, 2024
1 parent 63e780d commit b57ff01
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/shimmers/sketches/ring_impressions.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,22 @@
(gv/vec2 (* width x) (* height y)))

(defn planar-pairs [circles pairs]
(reduce (fn [xs segment]
(letfn [(planar? [circles xs segment]
(let [[p q] segment]
(if (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? (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))))]
(reduce (fn [xs segment]
(if (planar? circles xs segment)
(conj xs segment)
xs)))
[]
(cs/all-pairs pairs)))
xs))
[]
(cs/all-pairs pairs))))

(defn noise-pos [seed]
(fn [scale pos]
Expand Down

0 comments on commit b57ff01

Please sign in to comment.