Skip to content

Commit

Permalink
notes about point order blocking some polygon conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
dgtized committed Nov 23, 2023
1 parent 088acf1 commit 4c614ba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/shimmers/math/geometry/rectangle.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
(left-side (rect/rect 5))
(map g/bounds (lines/cut-polygon (rect/rect 10) (left-side (rect/rect 2 0 6 10)))))

;; FIXME: handle if point order is rotated (also cw/ccw)?
;; ie a-b vs b-c vs c-d
;; d-c a-d b-a
(defn polygon->rectangle
"Convert a `polygon` to a `Rect2` iff it has 4 points and they are axis aligned.
Expand Down
7 changes: 4 additions & 3 deletions src/shimmers/sketches/divisible.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,10 @@
(mapcat (fn [r] (punch-out r box)) rects))
[bounds]
punches)]
(concat (map (fn [s] (if (instance? Polygon2 s)
(vary-meta s assoc :fill "#ddd")
s))
(concat (map (fn [s]
(if (instance? Polygon2 s)
(vary-meta s assoc :fill "#ddd")
s))
(reduce reduce-overlapping
remaining
punches))
Expand Down

0 comments on commit 4c614ba

Please sign in to comment.