[Arakhnę-Dev] [419] * Add unit tests for the function of intersection test between a shape and a path (or a path iterator).

[ Thread Index | Date Index | More arakhne.org/dev Archives ]


Revision: 419
Author:   galland
Date:     2013-04-08 22:02:47 +0200 (Mon, 08 Apr 2013)
Log Message:
-----------
* Add unit tests for the function of intersection test between a shape and a path (or a path iterator).
* Fixing bugs in the intersection tests between a shape and a path (or a path iterator).

Modified Paths:
--------------
    trunk/math/src/main/java/org/arakhne/afc/math/continous/object2d/AbstractShape2f.java
    trunk/math/src/main/java/org/arakhne/afc/math/continous/object2d/Circle2f.java
    trunk/math/src/main/java/org/arakhne/afc/math/continous/object2d/Ellipse2f.java
    trunk/math/src/main/java/org/arakhne/afc/math/continous/object2d/Path2f.java
    trunk/math/src/main/java/org/arakhne/afc/math/continous/object2d/Rectangle2f.java
    trunk/math/src/main/java/org/arakhne/afc/math/continous/object2d/RoundRectangle2f.java
    trunk/math/src/main/java/org/arakhne/afc/math/continous/object2d/Segment2f.java
    trunk/math/src/test/java/org/arakhne/afc/math/continous/object2d/AbstractPath2fTestCase.java
    trunk/math/src/test/java/org/arakhne/afc/math/continous/object2d/AbstractShape2fTestCase.java
    trunk/math/src/test/java/org/arakhne/afc/math/continous/object2d/Circle2fTest.java
    trunk/math/src/test/java/org/arakhne/afc/math/continous/object2d/Ellipse2fTest.java
    trunk/math/src/test/java/org/arakhne/afc/math/continous/object2d/GeneratePictureForTest.java
    trunk/math/src/test/java/org/arakhne/afc/math/continous/object2d/Rectangle2fTest.java
    trunk/math/src/test/java/org/arakhne/afc/math/continous/object2d/RoundRectangle2fTest.java
    trunk/math/src/test/java/org/arakhne/afc/math/continous/object2d/Segment2fTest.java

Modified: trunk/math/src/main/java/org/arakhne/afc/math/continous/object2d/AbstractShape2f.java
===================================================================
--- trunk/math/src/main/java/org/arakhne/afc/math/continous/object2d/AbstractShape2f.java	2013-04-08 09:09:17 UTC (rev 418)
+++ trunk/math/src/main/java/org/arakhne/afc/math/continous/object2d/AbstractShape2f.java	2013-04-08 20:02:47 UTC (rev 419)
@@ -107,5 +107,5 @@
 	 */
     @Override
     public abstract int hashCode();
-
+    
 }
\ No newline at end of file

Modified: trunk/math/src/main/java/org/arakhne/afc/math/continous/object2d/Circle2f.java
===================================================================
--- trunk/math/src/main/java/org/arakhne/afc/math/continous/object2d/Circle2f.java	2013-04-08 09:09:17 UTC (rev 418)
+++ trunk/math/src/main/java/org/arakhne/afc/math/continous/object2d/Circle2f.java	2013-04-08 20:02:47 UTC (rev 419)
@@ -470,8 +470,10 @@
 	public boolean intersects(PathIterator2f s) {
 		int mask = (s.getWindingRule() == PathWindingRule.NON_ZERO ? -1 : 2);
 		int crossings = Path2f.computeCrossingsFromCircle(
-				getPathIterator(),
-				getX(), getY(), getRadius());
+				0,
+				s,
+				getX(), getY(), getRadius(),
+				false, true);
 		return (crossings == MathConstants.SHAPE_INTERSECTS ||
 				(crossings & mask) != 0);
 	}

Modified: trunk/math/src/main/java/org/arakhne/afc/math/continous/object2d/Ellipse2f.java
===================================================================
--- trunk/math/src/main/java/org/arakhne/afc/math/continous/object2d/Ellipse2f.java	2013-04-08 09:09:17 UTC (rev 418)
+++ trunk/math/src/main/java/org/arakhne/afc/math/continous/object2d/Ellipse2f.java	2013-04-08 20:02:47 UTC (rev 419)
@@ -485,8 +485,10 @@
 	public boolean intersects(PathIterator2f s) {
 		int mask = (s.getWindingRule() == PathWindingRule.NON_ZERO ? -1 : 2);
 		int crossings = Path2f.computeCrossingsFromEllipse(
-				getPathIterator(),
-				getMinX(), getMinY(), getWidth(), getHeight());
+				0,
+				s,
+				getMinX(), getMinY(), getWidth(), getHeight(),
+				false, true);
 		return (crossings == MathConstants.SHAPE_INTERSECTS ||
 				(crossings & mask) != 0);
 	}

Modified: trunk/math/src/main/java/org/arakhne/afc/math/continous/object2d/Path2f.java
===================================================================
--- trunk/math/src/main/java/org/arakhne/afc/math/continous/object2d/Path2f.java	2013-04-08 09:09:17 UTC (rev 418)
+++ trunk/math/src/main/java/org/arakhne/afc/math/continous/object2d/Path2f.java	2013-04-08 20:02:47 UTC (rev 419)
@@ -676,8 +676,7 @@
 						numCrosses,
 						x1, y1, x2, y2,
 						curx, cury,
-						endx, endy,
-						true);
+						endx, endy);
 				if (numCrosses==MathConstants.SHAPE_INTERSECTS)
 					return numCrosses;
 				curx = endx;
@@ -728,8 +727,7 @@
 							numCrosses,
 							x1, y1, x2, y2,
 							curx, cury,
-							movx, movy,
-							true);
+							movx, movy);
 				}
 				if (numCrosses!=0)	return numCrosses;
 				curx = movx;
@@ -749,8 +747,7 @@
 						numCrosses,
 						x1, y1, x2, y2,
 						curx, cury,
