Ejemplo n.º 1
0
        public void LineCircleIntersection()
        {
            BoundaryCircle circleOnOrigin = new BoundaryCircle(1.0f, new Vector2D(0.0f,0.0f));

            Line intersectingLine = new Line(new Vector2D(-1.0f, -1.0f), new Vector2D(1.0f, 1.0f));
            Line nonIntersectingLine = new Line(new Vector2D(-1.0f, 1.0f), new Vector2D(1.0f, 2.0f));
            Line boundedNonIntersectingLine = new Line(new Vector2D(1.1f, 1.1f), new Vector2D(2.6f, 2.6f));
            Line internalLine = new Line(new Vector2D(0.5f, 0.5f), new Vector2D(0.4f, 0.4f));

            Assert.IsTrue(circleOnOrigin.TestIntersection(intersectingLine));
            Assert.IsFalse(circleOnOrigin.TestIntersection(nonIntersectingLine));
            Assert.IsFalse(circleOnOrigin.TestIntersection(boundedNonIntersectingLine));
            Assert.IsTrue(circleOnOrigin.TestIntersection(internalLine));
        }
Ejemplo n.º 2
0
 public static bool TestIntersection(this Bounds bounds, BoundaryCircle circle)
 {
     if (bounds is BoundaryCircle)
     {
         return circle.TestIntersection(bounds as BoundaryCircle);
     }
     else if (bounds is BoundaryRect)
     {
         return circle.TestIntersection(bounds as BoundaryRect);
     }
     else
     {
         throw new InvalidOperationException("Attempting to test boundary on unknown types");
     }
 }