public void ContainsPolygon()
        {
            var exactlyOverlappingPolygon = new BoundingPolygon(_testAabb.Corners());
            var closelyContainedPolygon   = new BoundingPolygon(
                new BoundingRectangle(0.001f, 0.001f, 19.999f, 19.999f).Corners());
            var closelyNonIntersectingPolygon = new BoundingPolygon(
                new BoundingRectangle(-1, -1, -0.001f, -0.001f).Corners());
            var closelyIntersectingPolygon = new BoundingPolygon(
                new BoundingRectangle(-1, -1, 0.001f, 0.001f).Corners());

            Assert.That(_testAabb.Contains(exactlyOverlappingPolygon), Is.EqualTo(Containment.Contains));
            Assert.That(_testAabb.Contains(closelyContainedPolygon), Is.EqualTo(Containment.Contains));
            Assert.That(_testAabb.Contains(closelyNonIntersectingPolygon), Is.EqualTo(Containment.Disjoint));
            Assert.That(_testAabb.Contains(closelyIntersectingPolygon), Is.EqualTo(Containment.Intersects));
        }
        public void RotatedRectangleContainsPointWorks()
        {
            var rect = new BoundingRectangle(new Vector2d(2.5, 2.5), new Size2d(4.24, 2.83))
            {
                Rotation = Math.PI / 4
            };

            Assert.True(rect.Contains(rect.Position));

            foreach (var vertex in rect.Corners())
            {
                Assert.True(rect.Contains(vertex));
            }

            Assert.False(rect.Contains(new Vector2d(-1, 0)));
            Assert.False(rect.Contains(rect.TopRight + 1));
            Assert.False(rect.Contains(rect.BotRight + 1));
            Assert.False(rect.Contains(rect.TopLeft - 1));
            Assert.False(rect.Contains(rect.BotLeft - 1));

            Assert.True(rect.Contains(rect.TopRight - 1));
            Assert.True(rect.Contains(rect.BotRight - 1));
            Assert.True(rect.Contains(rect.TopLeft + 1));
            Assert.True(rect.Contains(rect.BotLeft + 1));
        }
 public void Init()
 {
     circle1 = new BoundingCircle(Vector2D.YAxis, 2);
     circle2 = new BoundingCircle(Vector2D.XAxis, 2);
     rect1 = BoundingRectangle.FromCircle(circle1);
     circle3 = BoundingCircle.FromRectangle(rect1);
     rect2 = BoundingRectangle.FromCircle(circle3);
     polygon1 = new BoundingPolygon(rect1.Corners());
 }
 public void Init()
 {
     circle1  = new BoundingCircle(Vector2D.YAxis, 2);
     circle2  = new BoundingCircle(Vector2D.XAxis, 2);
     rect1    = BoundingRectangle.FromCircle(circle1);
     circle3  = BoundingCircle.FromRectangle(rect1);
     rect2    = BoundingRectangle.FromCircle(circle3);
     polygon1 = new BoundingPolygon(rect1.Corners());
 }
        public void UnrotatedRectangleContainsPointWorks()
        {
            var rect = new BoundingRectangle(new Vector2d(3, 2), new Size2d(6, 4));

            Assert.True(rect.Contains(rect.Position));

            foreach (var vertex in rect.Corners())
            {
                Assert.True(rect.Contains(vertex));
            }

            Assert.False(rect.Contains(new Vector2d(-1, 0)));
            Assert.False(rect.Contains(rect.TopRight + 1));
            Assert.False(rect.Contains(rect.BotRight + 1));
            Assert.False(rect.Contains(rect.TopLeft - 1));
            Assert.False(rect.Contains(rect.BotLeft - 1));
        }
Beispiel #6
0
 public void Intersects(ref BoundingRectangle rect, out bool result)
 {
     Intersects(this.vertexes, rect.Corners(), out result);
 }
Beispiel #7
0
 public void Contains(ref BoundingRectangle rect, out ContainmentType result)
 {
     Contains(rect.Corners(), out result);
 }