@@ -273,6 +273,45 @@ mod tests {
273273 ) ;
274274 }
275275
276+ /// Test that intersects() detects when an edge passes through another polygon's interior.
277+ ///
278+ /// Shape A is a quadrilateral: (0,1), (0,0), (3,0), (3,8)
279+ /// Shape B is a box: (0,3) to (1,4)
280+ ///
281+ /// The edge from (0,1) to (3,8) passes through (1, 10/3 ≈ 3.33), which is inside B.
282+ /// Therefore intersects() should return true.
283+ #[ test]
284+ fn test_intersects_edge_through_interior ( ) {
285+ // Shape A: quadrilateral with edge passing through B's interior
286+ let shape_a = vec ! [
287+ IntPoint :: new( 0 , 1 ) ,
288+ IntPoint :: new( 0 , 0 ) ,
289+ IntPoint :: new( 3 , 0 ) ,
290+ IntPoint :: new( 3 , 8 ) ,
291+ ] ;
292+
293+ // Shape B: box from (0,3) to (1,4)
294+ let shape_b = vec ! [
295+ IntPoint :: new( 0 , 3 ) ,
296+ IntPoint :: new( 1 , 3 ) ,
297+ IntPoint :: new( 1 , 4 ) ,
298+ IntPoint :: new( 0 , 4 ) ,
299+ ] ;
300+
301+ let mut overlay = PredicateOverlay :: new ( 16 ) ;
302+ overlay. add_contour ( & shape_a, ShapeType :: Subject ) ;
303+ overlay. add_contour ( & shape_b, ShapeType :: Clip ) ;
304+
305+ // The edge from (0,1) to (3,8) has parametric form:
306+ // P(t) = (0,1) + t*(3,7) = (3t, 1+7t) for t in [0,1]
307+ // At x=1: t=1/3, y = 1 + 7/3 = 10/3 ≈ 3.333
308+ // Point (1, 3.333) is strictly inside B (x in [0,1], y in [3,4])
309+ assert ! (
310+ overlay. intersects( ) ,
311+ "Edge (0,1)->(3,8) passes through box interior at (1, 3.33); should intersect"
312+ ) ;
313+ }
314+
276315 #[ test]
277316 fn test_segment_end_to_start_touch ( ) {
278317 // Triangle where subject's segment endpoint touches clip's segment startpoint
0 commit comments