Beispiel #1
0
        public void ContainsTopLeft()
        {
            var rect = new Rect2d(10, 10, 100, 100);

            Assert.True(rect.Contains(rect.TopLeft));
            Assert.True(rect.Contains(rect.Left, rect.Top));
        }
Beispiel #2
0
        public void DoNotContainsBottomRight()
        {
            var rect = new Rect2d(10, 10, 100, 100);

            Assert.False(rect.Contains(rect.BottomRight));
            Assert.False(rect.Contains(rect.Right, rect.Bottom));
        }
Beispiel #3
0
        public void ContainsRect()
        {
            var rect = new Rect2d(10, 10, 100, 100);

            Assert.True(rect.Contains(rect));
        }
Beispiel #4
0
        public void Contains()
        {
            var rect = new Rect2d(new Point2d(0, 0), new Size2d(3, 3));

            // OpenCV typically assumes that the top and left boundary of the rectangle are inclusive,
            // while the right and bottom boundaries are not. https://docs.opencv.org/2.4/modules/core/doc/basic_structures.html?highlight=rect

            Assert.False(rect.Contains(0, -1));
            Assert.False(rect.Contains(-1, 0));
            Assert.False(rect.Contains(-1, -1));

            Assert.True(rect.Contains(0, 0));
            Assert.True(rect.Contains(0, 1));
            Assert.True(rect.Contains(1, 0));
            Assert.True(rect.Contains(1, 1));

            Assert.True(rect.Contains(2, 0));
            Assert.True(rect.Contains(2, 1));
            Assert.True(rect.Contains(2, 2));
            Assert.True(rect.Contains(0, 2));
            Assert.True(rect.Contains(1, 2));
            Assert.True(rect.Contains(2, 2));

            Assert.False(rect.Contains(0, 3));
            Assert.False(rect.Contains(1, 3));
            Assert.False(rect.Contains(2, 3));
            Assert.False(rect.Contains(3, 3));
            Assert.False(rect.Contains(3, 0));
            Assert.False(rect.Contains(3, 1));
            Assert.False(rect.Contains(3, 2));
            Assert.False(rect.Contains(3, 3));
        }