-						movx, movy,
-						true);
+						movx, movy);
 			}
 			else {
 				// Assume that when is the path is open, only

Modified: trunk/math/src/main/java/org/arakhne/afc/math/continous/object2d/Rectangle2f.java
===================================================================
--- trunk/math/src/main/java/org/arakhne/afc/math/continous/object2d/Rectangle2f.java	2013-04-08 09:09:17 UTC (rev 418)
+++ trunk/math/src/main/java/org/arakhne/afc/math/continous/object2d/Rectangle2f.java	2013-04-08 20:02:47 UTC (rev 419)
@@ -509,7 +509,7 @@
 	}
 
 	/** Compute the intersection of this rectangle and the given rectangle.
-	 * This function does not change this rectangle.
+	 * This function changes this rectangle.
 	 * <p>
 	 * It is equivalent to:
 	 * <pre><code>
@@ -609,8 +609,9 @@
 		if (isEmpty()) return false;
 		int mask = (s.getWindingRule() == PathWindingRule.NON_ZERO ? -1 : 2);
 		int crossings = Path2f.computeCrossingsFromRect(
-				getPathIterator(),
-				getMinX(), getMinY(), getMaxX(), getMaxY());
+				s,
+				getMinX(), getMinY(), getMaxX(), getMaxY(),
+				false, true);
 		return (crossings == MathConstants.SHAPE_INTERSECTS ||
 				(crossings & mask) != 0);
 	}

Modified: trunk/math/src/main/java/org/arakhne/afc/math/continous/object2d/RoundRectangle2f.java
===================================================================
--- trunk/math/src/main/java/org/arakhne/afc/math/continous/object2d/RoundRectangle2f.java	2013-04-08 09:09:17 UTC (rev 418)
+++ trunk/math/src/main/java/org/arakhne/afc/math/continous/object2d/RoundRectangle2f.java	2013-04-08 20:02:47 UTC (rev 419)
@@ -452,8 +452,9 @@
 		if (isEmpty()) return false;
 		int mask = (s.getWindingRule() == PathWindingRule.NON_ZERO ? -1 : 2);
 		int crossings = Path2f.computeCrossingsFromRect(
-				getPathIterator(),
-				getMinX(), getMinY(), getMaxX(), getMaxY());
+				s,
+				getMinX(), getMinY(), getMaxX(), getMaxY(),
+				false, true);
 		return (crossings == MathConstants.SHAPE_INTERSECTS ||
 				(crossings & mask) != 0);
 	}

Modified: trunk/math/src/main/java/org/arakhne/afc/math/continous/object2d/Segment2f.java
===================================================================
--- trunk/math/src/main/java/org/arakhne/afc/math/continous/object2d/Segment2f.java	2013-04-08 09:09:17 UTC (rev 418)
+++ trunk/math/src/main/java/org/arakhne/afc/math/continous/object2d/Segment2f.java	2013-04-08 20:02:47 UTC (rev 419)
@@ -77,6 +77,9 @@
 	 * If the point lies on the line, then no crossings are recorded.
 	 * +1 is returned for a crossing where the Y coordinate is increasing
 	 * -1 is returned for a crossing where the Y coordinate is decreasing
+	 * <p>
+	 * This function differs from {@link #computeCrossingsFromPoint(float, float, float, float, float, float)}.
+	 * The equality test is not used in this function.
 	 * 
 	 * @param px is the reference point to test.
 	 * @param py is the reference point to test.
@@ -86,12 +89,14 @@
 	 * @param y1 is the secondpoint of the line.
 	 * @return the crossing.
 	 */
-	static int computeCrossingsFromPoint1(
+	private static int computeCrossingsFromPoint1(
 			float px, float py,
 			float x0, float y0,
 			float x1, float y1) {
+		// Copied from AWT API
 		if (py <  y0 && py <  y1) return 0;
 		if (py > y0 && py > y1) return 0;
+		// assert(y0 != y1);
 		if (px > x0 && px > x1) return 0;
 		if (px <  x0 && px <  x1) return (y0 < y1) ? 1 : -1;
 		float xintercept = x0 + (py - y0) * (x1 - x0) / (y1 - y0);
@@ -120,32 +125,6 @@
 			float sx2, float sy2,
 			float x0, float y0,
 			float x1, float y1) {
-		return computeCrossingsFromSegment(crossings, sx1, sy1, sx2, sy2, x0, y0, x1, y1, false);
-	}
-	
-	/**
-	 * Calculates the number of times the line from (x0,y0) to (x1,y1)
-	 * crosses the segment (sx0,sy0) to (sx1,sy1) extending to the right.
-	 * 
-	 * @param crossings is the initial value for the number of crossings.
-	 * @param sx1 is the first point of the segment to extend.
-	 * @param sy1 is the first point of the segment to extend.
-	 * @param sx2 is the second point of the segment to extend.
-	 * @param sy2 is the second point of the segment to extend.
-	 * @param x0 is the first point of the line.
-	 * @param y0 is the first point of the line.
-	 * @param x1 is the second point of the line.
-	 * @param y1 is the secondpoint of the line.
-	 * @param linesAreCrossing indicates if the shadow lines are crossing.
-	 * @return the crossing, or {@link MathConstants#SHAPE_INTERSECTS}
-	 */
-	static int computeCrossingsFromSegment(
-			int crossings,
-			float sx1, float sy1,
-			float sx2, float sy2,
-			float x0, float y0,
-			float x1, float y1,
-			boolean linesAreCrossing) {
 		int numCrosses = crossings;
 
 		float xmin = Math.min(sx1, sx2);
@@ -181,16 +160,16 @@
 				side2 = MathUtil.sidePointLine(sx2, sy2, sx1, sy1, x1, y1, false);
 			}
 			if (side1>0 || side2>0) {
-				int n1, n2;
-				if (linesAreCrossing) {
-					n1 = computeCrossingsFromPoint1(sx1, sy1, x0, y0, x1, y1);
+				int n1 = computeCrossingsFromPoint(sx1, sy1, x0, y0, x1, y1);
+				int n2;
+				if (n1!=0) {
 					n2 = computeCrossingsFromPoint1(sx2, sy2, x0, y0, x1, y1);
 				}
 				else {
-					n1 = computeCrossingsFromPoint(sx1, sy1, x0, y0, x1, y1);
 					n2 = computeCrossingsFromPoint(sx2, sy2, x0, y0, x1, y1);
 				}
-				numCrosses += n1 + n2;
+				numCrosses += n1;
+				numCrosses += n2;
 			}
 		}
 
@@ -952,8 +931,10 @@
 	public boolean intersects(PathIterator2f s) {
 		int mask = (s.getWindingRule() == PathWindingRule.NON_ZERO ? -1 : 2);
 		int crossings = Path2f.computeCrossingsFromSegment(
-				getPathIterator(),
-				getX1(), getY1(), getX2(), getY2());
+				0,
+				s,
+				getX1(), getY1(), getX2(), getY2(),
+				false);
 		return (crossings == MathConstants.SHAPE_INTERSECTS ||
 				(crossings & mask) != 0);
 	}

Modified: trunk/math/src/test/java/org/arakhne/afc/math/continous/object2d/AbstractPath2fTestCase.java
===================================================================
--- trunk/math/src/test/java/org/arakhne/afc/math/continous/object2d/AbstractPath2fTestCase.java	2013-04-08 09:09:17 UTC (rev 418)
+++ trunk/math/src/test/java/org/arakhne/afc/math/continous/object2d/AbstractPath2fTestCase.java	2013-04-08 20:02:47 UTC (rev 419)
@@ -138,14 +138,6 @@
 
 	/**
 	 */
-	public abstract void testIntersectsPath2f();
-
-	/**
-	 */
-	public abstract void testIntersectsPathIterator2f();
-	
-	/**
-	 */
 	public abstract void testIntersectsPathIterator2fFloatFloatFloatFloat();
 	
 	/**

Modified: trunk/math/src/test/java/org/arakhne/afc/math/continous/object2d/AbstractShape2fTestCase.java
===================================================================
--- trunk/math/src/test/java/org/arakhne/afc/math/continous/object2d/AbstractShape2fTestCase.java	2013-04-08 09:09:17 UTC (rev 418)
+++ trunk/math/src/test/java/org/arakhne/afc/math/continous/object2d/AbstractShape2fTestCase.java	2013-04-08 20:02:47 UTC (rev 419)
@@ -149,4 +149,12 @@
 	 */
 	public abstract void testClear();
 
+	/**
+	 */
+	public abstract void testIntersectsPath2f();
+
+	/**
+	 */
+	public abstract void testIntersectsPathIterator2f();
+	
 }
