@@ -75,18 +75,32 @@ public void CircleIntersectWithLine2D_NumberOfIntersections(string sc, double ra
7575 Assert . That ( actual . Count ( ) , Is . EqualTo ( expectedNumberOfIntersections ) ) ;
7676 }
7777
78- [ TestCase ( "0,0" , 1.41421356 /*=sqrt(2)*/ , "0,0" , "+1,+1" , "+1,+1" ) ]
79- [ TestCase ( "0,0" , 1 , "0,0" , "+1,0" , "+1,0" ) ]
80- [ TestCase ( "0,0" , 1 , "0,0" , "0,+1" , "0,+1" ) ]
81- public void CircleIntersectWithLineSegment2D ( string sCenter , double radius , string sStart , string sEnd , string sExpected )
78+ //segment contains the all intersections(same to the cases of circle and line)
79+ [ TestCase ( "0,0" , 1 , "-10,+10" , "+10,+10" , 0 ) ]
80+ [ TestCase ( "0,0" , 1 , "-10,+1" , "+10,+1" , 1 ) ]
81+ [ TestCase ( "0,0" , 1 , "-10,0" , "+10,0" , 2 ) ]
82+ [ TestCase ( "0,0" , 1 , "-10,-1" , "+10,-1" , 1 ) ]
83+ [ TestCase ( "0,0" , 1 , "-10,-10" , "+10,-10" , 0 ) ]
84+ //segments cross the circle's contour just 1 time
85+ [ TestCase ( "0,0" , 1 , "+0,+10" , "+10,+10" , 0 ) ]
86+ [ TestCase ( "0,0" , 1 , "+0,+1" , "+10,+1" , 1 ) ]
87+ [ TestCase ( "0,0" , 1 , "+0,0" , "+10,0" , 1 ) ]
88+ [ TestCase ( "0,0" , 1 , "+0,-1" , "+10,-1" , 1 ) ]
89+ [ TestCase ( "0,0" , 1 , "+0,-10" , "+10,-10" , 0 ) ]
90+ //segment contains no intersections(px of the startingPoint is too big to intersect with the circle)
91+ [ TestCase ( "0,0" , 1 , "+10,+10" , "+100,+10" , 0 ) ]
92+ [ TestCase ( "0,0" , 1 , "+10,+01" , "+100,+1" , 0 ) ]
93+ [ TestCase ( "0,0" , 1 , "+10,+00" , "+100,0" , 0 ) ]
94+ [ TestCase ( "0,0" , 1 , "+10,-01" , "+100,-1" , 0 ) ]
95+ [ TestCase ( "0,0" , 1 , "+10,-10" , "+100,-10" , 0 ) ]
96+ public void CircleIntersectWithLineSegment2D_NumberOfIntersections ( string sCenter , double radius , string sStart , string sEnd , int expectedNumberOfIntersections )
8297 {
8398 var circle = new Circle2D ( Point2D . Parse ( sCenter ) , radius ) ;
8499 var segment = new LineSegment2D ( Point2D . Parse ( sStart ) , Point2D . Parse ( sEnd ) ) ;
100+
85101 var actual = circle . IntersectWith ( segment ) ;
86- Assert . That ( actual . Length , Is . EqualTo ( 1 ) ) ;
87102
88- var expected = Point2D . Parse ( sExpected ) ;
89- AssertGeometry . AreEqual ( actual [ 0 ] , expected ) ;
103+ Assert . That ( actual . Count ( ) , Is . EqualTo ( expectedNumberOfIntersections ) ) ;
90104 }
91105 }
92106}
0 commit comments