public void IntersectionPointTest( float ax1, float ay1, float ax2, float ay2, float bx1, float by1, float bx2, float by2, float ix, float iy, IntersectionType type )
{
LineSegment segA = new LineSegment( new Point( ax1, ay1 ), new Point( ax2, ay2 ) );
LineSegment segB = new LineSegment( new Point( bx1, by1 ), new Point( bx2, by2 ) );
Point expectedIntersection = new Point( ix, iy );
Assert.DoesNotThrow( ( ) =>
{
Point? segSeg = segA.GetIntersectionWith( segB );
Point? segLine = segA.GetIntersectionWith( (Line) segB );
Point? lineSeg = ( (Line) segA ).GetIntersectionWith( segB );
if ( type == IntersectionType.AllFour )
{
Assert.AreEqual( expectedIntersection, segSeg );
}
else
{
Assert.AreEqual( null, segSeg );
}
if ( ( type == IntersectionType.AllFour ) || ( type == IntersectionType.SegmentA ) )
{
Assert.AreEqual( expectedIntersection, segLine );
}
else
{
Assert.AreEqual( null, segLine );
}
if ( ( type == IntersectionType.AllFour ) || ( type == IntersectionType.SegmentB ) )
{
Assert.AreEqual( expectedIntersection, lineSeg );
}
else
{
Assert.AreEqual( null, lineSeg );
}
} );
Point? lineLine = ( (Line) segA ).GetIntersectionWith( (Line) segB );
if ( type != IntersectionType.None )
{
Assert.AreEqual( expectedIntersection, lineLine );
}
else
{
Assert.AreEqual( null, lineLine );
}
}