\ No newline at end of file

Modified: trunk/math/src/test/java/org/arakhne/afc/math/continous/object2d/Circle2fTest.java
===================================================================
--- trunk/math/src/test/java/org/arakhne/afc/math/continous/object2d/Circle2fTest.java	2013-04-08 09:09:17 UTC (rev 418)
+++ trunk/math/src/test/java/org/arakhne/afc/math/continous/object2d/Circle2fTest.java	2013-04-08 20:02:47 UTC (rev 419)
@@ -456,5 +456,117 @@
 		this.r.setRadius(-7.8f);
 		assertEpsilonEquals(7.8f, this.r.getRadius());
 	}
+	
+	/**
+	 */
+	@Override
+	public void testIntersectsPath2f() {
+		Path2f p;
 
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(-2f, 2f);
+		p.lineTo(2f, 2f);
+		p.lineTo(2f, -2f);
+		assertFalse(this.r.intersects(p));
+		p.closePath();
+		assertTrue(this.r.intersects(p));
+		
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(0f, 0f);
+		p.lineTo(-2f, 2f);
+		assertTrue(this.r.intersects(p));
+		p.closePath();
+		assertTrue(this.r.intersects(p));
+
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(2f, 2f);
+		p.lineTo(-2f, 2f);
+		assertTrue(this.r.intersects(p));
+		p.closePath();
+		assertTrue(this.r.intersects(p));
+
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(-2f, 2f);
+		p.lineTo(2f, -2f);
+		assertTrue(this.r.intersects(p));
+		p.closePath();
+		assertTrue(this.r.intersects(p));
+
+		p = new Path2f();
+		p.moveTo(-2f, 2f);
+		p.lineTo(1f, 0f);
+		p.lineTo(2f, 1f);
+		assertTrue(this.r.intersects(p));
+		p.closePath();
+		assertTrue(this.r.intersects(p));
+
+		p = new Path2f();
+		p.moveTo(-2f, 2f);
+		p.lineTo(2f, 1f);
+		p.lineTo(1f, 0f);
+		assertFalse(this.r.intersects(p));
+		p.closePath();
+		assertTrue(this.r.intersects(p));
+	}
+
+	/**
+	 */
+	@Override
+	public void testIntersectsPathIterator2f() {
+		Path2f p;
+
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(-2f, 2f);
+		p.lineTo(2f, 2f);
+		p.lineTo(2f, -2f);
+		assertFalse(this.r.intersects(p.getPathIterator()));
+		p.closePath();
+		assertTrue(this.r.intersects(p.getPathIterator()));
+		
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(0f, 0f);
+		p.lineTo(-2f, 2f);
+		assertTrue(this.r.intersects(p.getPathIterator()));
+		p.closePath();
+		assertTrue(this.r.intersects(p.getPathIterator()));
+
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(2f, 2f);
+		p.lineTo(-2f, 2f);
+		assertTrue(this.r.intersects(p.getPathIterator()));
+		p.closePath();
+		assertTrue(this.r.intersects(p.getPathIterator()));
+
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(-2f, 2f);
+		p.lineTo(2f, -2f);
+		assertTrue(this.r.intersects(p.getPathIterator()));
+		p.closePath();
+		assertTrue(this.r.intersects(p.getPathIterator()));
+
+		p = new Path2f();
+		p.moveTo(-2f, 2f);
+		p.lineTo(1f, 0f);
+		p.lineTo(2f, 1f);
+		assertTrue(this.r.intersects(p.getPathIterator()));
+		p.closePath();
+		assertTrue(this.r.intersects(p.getPathIterator()));
+
+		p = new Path2f();
+		p.moveTo(-2f, 2f);
+		p.lineTo(2f, 1f);
+		p.lineTo(1f, 0f);
+		assertFalse(this.r.intersects(p.getPathIterator()));
+		p.closePath();
+		assertTrue(this.r.intersects(p.getPathIterator()));
+	}
+
 }
\ No newline at end of file

Modified: trunk/math/src/test/java/org/arakhne/afc/math/continous/object2d/Ellipse2fTest.java
===================================================================
--- trunk/math/src/test/java/org/arakhne/afc/math/continous/object2d/Ellipse2fTest.java	2013-04-08 09:09:17 UTC (rev 418)
+++ trunk/math/src/test/java/org/arakhne/afc/math/continous/object2d/Ellipse2fTest.java	2013-04-08 20:02:47 UTC (rev 419)
@@ -529,4 +529,120 @@
 				0f, 0f, 1f, 2f, .5f, -1f, .5f, -.5f));
 	}
 	
+	/**
+	 */
+	@Override
+	public void testIntersectsPath2f() {
+		Path2f p;
+
+		this.r.set(0f, 0f, 1.1f, 1f);
+		
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(-2f, 2f);
+		p.lineTo(2f, 2f);
+		p.lineTo(2f, -2f);
+		assertFalse(this.r.intersects(p));
+		p.closePath();
+		assertTrue(this.r.intersects(p));
+		
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(0f, 0f);
+		p.lineTo(-2f, 2f);
+		assertFalse(this.r.intersects(p));
+		p.closePath();
+		assertFalse(this.r.intersects(p));
+
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(2f, 2f);
+		p.lineTo(-2f, 2f);
+		assertTrue(this.r.intersects(p));
+		p.closePath();
+		assertTrue(this.r.intersects(p));
+
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(-2f, 2f);
+		p.lineTo(2f, -2f);
+		assertFalse(this.r.intersects(p));
+		p.closePath();
+		assertFalse(this.r.intersects(p));
+
+		p = new Path2f();
+		p.moveTo(-2f, 2f);
+		p.lineTo(1f, 0f);
+		p.lineTo(2f, 1f);
+		assertTrue(this.r.intersects(p));
+		p.closePath();
+		assertTrue(this.r.intersects(p));
+
+		p = new Path2f();
+		p.moveTo(-2f, 2f);
+		p.lineTo(2f, 1f);
+		p.lineTo(1f, 0f);
+		assertFalse(this.r.intersects(p));
+		p.closePath();
+		assertTrue(this.r.intersects(p));
+	}
+
+	/**
+	 */
+	@Override
+	public void testIntersectsPathIterator2f() {
+		Path2f p;
+
+		this.r.set(0f, 0f, 1.1f, 1f);
+		
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(-2f, 2f);
+		p.lineTo(2f, 2f);
+		p.lineTo(2f, -2f);
+		assertFalse(this.r.intersects(p.getPathIterator()));
+		p.closePath();
+		assertTrue(this.r.intersects(p.getPathIterator()));
+		
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(0f, 0f);
+		p.lineTo(-2f, 2f);
+		assertFalse(this.r.intersects(p.getPathIterator()));
+		p.closePath();
+		assertFalse(this.r.intersects(p.getPathIterator()));
+
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(2f, 2f);
+		p.lineTo(-2f, 2f);
+		assertTrue(this.r.intersects(p.getPathIterator()));
+		p.closePath();
+		assertTrue(this.r.intersects(p.getPathIterator()));
+
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(-2f, 2f);
+		p.lineTo(2f, -2f);
+		assertFalse(this.r.intersects(p.getPathIterator()));
+		p.closePath();
+		assertFalse(this.r.intersects(p.getPathIterator()));
+
+		p = new Path2f();
+		p.moveTo(-2f, 2f);
+		p.lineTo(1f, 0f);
+		p.lineTo(2f, 1f);
+		assertTrue(this.r.intersects(p.getPathIterator()));
+		p.closePath();
+		assertTrue(this.r.intersects(p.getPathIterator()));
+
+		p = new Path2f();
+		p.moveTo(-2f, 2f);
+		p.lineTo(2f, 1f);
+		p.lineTo(1f, 0f);
+		assertFalse(this.r.intersects(p.getPathIterator()));
+		p.closePath();
+		assertTrue(this.r.intersects(p.getPathIterator()));
+	}
+
 }
