🐛 Fix coplanar keyword mismatch in intersect-segments?

orientation returns the auto-qualified keyword ::coplanar
(app.common.geom.shapes.intersect/coplanar) but intersect-segments?
was comparing against the plain unqualified :coplanar keyword, which
never matches. This caused all collinear/on-segment edge cases to be
silently skipped, potentially missing valid segment intersections.

Signed-off-by: Andrey Antukh <niwi@niwi.nz>
This commit is contained in:
Andrey Antukh 2026-04-14 19:37:42 +00:00
parent adfe4c3945
commit cf47d5e53e
2 changed files with 8 additions and 10 deletions

View File

@ -55,16 +55,16 @@
(and (not= o1 o2) (not= o3 o4)) (and (not= o1 o2) (not= o3 o4))
;; p1, q1 and p2 colinear and p2 lies on p1q1 ;; p1, q1 and p2 colinear and p2 lies on p1q1
(and (= o1 :coplanar) ^boolean (on-segment? p2 p1 q1)) (and (= o1 ::coplanar) ^boolean (on-segment? p2 p1 q1))
;; p1, q1 and q2 colinear and q2 lies on p1q1 ;; p1, q1 and q2 colinear and q2 lies on p1q1
(and (= o2 :coplanar) ^boolean (on-segment? q2 p1 q1)) (and (= o2 ::coplanar) ^boolean (on-segment? q2 p1 q1))
;; p2, q2 and p1 colinear and p1 lies on p2q2 ;; p2, q2 and p1 colinear and p1 lies on p2q2
(and (= o3 :coplanar) ^boolean (on-segment? p1 p2 q2)) (and (= o3 ::coplanar) ^boolean (on-segment? p1 p2 q2))
;; p2, q2 and p1 colinear and q1 lies on p2q2 ;; p2, q2 and p1 colinear and q1 lies on p2q2
(and (= o4 :coplanar) ^boolean (on-segment? q1 p2 q2))))) (and (= o4 ::coplanar) ^boolean (on-segment? q1 p2 q2)))))
(defn points->lines (defn points->lines
"Given a set of points for a polygon will return "Given a set of points for a polygon will return

View File

@ -52,12 +52,10 @@
[(pt 0 5) (pt 10 5)])))) [(pt 0 5) (pt 10 5)]))))
(t/testing "Two collinear overlapping segments" (t/testing "Two collinear overlapping segments"
;; NOTE: The implementation compares orientation result (namespaced keyword ::coplanar) ;; Collinear overlapping segments correctly detected as intersecting.
;; against unnamespaced :coplanar, so the collinear branch never triggers. (t/is (true? (gint/intersect-segments?
;; Collinear overlapping segments are NOT detected as intersecting. [(pt 0 0) (pt 10 0)]
(t/is (false? (gint/intersect-segments? [(pt 5 0) (pt 15 0)]))))
[(pt 0 0) (pt 10 0)]
[(pt 5 0) (pt 15 0)]))))
(t/testing "Two non-overlapping collinear segments" (t/testing "Two non-overlapping collinear segments"
(t/is (false? (gint/intersect-segments? (t/is (false? (gint/intersect-segments?