Exemple #1
0
        /**
         * Test the getting the area of a self-intersecting polygon
         */
        [Test] public void testSelfIntersecting()
        {
            IPoly p = new PolyDefault();

            p.Add(6.0, 6.0);
            p.Add(2.0, 6.0);
            p.Add(2.0, 5.0);
            p.Add(4.0, 5.0);
            p.Add(4.0, 1.0);
            p.Add(2.0, 1.0);
            p.Add(2.0, 2.0);
            p.Add(1.0, 2.0);
            p.Add(1.0, 4.0);
            p.Add(2.0, 4.0);
            p.Add(2.0, 2.0);
            p.Add(3.0, 2.0);
            p.Add(3.0, 4.0);
            p.Add(2.0, 4.0);
            p.Add(2.0, 5.0);
            p.Add(0.0, 5.0);
            p.Add(0.0, 1.0);
            p.Add(2.0, 1.0);
            p.Add(2.0, 0.0);
            p.Add(6.0, 0.0);

            Assert.IsTrue(24.0 == p.GetArea());
        }
Exemple #2
0
        /**
         * Test the getting the area of a triangle
         */
        [Test] public void testAreaTriangle()
        {
            IPoly p = new PolyDefault();

            p.Add(0.0, 0.0);
            p.Add(2.0, 0.0);
            p.Add(2.0, 2.0);

            Assert.IsTrue(2.0 == p.GetArea());
        }
Exemple #3
0
        public void testAreaNonConvex()
        {
            IPoly p = new PolyDefault();
            p.Add( 0.0, 0.0 );
            p.Add( 0.0, 8.0 );
            p.Add( 6.0, 4.0 );
            p.Add( 4.0, 2.0 );
            p.Add( 2.0, 4.0 );

            Assert.IsTrue( 20.0 == p.GetArea() );
        }
Exemple #4
0
        /**
         * Test the getting the area of a non-convex polygon
         */
        [Test] public void testAreaNonConvex()
        {
            IPoly p = new PolyDefault();

            p.Add(0.0, 0.0);
            p.Add(0.0, 8.0);
            p.Add(6.0, 4.0);
            p.Add(4.0, 2.0);
            p.Add(2.0, 4.0);

            Assert.IsTrue(20.0 == p.GetArea());
        }
Exemple #5
0
        /**
         * Test the getting the area of a polygon with a hole
         */
        [Test] public void testAreaWithHole()
        {
            IPoly p1 = new PolyDefault();

            p1.Add(0.0, 0.0);
            p1.Add(4.0, 0.0);
            p1.Add(4.0, 4.0);
            p1.Add(0.0, 4.0);

            IPoly p2 = new PolyDefault(true);

            p2.Add(1.0, 1.0);
            p2.Add(3.0, 1.0);
            p2.Add(3.0, 3.0);
            p2.Add(1.0, 3.0);

            IPoly p = new PolyDefault();

            p.Add(p1);
            p.Add(p2);

            Assert.IsTrue(12.0 == p.GetArea());
        }
Exemple #6
0
        public void testAreaTriangle()
        {
            IPoly p = new PolyDefault();
            p.Add( 0.0, 0.0 );
            p.Add( 2.0, 0.0 );
            p.Add( 2.0, 2.0 );

            Assert.IsTrue( 2.0 == p.GetArea() );
        }
Exemple #7
0
        public void testSelfIntersecting()
        {
            IPoly p = new PolyDefault();
            p.Add( 6.0, 6.0 );
            p.Add( 2.0, 6.0 );
            p.Add( 2.0, 5.0 );
            p.Add( 4.0, 5.0 );
            p.Add( 4.0, 1.0 );
            p.Add( 2.0, 1.0 );
            p.Add( 2.0, 2.0 );
            p.Add( 1.0, 2.0 );
            p.Add( 1.0, 4.0 );
            p.Add( 2.0, 4.0 );
            p.Add( 2.0, 2.0 );
            p.Add( 3.0, 2.0 );
            p.Add( 3.0, 4.0 );
            p.Add( 2.0, 4.0 );
            p.Add( 2.0, 5.0 );
            p.Add( 0.0, 5.0 );
            p.Add( 0.0, 1.0 );
            p.Add( 2.0, 1.0 );
            p.Add( 2.0, 0.0 );
            p.Add( 6.0, 0.0 );

            Assert.IsTrue( 24.0 == p.GetArea() );
        }
Exemple #8
0
        public void testAreaWithHole()
        {
            IPoly p1 = new PolyDefault();
            p1.Add( 0.0, 0.0 );
            p1.Add( 4.0, 0.0 );
            p1.Add( 4.0, 4.0 );
            p1.Add( 0.0, 4.0 );

            IPoly p2 = new PolyDefault(true);
            p2.Add( 1.0, 1.0 );
            p2.Add( 3.0, 1.0 );
            p2.Add( 3.0, 3.0 );
            p2.Add( 1.0, 3.0 );

            IPoly p = new PolyDefault();
            p.Add( p1 );
            p.Add( p2 );

            Assert.IsTrue( 12.0 == p.GetArea() );
        }