\ No newline at end of file

Modified: trunk/math/src/test/java/org/arakhne/afc/math/continous/object2d/GeneratePictureForTest.java
===================================================================
--- trunk/math/src/test/java/org/arakhne/afc/math/continous/object2d/GeneratePictureForTest.java	2013-04-08 09:09:17 UTC (rev 418)
+++ trunk/math/src/test/java/org/arakhne/afc/math/continous/object2d/GeneratePictureForTest.java	2013-04-08 20:02:47 UTC (rev 419)
@@ -44,116 +44,73 @@
  */
 public class GeneratePictureForTest extends TestCase {
 
-	private static final boolean GENERATE_TESTING_PICTURE = false;
+	private static final boolean GENERATE_TESTING_PICTURE = true;
 	
-	private Path2f r1;
-	private Path2f r2;
-	private Path2f r3;
-	private Path2f r4;
-	private Path2f r5;
-	private Path2f r6;
-	private Path2f r7;
-	private Path2f r8;
-		
+	private static final float CELL_SIZE = 100;
+
+	private Path2f[] paths;
+	private Point2f[] points;
+	private Segment2f[] lines;
+	private Segment2f[] segments;
+	private Circle2f[] circles;
+	private Rectangle2f[] rectangles;
+	private Ellipse2f[] ellipses;
+
 	@Override
 	protected void setUp() throws Exception {
 		super.setUp();
-		
-		this.r1 = new Path2f();
-		this.r1.moveTo(1f, 1f);
-		this.r1.lineTo(2f, 2f);
-		this.r1.quadTo(3f, 0f, 4f, 3f);
-		this.r1.curveTo(5f, -1f, 6f, 5f, 7f, -5f);
+		//
+		// PATHS
+		Path2f r0 = new Path2f();
+		r0.moveTo(1f, 1f);
+		r0.lineTo(2f, 2f);
+		r0.quadTo(3f, 0f, 4f, 3f);
+		r0.curveTo(5f, -1f, 6f, 5f, 7f, -5f);
 
-		this.r2 = new Path2f();
-		this.r2.moveTo(2f, 1f);
-		this.r2.lineTo(4f, 0f);
-		this.r2.quadTo(5f, -2f, 2f, -3f);
-		this.r2.closePath();
-		
-		this.r3 = new Path2f();
-		this.r3.moveTo(5f, 0f);
-		this.r3.lineTo(6f, 2f);
-		this.r3.lineTo(7f, 1f);
-		this.r3.closePath();
+		Path2f r1 = new Path2f();
+		r1.moveTo(-2f, -2f);
+		r1.lineTo(-2f, 2f);
+		r1.lineTo(2f, 2f);
+		r1.lineTo(2f, -2f);
 
-		this.r4 = new Path2f();
-		this.r4.moveTo(1f, 2f);
-		this.r4.lineTo(0f, 1f);
-		this.r4.lineTo(3f, 0f);
+		Path2f r2 = new Path2f();
+		r2.moveTo(-2f, -2f);
+		r2.lineTo(0f, 0f);
+		r2.lineTo(-2f, 2f);
 
-		this.r5 = new Path2f();
-		this.r5.moveTo(3f, 0f);
-		this.r5.lineTo(4f, 1f);
-		this.r5.lineTo(5f, -2f);
-		this.r5.closePath();
+		Path2f r3 = new Path2f();
+		r3.moveTo(-2f, -2f);
+		r3.lineTo(2f, 2f);
+		r3.lineTo(-2f, 2f);
 
-		this.r6 = new Path2f();
-		this.r6.moveTo(4f, 4f);
-		this.r6.lineTo(0f, 2f);
-		this.r6.lineTo(2f, -3f);
-		this.r6.lineTo(7f, -6f);
-		this.r6.lineTo(8f, 0f);
+		Path2f r4 = new Path2f();
+		r4.moveTo(-2f, -2f);
+		r4.lineTo(-2f, 2f);
+		r4.lineTo(2f, -2f);
 
-		this.r7 = new Path2f();
-		this.r7.moveTo(4f, 4f);
-		this.r7.lineTo(0f, 2f);
-		this.r7.lineTo(2f, -3f);
-		this.r7.lineTo(7f, -6f);
-		this.r7.lineTo(8f, 0f);
-		this.r7.closePath();
+		Path2f r5 = new Path2f();
+		r5.moveTo(-2f, 2f);
+		r5.lineTo(1f, 0f);
+		r5.lineTo(2f, 1f);
 
-		this.r8 = new Path2f();
-		this.r8.moveTo(0f, -5f);
-		this.r8.lineTo(1f, -3f);
-		this.r8.lineTo(2f, -6f);
-		this.r8.closePath();
-	}
-	
-	@Override
-	protected void tearDown() throws Exception {
-		this.r2 = this.r3 = this.r4 = null;
-		this.r5 = this.r6 = this.r7 = null;
-		this.r8 = null;
-		super.tearDown();
-	}
+		Path2f r6 = new Path2f();
+		r6.moveTo(-2f, 2f);
+		r6.lineTo(2f, 1f);
+		r6.lineTo(1f, 0f);
 
-	private static int toX(float x) {
-		return (int)(x * 100) + 20;
-	}
-
-	private static int toY(float y) {
-		return (int)(1000 - ((y * 100) + 600));
-	}
-
-	private static int toS(float s) {
-		return (int)(s * 100);
-	}
-
-	public void testImageGeneration() throws IOException {
-		PathIterator2f pi;
-		BufferedImage img = new BufferedImage(800, 1000, BufferedImage.TYPE_INT_ARGB);
-		Graphics2D g = (Graphics2D)img.getGraphics();
-		//Background
-		g.setColor(Color.WHITE);
-		g.fillRect(0, 0, 800, 1000);
-
-		//
-		// PATHS
-		Path2f[] paths = new Path2f[] {
-				this.r1,
-				this.r2,
-				this.r3,
-				this.r4,
-				this.r5,
-				this.r6,
-				this.r7,
-				this.r8,
+		this.paths = new Path2f[] {
+//				r0,
+//				r1,
+//				r2,
+//				r3,
+//				r4,
+//				r5,
+//				r6,
 		};
 
 		//
 		// POINTS
-		Point2f[] points = new Point2f[] {
+		this.points = new Point2f[] {
 				//				new Point2f(0f, 0f),
 				//				new Point2f(4f, 3f),
 				//				new Point2f(2f, 2f),
@@ -168,17 +125,20 @@
 
 		//
 		// LINES
-		Segment2f[] lines = new Segment2f[] {
+		this.lines = new Segment2f[] {
 				//new Segment2f(6.7773438f, -3.0272121f, 6.7890625f, -3.1188917f),
 				//new Segment2f(6.7890625f, -3.1188917f, 6.8007812f, -3.2118688f),
 				//new Segment2f(6.8007812f, -3.2118688f, 6.8125f, -3.3061523f),
 				//new Segment2f(6.9414062f, -4.4321795f, 6.953125f, -4.5428696f),
 				//new Segment2f(.5f, -1f, .5f, 2f),
+				//new Segment2f(4f, -3f, 1f, 1f),
 		};
 
 		//
 		// SEGMENTS
-		Segment2f[] segments = new Segment2f[] {
+		this.segments = new Segment2f[] {
+				new Segment2f(4f, -3f, 1f, 1f),
+				new Segment2f(7f, -5f, 1f, 1f),
 				//				new Segment2f(0f, 0f, 1f, 1f),
 				//				new Segment2f(4f, 3f, 1f, 1f),
 				//				new Segment2f(2f, 2f, 1f, 1f),
@@ -198,8 +158,8 @@
 
 		//
 		// CIRCLES
-		Circle2f[] circles = new Circle2f[] {
-				//				new Circle2f(0f, 0f, 1f),
+		this.circles = new Circle2f[] {
+				//new Circle2f(0f, 0f, 1f),
 				//				new Circle2f(4f, 3f, 1f),
 				//				new Circle2f(2f, 2f, 1f),
 				//				new Circle2f(2f, 1f, 1f),
@@ -217,24 +177,25 @@
 
 		//
 		// RECTANGLES
-		Rectangle2f[] rectangles = new Rectangle2f[] {
-//				new Rectangle2f(0f, 0f, 1f, 1f),
-//				new Rectangle2f(4f, 3f, 1f, 1f),
-//				new Rectangle2f(2f, 2f, 1f, 1f),
-//				new Rectangle2f(2f, 1f, 1f, 1f),
-//				new Rectangle2f(3f, 0f, 1f, 1f),
-//				new Rectangle2f(-1f, -1f, 1f, 1f),
-//				new Rectangle2f(4f, -3f, 1f, 1f),
-//				new Rectangle2f(-3f, 4f, 1f, 1f),
-//				new Rectangle2f(6f, -5f, 1f, 1f),
-//				new Rectangle2f(4f, 0f, 1f, 1f),
-//				new Rectangle2f(5f, 0f, 1f, 1f),
-//				new Rectangle2f(.01f, .01f, 1f, 1f),
+		this.rectangles = new Rectangle2f[] {
+				//				new Rectangle2f(0f, 0f, 1f, 1f),
+				//				new Rectangle2f(4f, 3f, 1f, 1f),
+				//				new Rectangle2f(2f, 2f, 1f, 1f),
+				//				new Rectangle2f(2f, 1f, 1f, 1f),
+				//				new Rectangle2f(3f, 0f, 1f, 1f),
+				//				new Rectangle2f(-1f, -1f, 1f, 1f),
+				//				new Rectangle2f(4f, -3f, 1f, 1f),
+				//				new Rectangle2f(-3f, 4f, 1f, 1f),
+				//				new Rectangle2f(6f, -5f, 1f, 1f),
+				//				new Rectangle2f(4f, 0f, 1f, 1f),
+				//				new Rectangle2f(5f, 0f, 1f, 1f),
+				//				new Rectangle2f(.01f, .01f, 1f, 1f),
 		};
 
 		//
 		// ELLIPSES
-		Ellipse2f[] ellipses = new Ellipse2f[] {
+		this.ellipses = new Ellipse2f[] {
+				//				new Ellipse2f(0f, 0f, 1.1f, 1f),
 				//				new Ellipse2f(0f, 0f, 1f, 2f),
 				//				new Ellipse2f(4f, 3f, 1f, 2f),
 				//				new Ellipse2f(2f, 2f, 1f, 2f),
@@ -249,19 +210,143 @@
 				//				new Ellipse2f(6f, 0f, 1f, 2f),
 		};
 
+	}
+	
+	private static int toX(float x, Rectangle2f doc) {
+		return (int)((x - doc.getMinX()) * CELL_SIZE);
+	}
+
+	private static int toY(float y, Rectangle2f doc) {
+		return (int)((doc.getMaxY() - y) * CELL_SIZE);
+	}
+
+	private static int toS(float s) {
+		return (int)(s * CELL_SIZE);
+	}
+
+	public void testImageGeneration() throws IOException {
+		PathIterator2f pi;
+
+		// Compute the bounds
+		Rectangle2f docBounds = new Rectangle2f();
+		boolean isset = false;
+		for(Point2f obj : this.points) {
+			if (isset)
+				docBounds.add(obj.getX(), obj.getY());
+			else {
+				docBounds.set(obj.getX(), obj.getY(), 0, 0);
+				isset = true;
+			}
+		}
+		for(Path2f obj : this.paths) {
+			Rectangle2f bb = obj.toBoundingBox();
+			if (isset) {
+				docBounds.setUnion(bb);
+			}
+			else {
+				docBounds.set(bb);
+				isset = true;
+			}
+		}
+		for(Segment2f obj : this.lines) {
+			float xx1 = obj.getX1();
+			float yy1 = obj.getY1();
+			float xx2 = obj.getX2();
+			float yy2 = obj.getY2();
+			if (isset) {
+				Rectangle2f r = new Rectangle2f();
+				r.setFromCorners(xx1, yy1, xx2, yy2);
+				docBounds.setUnion(r);
+			}
+			else {
+				docBounds.setFromCorners(xx1, yy1, xx2, yy2);
+				isset = true;
+			}
+		}
+		for(Segment2f obj : this.segments) {
+			float xx1 = obj.getX1();
+			float yy1 = obj.getY1();
+			float xx2 = obj.getX2();
+			float yy2 = obj.getY2();
+			if (isset) {
+				Rectangle2f r = new Rectangle2f();
+				r.setFromCorners(xx1, yy1, xx2, yy2);
+				docBounds.setUnion(r);
+			}
+			else {
+				docBounds.setFromCorners(xx1, yy1, xx2, yy2);
+				isset = true;
+			}
+		}
+		for(Circle2f obj : this.circles) {
+			float xx = obj.getX();
+			float yy = obj.getY();
+			float r = obj.getRadius();
+			if (isset) {
+				Rectangle2f rect = new Rectangle2f();
+				rect.setFromCorners(xx-r, yy-r, xx+r, yy+r);
+				docBounds.setUnion(rect);
+			}
+			else {
+				docBounds.setFromCorners(xx-r, yy-r, xx+r, yy+r);
+				isset = true;
+			}
+		}
+		for(Ellipse2f obj : this.ellipses) {
+			float x1 = obj.getMinX();
+			float y1 = obj.getMinY();
+			float x2 = obj.getMaxX();
+			float y2 = obj.getMaxY();
+			if (isset) {
+				Rectangle2f rect = new Rectangle2f();
+				rect.setFromCorners(x1, y1, x2, y2);
+				docBounds.setUnion(rect);
+			}
+			else {
+				docBounds.setFromCorners(x1, y1, x2, y2);
+				isset = true;
+			}
+		}
+		for(Rectangle2f obj : this.rectangles) {
+			float x1 = obj.getMinX();
+			float y1 = obj.getMinY();
+			float x2 = obj.getMaxX();
+			float y2 = obj.getMaxY();
+			if (isset) {
+				Rectangle2f rect = new Rectangle2f();
+				rect.setFromCorners(x1, y1, x2, y2);
+				docBounds.setUnion(rect);
+			}
+			else {
+				docBounds.setFromCorners(x1, y1, x2, y2);
+				isset = true;
+			}
+		}
+		docBounds.inflate(2, 2, 2, 2);
+		
+		// Create the image
+		BufferedImage img = new BufferedImage(
+				toS(docBounds.getWidth()), 
+				toS(docBounds.getHeight()),
+				BufferedImage.TYPE_INT_ARGB);
+		Graphics2D g = (Graphics2D)img.getGraphics();
+		//Background
+		g.setColor(Color.WHITE);
+		g.fillRect(0, 0, img.getWidth(), img.getHeight());
+
 		// Elements
 		g.setColor(Color.ORANGE);
-		for(Point2f obj : points) {
+		for(Point2f obj : this.points) {
 			g.fillRect(
-					toX(obj.getX()) - 4, toY(obj.getY()) - 4,
+					toX(obj.getX(), docBounds) - 4, toY(obj.getY(), docBounds) - 4,
 					9, 9);
 		}
 		Stroke oldStroke = g.getStroke();
-		for(Segment2f obj : lines) {
-			int xx1 = toX(obj.getX1());
-			int yy1 = toY(obj.getY1());
-			int xx2 = toX(obj.getX2());
-			int yy2 = toY(obj.getY2());
+		for(Segment2f obj : this.lines) {
+			int xx1 = toX(obj.getX1(), docBounds);
+			int yy1 = toY(obj.getY1(), docBounds);
+			int xx2 = toX(obj.getX2(), docBounds);
+			int yy2 = toY(obj.getY2(), docBounds);
 
 			g.setStroke(new BasicStroke(2));
 			Vector2f v = new Vector2f(xx2 - xx1, yy2 - yy1);
@@ -277,32 +362,32 @@
 			g.drawLine(xx1, yy1, xx2, yy2);
 		}
 		g.setStroke(new BasicStroke(3));
-		for(Segment2f obj : segments) {
+		for(Segment2f obj : this.segments) {
 			g.drawLine(
-					toX(obj.getX1()), toY(obj.getY1()),
-					toX(obj.getX2()), toY(obj.getY2()));
+					toX(obj.getX1(), docBounds), toY(obj.getY1(), docBounds),
+					toX(obj.getX2(), docBounds), toY(obj.getY2(), docBounds));
 		}
 		g.setStroke(oldStroke);
-		for(Circle2f obj : circles) {
+		for(Circle2f obj : this.circles) {
 			int r = toS(obj.getRadius());
 			g.drawOval(
-					toX(obj.getX())-r, toY(obj.getY())-r,
+					toX(obj.getX(), docBounds)-r, toY(obj.getY(), docBounds)-r,
 					r*2, r*2);
 		}
-		for(Ellipse2f obj : ellipses) {
-			int x1 = toX(obj.getMinX());
-			int y1 = toY(obj.getMinY());
-			int x2 = toX(obj.getMaxX());
-			int y2 = toY(obj.getMaxY());
+		for(Ellipse2f obj : this.ellipses) {
+			int x1 = toX(obj.getMinX(), docBounds);
+			int y1 = toY(obj.getMinY(), docBounds);
+			int x2 = toX(obj.getMaxX(), docBounds);
+			int y2 = toY(obj.getMaxY(), docBounds);
 			g.drawOval(
 					Math.min(x1, x2), Math.min(y1, y2),
 					toS(obj.getWidth()), toS(obj.getHeight()));
 		}
-		for(Rectangle2f obj : rectangles) {
-			int x1 = toX(obj.getMinX());
-			int y1 = toY(obj.getMinY());
-			int x2 = toX(obj.getMaxX());
-			int y2 = toY(obj.getMaxY());
+		for(Rectangle2f obj : this.rectangles) {
+			int x1 = toX(obj.getMinX(), docBounds);
+			int y1 = toY(obj.getMinY(), docBounds);
+			int x2 = toX(obj.getMaxX(), docBounds);
+			int y2 = toY(obj.getMaxY(), docBounds);
 			g.fillRect(
 					Math.min(x1, x2), Math.min(y1, y2),
 					toS(obj.getWidth()), toS(obj.getHeight()));
@@ -310,22 +395,41 @@
 
 		// Cells
 		g.setColor(Color.LIGHT_GRAY);
-		for(float y=-6; y<=4; y+=1) {
-			if (y!=0f) g.drawLine(toX(-10), toY(y), toX(10), toY(y));
+		int minXpixel = toX(docBounds.getMinX(), docBounds);
+		int minYpixel = toY(docBounds.getMinY(), docBounds);
+		int maxXpixel = toX(docBounds.getMaxX(), docBounds);
+		int maxYpixel = toY(docBounds.getMaxY(), docBounds);
+		if (minXpixel>maxXpixel) {
+			int t = minXpixel;
+			minXpixel = maxXpixel;
+			maxXpixel = t;
 		}
-		for(float x=-1; x<=8; x+=1) {
-			if (x!=0f) g.drawLine(toX(x), toY(-10), toX(x), toY(10));
+		if (minYpixel>maxYpixel) {
+			int t = minYpixel;
+			minYpixel = maxYpixel;
+			maxYpixel = t;
 		}
+		for(int y=minYpixel; y<=maxYpixel; y+=CELL_SIZE) {
+			g.drawLine(minXpixel, y, maxXpixel, y);
+		}
+		for(int x=minXpixel; x<=maxXpixel; x+=CELL_SIZE) {
+			g.drawLine(x, minYpixel, x, maxYpixel);
+		}
 		g.setColor(Color.BLACK);
-		g.drawLine(toX(-10), toY(0), toX(10), toY(0));
-		g.drawLine(toX(0), toY(-10), toX(0), toY(10));
+		int xzero = toX(0, docBounds);
+		int yzero = toY(0, docBounds);
+		g.drawLine(minXpixel, yzero, maxXpixel, yzero);
+		g.drawLine(xzero, minYpixel, xzero, maxYpixel);
+		g.fillOval(xzero-3, yzero-3, 7, 7);
+		g.fillOval(xzero-3, toY(1, docBounds)-3, 7, 7);
+		g.fillOval(toX(1, docBounds)-3, yzero-3, 7, 7);
 
 		// Path
 		Color[] colors = new Color[] {
-			Color.RED, Color.BLUE, Color.CYAN, Color.GREEN
+				Color.RED, Color.BLUE, Color.CYAN, Color.GREEN
 		};
 		int colorIndex = 0;
-		for(Path2f path : paths) {
+		for(Path2f path : this.paths) {
 			g.setColor(colors[colorIndex]);
 			colorIndex = (colorIndex+1)%colors.length;
 			pi = path.getPathIterator(MathConstants.SPLINE_APPROXIMATION_RATIO);
@@ -336,21 +440,21 @@
 				PathElement2f pe = pi.next();
 				switch(pe.type) {
 				case MOVE_TO:
-					cx = mx = toX(pe.toX);
-					cy = my = toY(pe.toY);
+					cx = mx = toX(pe.toX, docBounds);
+					cy = my = toY(pe.toY, docBounds);
 					break;
 				case LINE_TO:
-					cx = toX(pe.toX);
-					cy = toY(pe.toY);
+					cx = toX(pe.toX, docBounds);
+					cy = toY(pe.toY, docBounds);
 					g.drawLine(
-							toX(pe.fromX), toY(pe.fromY),
+							toX(pe.fromX, docBounds), toY(pe.fromY, docBounds),
 							cx, cy);
 					break;
 				case CLOSE:
-					cx = toX(pe.toX);
-					cy = toY(pe.toY);
+					cx = toX(pe.toX, docBounds);
+					cy = toY(pe.toY, docBounds);
 					g.drawLine(
-							toX(pe.fromX), toY(pe.fromY),
+							toX(pe.fromX, docBounds), toY(pe.fromY, docBounds),
 							cx, cy);
 					closed = true;
 					break;
@@ -375,5 +479,5 @@
 		if (GENERATE_TESTING_PICTURE)
 			ImageIO.write(img, "png", new File(FileSystem.getUserHomeDirectory(), "mytest.png"));  //$NON-NLS-1$//$NON-NLS-2$
 	}
-	
+
 }
\ No newline at end of file

Modified: trunk/math/src/test/java/org/arakhne/afc/math/continous/object2d/Rectangle2fTest.java
===================================================================
--- trunk/math/src/test/java/org/arakhne/afc/math/continous/object2d/Rectangle2fTest.java	2013-04-08 09:09:17 UTC (rev 418)
+++ trunk/math/src/test/java/org/arakhne/afc/math/continous/object2d/Rectangle2fTest.java	2013-04-08 20:02:47 UTC (rev 419)
@@ -583,4 +583,116 @@
 		assertTrue(this.r.intersects(new Ellipse2f(-1f, -1f, 1.2f, 1.2f)));
 	}
 
+	/**
+	 */
+	@Override
+	public void testIntersectsPath2f() {
+		Path2f p;
+		
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(-2f, 2f);
+		p.lineTo(2f, 2f);
+		p.lineTo(2f, -2f);
+		assertFalse(this.r.intersects(p));
+		p.closePath();
+		assertTrue(this.r.intersects(p));
+		
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(0f, 0f);
+		p.lineTo(-2f, 2f);
+		assertFalse(this.r.intersects(p));
+		p.closePath();
+		assertFalse(this.r.intersects(p));
+
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(2f, 2f);
+		p.lineTo(-2f, 2f);
+		assertTrue(this.r.intersects(p));
+		p.closePath();
+		assertTrue(this.r.intersects(p));
+
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(-2f, 2f);
+		p.lineTo(2f, -2f);
+		assertFalse(this.r.intersects(p));
+		p.closePath();
+		assertFalse(this.r.intersects(p));
+
+		p = new Path2f();
+		p.moveTo(-2f, 2f);
+		p.lineTo(1f, 0f);
+		p.lineTo(2f, 1f);
+		assertTrue(this.r.intersects(p));
+		p.closePath();
+		assertTrue(this.r.intersects(p));
+
+		p = new Path2f();
+		p.moveTo(-2f, 2f);
+		p.lineTo(2f, 1f);
+		p.lineTo(1f, 0f);
+		assertFalse(this.r.intersects(p));
+		p.closePath();
+		assertTrue(this.r.intersects(p));
+	}
+
+	/**
+	 */
+	@Override
+	public void testIntersectsPathIterator2f() {
+		Path2f p;
+
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(-2f, 2f);
+		p.lineTo(2f, 2f);
+		p.lineTo(2f, -2f);
+		assertFalse(this.r.intersects(p.getPathIterator()));
+		p.closePath();
+		assertTrue(this.r.intersects(p.getPathIterator()));
+		
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(0f, 0f);
+		p.lineTo(-2f, 2f);
+		assertFalse(this.r.intersects(p.getPathIterator()));
+		p.closePath();
+		assertFalse(this.r.intersects(p.getPathIterator()));
+
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(2f, 2f);
+		p.lineTo(-2f, 2f);
+		assertTrue(this.r.intersects(p.getPathIterator()));
+		p.closePath();
+		assertTrue(this.r.intersects(p.getPathIterator()));
+
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(-2f, 2f);
+		p.lineTo(2f, -2f);
+		assertFalse(this.r.intersects(p.getPathIterator()));
+		p.closePath();
+		assertFalse(this.r.intersects(p.getPathIterator()));
+
+		p = new Path2f();
+		p.moveTo(-2f, 2f);
+		p.lineTo(1f, 0f);
+		p.lineTo(2f, 1f);
+		assertTrue(this.r.intersects(p.getPathIterator()));
+		p.closePath();
+		assertTrue(this.r.intersects(p.getPathIterator()));
+
+		p = new Path2f();
+		p.moveTo(-2f, 2f);
+		p.lineTo(2f, 1f);
+		p.lineTo(1f, 0f);
+		assertFalse(this.r.intersects(p.getPathIterator()));
+		p.closePath();
+		assertTrue(this.r.intersects(p.getPathIterator()));
+	}
+
 }
\ No newline at end of file

Modified: trunk/math/src/test/java/org/arakhne/afc/math/continous/object2d/RoundRectangle2fTest.java
===================================================================
--- trunk/math/src/test/java/org/arakhne/afc/math/continous/object2d/RoundRectangle2fTest.java	2013-04-08 09:09:17 UTC (rev 418)
+++ trunk/math/src/test/java/org/arakhne/afc/math/continous/object2d/RoundRectangle2fTest.java	2013-04-08 20:02:47 UTC (rev 419)
@@ -456,4 +456,116 @@
 				.25f, .25f, .5f, .5f));
 	}
 
+	/**
+	 */
+	@Override
+	public void testIntersectsPath2f() {
+		Path2f p;
+		
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(-2f, 2f);
+		p.lineTo(2f, 2f);
+		p.lineTo(2f, -2f);
+		assertFalse(this.r.intersects(p));
+		p.closePath();
+		assertTrue(this.r.intersects(p));
+		
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(0f, 0f);
+		p.lineTo(-2f, 2f);
+		assertFalse(this.r.intersects(p));
+		p.closePath();
+		assertFalse(this.r.intersects(p));
+
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(2f, 2f);
+		p.lineTo(-2f, 2f);
+		assertTrue(this.r.intersects(p));
+		p.closePath();
+		assertTrue(this.r.intersects(p));
+
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(-2f, 2f);
+		p.lineTo(2f, -2f);
+		assertFalse(this.r.intersects(p));
+		p.closePath();
+		assertFalse(this.r.intersects(p));
+
+		p = new Path2f();
+		p.moveTo(-2f, 2f);
+		p.lineTo(1f, 0f);
+		p.lineTo(2f, 1f);
+		assertTrue(this.r.intersects(p));
+		p.closePath();
+		assertTrue(this.r.intersects(p));
+
+		p = new Path2f();
+		p.moveTo(-2f, 2f);
+		p.lineTo(2f, 1f);
+		p.lineTo(1f, 0f);
+		assertFalse(this.r.intersects(p));
+		p.closePath();
+		assertTrue(this.r.intersects(p));
+	}
+
+	/**
+	 */
+	@Override
+	public void testIntersectsPathIterator2f() {
+		Path2f p;
+
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(-2f, 2f);
+		p.lineTo(2f, 2f);
+		p.lineTo(2f, -2f);
+		assertFalse(this.r.intersects(p.getPathIterator()));
+		p.closePath();
+		assertTrue(this.r.intersects(p.getPathIterator()));
+		
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(0f, 0f);
+		p.lineTo(-2f, 2f);
+		assertFalse(this.r.intersects(p.getPathIterator()));
+		p.closePath();
+		assertFalse(this.r.intersects(p.getPathIterator()));
+
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(2f, 2f);
+		p.lineTo(-2f, 2f);
+		assertTrue(this.r.intersects(p.getPathIterator()));
+		p.closePath();
+		assertTrue(this.r.intersects(p.getPathIterator()));
+
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(-2f, 2f);
+		p.lineTo(2f, -2f);
+		assertFalse(this.r.intersects(p.getPathIterator()));
+		p.closePath();
+		assertFalse(this.r.intersects(p.getPathIterator()));
+
+		p = new Path2f();
+		p.moveTo(-2f, 2f);
+		p.lineTo(1f, 0f);
+		p.lineTo(2f, 1f);
+		assertTrue(this.r.intersects(p.getPathIterator()));
+		p.closePath();
+		assertTrue(this.r.intersects(p.getPathIterator()));
+
+		p = new Path2f();
+		p.moveTo(-2f, 2f);
+		p.lineTo(2f, 1f);
+		p.lineTo(1f, 0f);
+		assertFalse(this.r.intersects(p.getPathIterator()));
+		p.closePath();
+		assertTrue(this.r.intersects(p.getPathIterator()));
+	}
+
 }
\ No newline at end of file

Modified: trunk/math/src/test/java/org/arakhne/afc/math/continous/object2d/Segment2fTest.java
===================================================================
--- trunk/math/src/test/java/org/arakhne/afc/math/continous/object2d/Segment2fTest.java	2013-04-08 09:09:17 UTC (rev 418)
+++ trunk/math/src/test/java/org/arakhne/afc/math/continous/object2d/Segment2fTest.java	2013-04-08 20:02:47 UTC (rev 419)
@@ -337,7 +337,7 @@
 						7f, -5f, 1f, 1f,
 						4f, -3f, 1f, 1f));
 		assertEquals(
-				1,
+				2,
 				Segment2f.computeCrossingsFromSegment(
 						0,
 						4f, -3f, 1f, 1f,
@@ -349,7 +349,7 @@
 						1f, 1f, 4f, -3f,
 						7f, -5f, 1f, 1f));
 		assertEquals(
-				-1,
+				-2,
 				Segment2f.computeCrossingsFromSegment(
 						0,
 						4f, -3f, 1f, 1f,
@@ -540,7 +540,7 @@
 						20f, -5f, .75f, .5f));
 
 		assertEquals(
-				1,
+				2,
 				Segment2f.computeCrossingsFromSegment(
 						0,
 						1f, 0f, 0f, 1f,
@@ -1194,7 +1194,7 @@
 
 	/**
 	 */
-	public void testgetPathIteratorVoid() {
+	public void testGetPathIteratorVoid() {
 		PathIterator2f pi = this.r.getPathIterator();
 		assertElement(pi, PathElementType.MOVE_TO, 0f,0f);
 		assertElement(pi, PathElementType.LINE_TO, 1f,1f);
@@ -1203,7 +1203,7 @@
 
 	/**
 	 */
-	public void testgetPathIteratorTransform2D() {
+	public void testGetPathIteratorTransform2D() {
 		Transform2D tr;
 		PathIterator2f pi;
 		
@@ -1307,4 +1307,112 @@
 		assertEpsilonEquals(1.414213562f, s.getY2());
     }
 
+    @Override
+	public void testIntersectsPath2f() {
+		Path2f p;
+		
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(-2f, 2f);
+		p.lineTo(2f, 2f);
+		p.lineTo(2f, -2f);
+		assertFalse(this.r.intersects(p));
+		p.closePath();
+		assertTrue(this.r.intersects(p));
+		
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(0f, 0f);
+		p.lineTo(-2f, 2f);
+		assertFalse(this.r.intersects(p));
+		p.closePath();
+		assertFalse(this.r.intersects(p));
+
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(2f, 2f);
+		p.lineTo(-2f, 2f);
+		assertTrue(this.r.intersects(p));
+		p.closePath();
+		assertTrue(this.r.intersects(p));
+
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(-2f, 2f);
+		p.lineTo(2f, -2f);
+		assertFalse(this.r.intersects(p));
+		p.closePath();
+		assertFalse(this.r.intersects(p));
+
+		p = new Path2f();
+		p.moveTo(-2f, 2f);
+		p.lineTo(1f, 0f);
+		p.lineTo(2f, 1f);
+		assertTrue(this.r.intersects(p));
+		p.closePath();
+		assertTrue(this.r.intersects(p));
+
+		p = new Path2f();
+		p.moveTo(-2f, 2f);
+		p.lineTo(2f, 1f);
+		p.lineTo(1f, 0f);
+		assertFalse(this.r.intersects(p));
+		p.closePath();
+		assertTrue(this.r.intersects(p));
+	}
+
+    @Override
+	public void testIntersectsPathIterator2f() {
+		Path2f p;
+		
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(-2f, 2f);
+		p.lineTo(2f, 2f);
+		p.lineTo(2f, -2f);
+		assertFalse(this.r.intersects(p.getPathIterator()));
+		p.closePath();
+		assertTrue(this.r.intersects(p.getPathIterator()));
+		
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(0f, 0f);
+		p.lineTo(-2f, 2f);
+		assertFalse(this.r.intersects(p.getPathIterator()));
+		p.closePath();
+		assertFalse(this.r.intersects(p.getPathIterator()));
+
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(2f, 2f);
+		p.lineTo(-2f, 2f);
+		assertTrue(this.r.intersects(p.getPathIterator()));
+		p.closePath();
+		assertTrue(this.r.intersects(p.getPathIterator()));
+
+		p = new Path2f();
+		p.moveTo(-2f, -2f);
+		p.lineTo(-2f, 2f);
+		p.lineTo(2f, -2f);
+		assertFalse(this.r.intersects(p.getPathIterator()));
+		p.closePath();
+		assertFalse(this.r.intersects(p.getPathIterator()));
+
+		p = new Path2f();
+		p.moveTo(-2f, 2f);
+		p.lineTo(1f, 0f);
+		p.lineTo(2f, 1f);
+		assertTrue(this.r.intersects(p.getPathIterator()));
+		p.closePath();
+		assertTrue(this.r.intersects(p.getPathIterator()));
+
+		p = new Path2f();
+		p.moveTo(-2f, 2f);
+		p.lineTo(2f, 1f);
+		p.lineTo(1f, 0f);
+		assertFalse(this.r.intersects(p.getPathIterator()));
+		p.closePath();
+		assertTrue(this.r.intersects(p.getPathIterator()));
+	}
+
 }
\ No newline at end of file


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/