Ejemplo n.º 1
0
        public void Test_R2Rect_AddPoint()
        {
            // AddPoint()
            R2Point sw1 = new(0, 0.25);
            R2Point ne1 = new(0.5, 0.75);
            R2Rect  r1  = new(sw1, ne1);

            R2Rect r2 = R2Rect.Empty;

            r2 = r2.AddPoint(new R2Point(0, 0.25));
            r2 = r2.AddPoint(new R2Point(0.5, 0.25));
            r2 = r2.AddPoint(new R2Point(0, 0.75));
            r2 = r2.AddPoint(new R2Point(0.1, 0.4));
            Assert.Equal(r1, r2);
        }
Ejemplo n.º 2
0
        private static void TestIntervalOps(R2Rect x, R2Rect y, string expected_rexion,
                                            R2Rect expected_union, R2Rect expected_intersection)
        {
            // Test all of the interval operations on the given pair of intervals.
            // "expected_rexion" is a sequence of "T" and "F" characters corresponding
            // to the expected results of Contains(), InteriorContains(), Intersects(),
            // and InteriorIntersects() respectively.

            Assert.Equal(expected_rexion[0] == 'T', x.Contains(y));
            Assert.Equal(expected_rexion[1] == 'T', x.InteriorContains(y));
            Assert.Equal(expected_rexion[2] == 'T', x.Intersects(y));
            Assert.Equal(expected_rexion[3] == 'T', x.InteriorIntersects(y));

            Assert.Equal(x.Union(y) == x, x.Contains(y));
            Assert.Equal(!x.Intersection(y).IsEmpty(), x.Intersects(y));

            Assert.Equal(expected_union, x.Union(y));
            Assert.Equal(expected_intersection, x.Intersection(y));

            R2Rect r = x;

            r = r.AddRect(y);
            Assert.Equal(expected_union, r);
            if (y.GetSize() == new R2Point(0, 0))
            {
                r = x;
                r = r.AddPoint(y.Lo());
                Assert.Equal(expected_union, r);
            }
        }