Esempio n. 1
0
		public void TestOverlap2()
		{
			RECT r0 = new RECT( 10,0,10,10);
			RECT r1 = new RECT( 0,0,10,10);
			Assertion.Assert( r1.overlaps(r0) );
			Assertion.Assert( !r1.overlaps_interior(r0) );
		}
Esempio n. 2
0
		public void TestMidPoint()
		{
			RECT rA = new RECT(10,10,10,10);
			POINT mp = rA.midpoint();
			Assertion.AssertEquals( mp.x, 15.0 );
			Assertion.AssertEquals( mp.y, 15.0 );

		}
Esempio n. 3
0
		public void TestStructness()
		{
			RECT r0 = new RECT( 0,0,10,10);
			RECT r1 = r0;
			r1.x0 = 100;
			Assertion.Assert( !r0.Equals( r1)  );
			Assertion.AssertEquals( r0.x0 , 0 );
		}
Esempio n. 4
0
		public void TestOverlap1()
		{
			RECT r0 = new RECT( 0,0,10,10);
			RECT r1 = new RECT( 10,10,20,20);
			RECT r2 = new RECT( 11,11,20,20);
			RECT r3 = new RECT( 9.999,9.999,20,20);
			Assertion.Assert( r1.overlaps(r0) );
			Assertion.Assert( !r1.overlaps_interior(r0) );
			Assertion.Assert( !r2.overlaps(r0) );
			Assertion.Assert( r3.overlaps(r0) );
			Assertion.Assert( r3.overlaps_interior(r0) );
		}
Esempio n. 5
0
		public bool overlaps_interior( RECT r1 ) 
		{
			RECT r0=this;

			double x0,x1,y0,y1;
			r0.get_diagonal_points(out x0, out y0, out x1, out y1 );

			double x2,y2,x3,y3;
			r1.get_diagonal_points(out x2, out y2, out x3, out y3 );

			bool b = !(   
				( (x0<=x2) && (x1<=x2))
				|| ((x0>=x3) && (x1>=x3)) 
				|| ((y0<=y2) && (y1<=y2)) 
				|| ((y0>=y3) && (y1>=y3))   );

			return b;

		}
Esempio n. 6
0
		public void TestDecompose()
		{
			RECT rA = new RECT(0,0,10,10);
			RECT rB = new RECT(5,5,15,15);
			RECT rC = new RECT(50,50,10,10);

			RECT [] output = new RECT[4];

			int num_output_rects;

			num_output_rects = RECTTOOLS.decompose_overlapping( rA, rA , output );
			Assertion.AssertEquals( num_output_rects, 0 );

			num_output_rects = RECTTOOLS.decompose_overlapping( rA, rC , output );
			Assertion.AssertEquals( num_output_rects, 0 );

			num_output_rects = RECTTOOLS.decompose_overlapping( rA, rB , output );
			Assertion.AssertEquals( num_output_rects, 2 );

		}
Esempio n. 7
0
		public RECT intersection( RECT r1 )
		{
			double nx0 = System.Math.Max( this.x0, r1.x0 );
			double ny0 = System.Math.Max( this.y0, r1.y0 );
			double nx1 = System.Math.Min( this.x1, r1.x1 );
			double ny1 = System.Math.Min( this.y1, r1.y1 );
			return new RECT( nx0, ny0, nx1-nx0, ny1-ny0 );
		}
Esempio n. 8
0
		public bool contains( RECT B)
		{
			return ( (this.x0<=B.x0 ) && ( this.y0 <=B.y0 ) && ( B.x1<=this.x1 ) && ( B.y1<=this.y1) );
		}
Esempio n. 9
0
		public void TestIntersection()
		{
			RECT rA = new RECT(10,10,10,10);
			RECT rB = new RECT(0,0,30,30);
			RECT rC = new RECT(15,15,20,20);
			RECT rD = new RECT(0,0,15,15);
			RECT rI;

			rI = rA.intersection( rB );
			Assertion.AssertEquals( rI, rA );

			rI = rA.intersection( rC );
			Assertion.AssertEquals( rI, new RECT( 15,15,5,5 ) );

			rI = rA.intersection( rD );
			Assertion.AssertEquals( rI, new RECT( 10,10,5,5 ) );


		}
Esempio n. 10
0
		public void TestDX3()
		{
			RECT rA = new RECT(0,0,20,20);
			RECT rB = new RECT(-10,10,20,20);
			RECT [] ro = new RECT [4];

			int count = RECTTOOLS.decompose_overlapping( rA, rB, ro );

			Assertion.AssertEquals(2, count );
			Assertion.AssertEquals( new RECT(-10,10,10,10), ro[0] );
			Assertion.AssertEquals( new RECT(-10,20,20,10), ro[1] );
		}
Esempio n. 11
0
		public void TestArea4b()
		{
			RECT [] ra= new RECT[2];
			ra[0] = new RECT(0,0,400,400);
			ra[1] = new RECT(10,10,10,10);

			double area = RECTTOOLS.get_union_of_area( ra );
			Assertion.AssertEquals(( 400.0 * 400.0 ) , area );
		}
Esempio n. 12
0
		public void TestArea3()
		{
			RECT [] ra= new RECT[4];
			ra[0] = new RECT(10,10,10,10);
			ra[1]= new RECT(15,15,10,10);
			ra[2] = new RECT(15,15,2,2);
			ra[3] = new RECT(100,100,10,10);

			double area = RECTTOOLS.get_union_of_area( ra );
			Assertion.AssertEquals( ( 25*7.0 ) + 100, area);
		}
Esempio n. 13
0
		public void TestEquality()
		{
			RECT r0 = new RECT( 0,0,10,10);
			RECT r1 = r0;
			Assertion.AssertEquals( r0, r1 );
		}
Esempio n. 14
0
		public void TestDecomposeAll()
		{
			RECT [] ra= new RECT[2];
			ra[0] = new RECT(10,10,10,10);
			ra[1]= new RECT(15,15,10,10);

			double area = RECTTOOLS.get_union_of_area( ra );
			Assertion.AssertEquals( area, 25*7.0);
		}
Esempio n. 15
0
		public static void test()
		{

			RECT rA = new RECT(10,10,10,10);
			RECT rB = new RECT(0,0,30,30);
			RECT [] ro = new RECT [4];

			int count = RECTTOOLS.decompose_overlapping( rA, rB, ro );

			//Assertion.AssertEquals( 1 , count );



		}