[Arakhnę-Dev] [413] * Path2fTest -> ClosePath2fTest |
[ Thread Index |
Date Index
| More arakhne.org/dev Archives
]
Revision: 413
Author: galland
Date: 2013-04-05 22:39:57 +0200 (Fri, 05 Apr 2013)
Log Message:
-----------
* Path2fTest -> ClosePath2fTest
Removed Paths:
-------------
trunk/math/src/test/java/org/arakhne/afc/math/continous/object2d/Path2fTest.java
Deleted: trunk/math/src/test/java/org/arakhne/afc/math/continous/object2d/Path2fTest.java
===================================================================
--- trunk/math/src/test/java/org/arakhne/afc/math/continous/object2d/Path2fTest.java 2013-04-05 20:39:23 UTC (rev 412)
+++ trunk/math/src/test/java/org/arakhne/afc/math/continous/object2d/Path2fTest.java 2013-04-05 20:39:57 UTC (rev 413)
@@ -1,718 +0,0 @@
-/*
- * $Id$
- *
- * Copyright (c) 2006-10, Multiagent Team, Laboratoire Systemes et Transports, Universite de Technologie de Belfort-Montbeliard.
- * Copyright (C) 2012 Stephane GALLAND.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- * This program is free software; you can redistribute it and/or modify
- */
-package org.arakhne.afc.math.continous.object2d;
-
-import org.arakhne.afc.math.generic.PathElementType;
-import org.arakhne.afc.math.generic.PathWindingRule;
-import org.arakhne.afc.math.generic.Point2D;
-import org.arakhne.afc.math.matrix.Transform2D;
-
-/**
- * @author $Author: galland$
- * @version $FullVersion$
- * @mavengroupid $GroupId$
- * @mavenartifactid $ArtifactId$
- */
-public class Path2fTest extends AbstractShape2fTestCase<Path2f> {
-
- @Override
- protected Path2f createShape() {
- Path2f p = new Path2f();
- p.moveTo(1f, 1f);
- p.lineTo(2f, 2f);
- p.quadTo(3f, 0f, 4f, 3f);
- p.curveTo(5f, -1f, 6f, 5f, 7f, -5f);
- p.closePath();
- return p;
- }
-
- @Override
- public void testIsEmpty() {
- assertFalse(this.r.isEmpty());
-
- this.r.clear();
- assertTrue(this.r.isEmpty());
-
- this.r.moveTo(1f, 2f);
- assertTrue(this.r.isEmpty());
- this.r.moveTo(3f, 4f);
- assertTrue(this.r.isEmpty());
- this.r.lineTo(5f, 6f);
- assertFalse(this.r.isEmpty());
- this.r.closePath();
- assertFalse(this.r.isEmpty());
-
- this.r.clear();
- assertTrue(this.r.isEmpty());
-
- this.r.moveTo(1f, 2f);
- assertTrue(this.r.isEmpty());
- this.r.moveTo(3f, 4f);
- assertTrue(this.r.isEmpty());
- this.r.lineTo(3f, 4f);
- assertTrue(this.r.isEmpty());
- this.r.closePath();
- assertTrue(this.r.isEmpty());
-
- this.r.clear();
- assertTrue(this.r.isEmpty());
-
- this.r.moveTo(1f, 2f);
- assertTrue(this.r.isEmpty());
- this.r.moveTo(3f, 4f);
- assertTrue(this.r.isEmpty());
- this.r.lineTo(3f, 4f);
- assertTrue(this.r.isEmpty());
- this.r.lineTo(5f, 6f);
- assertFalse(this.r.isEmpty());
- }
-
- @Override
- public void testClear() {
- this.r.clear();
- assertEquals(0, this.r.size());
- }
-
- @Override
- public void testClone() {
- Path2f b = this.r.clone();
-
- assertNotSame(b, this.r);
- PathElement2f pe1, pe2;
- PathIterator2f i1 = this.r.getPathIterator();
- PathIterator2f i2 = b.getPathIterator();
- while (i1.hasNext()) {
- assertTrue(i2.hasNext());
- pe1 = i1.next();
- pe2 = i2.next();
- assertEquals(pe1.type, pe2.type);
- assertEpsilonEquals(pe1.fromX, pe2.fromX);
- assertEpsilonEquals(pe1.fromY, pe2.fromY);
- assertEpsilonEquals(pe1.ctrlX1, pe2.ctrlX1);
- assertEpsilonEquals(pe1.ctrlY1, pe2.ctrlY1);
- assertEpsilonEquals(pe1.ctrlX2, pe2.ctrlX2);
- assertEpsilonEquals(pe1.ctrlY2, pe2.ctrlY2);
- assertEpsilonEquals(pe1.toX, pe2.toX);
- assertEpsilonEquals(pe1.toY, pe2.toY);
-
- }
- assertFalse(i2.hasNext());
-
- b.translate(1f, 1f);
-
- i1 = this.r.getPathIterator();
- i2 = b.getPathIterator();
- while (i1.hasNext()) {
- assertTrue(i2.hasNext());
- pe1 = i1.next();
- pe2 = i2.next();
- assertEquals(pe1.type, pe2.type);
- assertNotEpsilonEquals(pe1.fromX, pe2.fromX);
- assertNotEpsilonEquals(pe1.fromY, pe2.fromY);
- assertNotEpsilonEquals(pe1.ctrlX1, pe2.ctrlX1);
- assertNotEpsilonEquals(pe1.ctrlY1, pe2.ctrlY1);
- assertNotEpsilonEquals(pe1.ctrlX2, pe2.ctrlX2);
- assertNotEpsilonEquals(pe1.ctrlY2, pe2.ctrlY2);
- assertNotEpsilonEquals(pe1.toX, pe2.toX);
- assertNotEpsilonEquals(pe1.toY, pe2.toY);
-
- }
- assertFalse(i2.hasNext());
- }
-
- /*private static int toX(float x) {
- return (int)(x * 100) + 20;
- }
-
- private static int toY(float y) {
- return (int)(y * 100) + 600;
- }
-
- private static int toS(float s) {
- return (int)(s * 100);
- }
-
- public void testFlattening() throws IOException {
- BufferedImage img = new BufferedImage(800, 1000, BufferedImage.TYPE_INT_ARGB);
- Graphics2D g = (Graphics2D)img.getGraphics();
- g.setColor(Color.WHITE);
- g.fillRect(0, 0, 800, 1000);
- 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));
- }
- for(float x=-1; x<=8; x+=1) {
- if (x!=0f) g.drawLine(toX(x), toY(-10), toX(x), toY(10));
- }
- g.setColor(Color.BLACK);
- g.drawLine(toX(-10), toY(0), toX(10), toY(0));
- g.drawLine(toX(0), toY(-10), toX(0), toY(10));
-
- g.setColor(Color.ORANGE);
- Segment2f[] ells = new Segment2f[] {
- new Segment2f(0f, 0f, 1f, 1f),
- new Segment2f(4f, 3f, 1f, 1f),
- new Segment2f(2f, 2f, 1f, 1f),
- new Segment2f(2f, 1f, 1f, 1f),
- new Segment2f(3f, 0f, 1f, 1f),
- new Segment2f(-1f, -1f, 1f, 1f),
- new Segment2f(4f, -3f, 1f, 1f),
- new Segment2f(-3f, 4f, 1f, 1f),
- new Segment2f(6f, -5f, 1f, 1f),
- new Segment2f(4f, 0f, 1f, 1f),
- new Segment2f(5f, 0f, 1f, 1f),
- new Segment2f(.01f, .01f, 1f, 1f),
- };
- for(Segment2f ell : ells) {
- g.drawLine(
- toX(ell.getX1()), toY(ell.getY1()),
- toX(ell.getX2()), toY(ell.getY2()));
- }
-
- g.setColor(Color.GREEN);
-
- Segment2f[] segs = new Segment2f[] {
-// new Segment2f(-1f, -5f, 5f, -4f),
-// new Segment2f(-5f, -1f, -7f, 3f),
-// new Segment2f(10f, -1f, 11f, -2f),
-// new Segment2f(1f, 6f, 3f, 5f),
-// new Segment2f(6f, -1f, 5f, .5f),
-// new Segment2f(6f, -1f, 5f, 2f),
-// new Segment2f(6f, .5f, 5f, 2f),
-// new Segment2f(3f, 0f, .5f, .5f),
-// new Segment2f(3f, 0f, 0f, 2f),
-// new Segment2f(.5f, -1f, .5f, 4f),
-// new Segment2f(3f, 0f, 1f, 3f),
- };
- for(Segment2f seg : segs) {
- g.drawLine(toX(seg.getX1()), toY(seg.getY1()), toX(seg.getX2()), toY(seg.getY2()));
- }
-
- PathIterator2f pi = this.r.getPathIterator(.5f);
- while (pi.hasNext()) {
- PathElement2f pe = pi.next();
- switch(pe.type) {
- case LINE_TO:
- g.drawLine(
- toX(pe.fromX), toY(pe.fromY),
- toX(pe.toX), toY(pe.toY));
- break;
- case QUAD_TO:
- g.draw( new QuadCurve2D.Float(
- toX(pe.fromX), toY(pe.fromY),
- toX(pe.ctrlX1), toY(pe.ctrlY1),
- toX(pe.toX), toY(pe.toY)));
- break;
- case CURVE_TO:
- g.draw( new CubicCurve2D.Float(
- toX(pe.fromX), toY(pe.fromY),
- toX(pe.ctrlX1), toY(pe.ctrlY1),
- toX(pe.ctrlX2), toY(pe.ctrlY2),
- toX(pe.toX), toY(pe.toY)));
- break;
- case CLOSE:
- g.drawLine(
- toX(pe.fromX), toY(pe.fromY),
- toX(pe.toX), toY(pe.toY));
- break;
- default:
- }
- }
-
- g.setColor(Color.RED);
- pi = this.r.getPathIterator(MathConstants.SPLINE_APPROXIMATION_RATIO);
- while (pi.hasNext()) {
- PathElement2f pe = pi.next();
- switch(pe.type) {
- case LINE_TO:
- g.drawLine(
- toX(pe.fromX), toY(pe.fromY),
- toX(pe.toX), toY(pe.toY));
- break;
- case CLOSE:
- g.drawLine(
- toX(pe.fromX), toY(pe.fromY),
- toX(pe.toX), toY(pe.toY));
- break;
- default:
- }
- }
- g.dispose();
- ImageIO.write(img, "png", new File("/home/sgalland/mytest.png"));
- }*/
-
- /**
- */
- public void testContainsPathIterator2fFloatFloat() {
- assertFalse(Path2f.contains(this.r.getPathIterator(), 0f, 0f));
- assertFalse(Path2f.contains(this.r.getPathIterator(), 4f, 3f));
- assertFalse(Path2f.contains(this.r.getPathIterator(), 2f, 2f));
- assertFalse(Path2f.contains(this.r.getPathIterator(), 2f, 2f));
- assertTrue(Path2f.contains(this.r.getPathIterator(), 2f, 1f));
- assertTrue(Path2f.contains(this.r.getPathIterator(), 5f, 0f));
- assertFalse(Path2f.contains(this.r.getPathIterator(), -1f, -1f));
- }
-
- /**
- */
- public void testIntersectsPathIterator2fFloatFloatFloatFloat() {
- assertFalse(Path2f.intersects(this.r.getPathIterator(), 0f, 0f, 1f, 1f));
- assertFalse(Path2f.intersects(this.r.getPathIterator(), 4f, 3f, 1f, 1f));
- assertFalse(Path2f.intersects(this.r.getPathIterator(), 2f, 2f, 1f, 1f));
- assertTrue(Path2f.intersects(this.r.getPathIterator(), 2f, 1f, 1f, 1f));
- assertTrue(Path2f.intersects(this.r.getPathIterator(), 3f, 0f, 1f, 1f));
- assertFalse(Path2f.intersects(this.r.getPathIterator(), -1f, -1f, 1f, 1f));
- assertTrue(Path2f.intersects(this.r.getPathIterator(), 4f, -3f, 1f, 1f));
- assertFalse(Path2f.intersects(this.r.getPathIterator(), -3f, 4f, 1f, 1f));
- assertTrue(Path2f.intersects(this.r.getPathIterator(), 6f, -5f, 1f, 1f));
- assertFalse(Path2f.intersects(this.r.getPathIterator(), 4f, 0f, 1f, 1f));
- assertFalse(Path2f.intersects(this.r.getPathIterator(), 5f, 0f, 1f, 1f));
- }
-
- /**
- */
- public void testGetClosestPointTo() {
- Point2D p;
-
- p = this.r.getClosestPointTo(new Point2f(0f, 0f));
- assertEpsilonEquals(1f, p.getX());
- assertEpsilonEquals(1f, p.getY());
-
- p = this.r.getClosestPointTo(new Point2f(4f, 0f));
- assertEpsilonEquals(4f, p.getX());
- assertEpsilonEquals(0f, p.getY());
-
- p = this.r.getClosestPointTo(new Point2f(4f, 2f));
- assertEpsilonEquals(4f, p.getX());
- assertEpsilonEquals(2f, p.getY());
- }
-
-
- @Override
- public void testDistancePoint2D() {
- //
- }
-
- @Override
- public void testDistanceSquaredPoint2D() {
- //
- }
-
- @Override
- public void testDistanceL1Point2D() {
- //
- }
-
- @Override
- public void testDistanceLinfPoint2D() {
- //
- }
-
- @Override
- public void testTranslateFloatFloat() {
- this.r.translate(3.4f, 4.5f);
- PathIterator2f pi = this.r.getPathIterator();
- assertElement(pi, PathElementType.MOVE_TO, 4.4f, 5.5f);
- assertElement(pi, PathElementType.LINE_TO, 5.4f, 6.5f);
- assertElement(pi, PathElementType.QUAD_TO, 6.4f, 4.5f, 7.4f, 7.5f);
- assertElement(pi, PathElementType.CURVE_TO, 8.4f, 3.5f, 9.4f, 9.5f, 10.4f, -.5f);
- assertElement(pi, PathElementType.CLOSE);
- assertNoElement(pi);
- }
-
- /**
- */
- public void testSetWindingRule() {
- assertEquals(PathWindingRule.NON_ZERO, this.r.getWindingRule());
- for(PathWindingRule rule : PathWindingRule.values()) {
- this.r.setWindingRule(rule);
- assertEquals(rule, this.r.getWindingRule());
- }
- }
-
- /**
- */
- public void testAddIterator() {
- Path2f p2 = new Path2f();
- p2.moveTo(3.4f, 4.5f);
- p2.lineTo(5.6f, 6.7f);
-
- this.r.add(p2.getPathIterator());
-
- PathIterator2f pi = this.r.getPathIterator();
- assertElement(pi, PathElementType.MOVE_TO, 1f, 1f);
- assertElement(pi, PathElementType.LINE_TO, 2f, 2f);
- assertElement(pi, PathElementType.QUAD_TO, 3f, 0f, 4f, 3f);
- assertElement(pi, PathElementType.CURVE_TO, 5f, -1f, 6f, 5f, 7f, -5f);
- assertElement(pi, PathElementType.CLOSE);
- assertElement(pi, PathElementType.MOVE_TO, 3.4f, 4.5f);
- assertElement(pi, PathElementType.LINE_TO, 5.6f, 6.7f);
- assertNoElement(pi);
- }
-
- /**
- */
- public void testGetPathIteratorVoid() {
- PathIterator2f pi = this.r.getPathIterator();
- assertElement(pi, PathElementType.MOVE_TO, 1f, 1f);
- assertElement(pi, PathElementType.LINE_TO, 2f, 2f);
- assertElement(pi, PathElementType.QUAD_TO, 3f, 0f, 4f, 3f);
- assertElement(pi, PathElementType.CURVE_TO, 5f, -1f, 6f, 5f, 7f, -5f);
- assertElement(pi, PathElementType.CLOSE);
- assertNoElement(pi);
- }
-
- /**
- */
- public void testGetPathIteratorTransform2D() {
- Transform2D tr;
- PathIterator2f pi;
-
- tr = new Transform2D();
- pi = this.r.getPathIterator(tr);
- assertElement(pi, PathElementType.MOVE_TO, 1f, 1f);
- assertElement(pi, PathElementType.LINE_TO, 2f, 2f);
- assertElement(pi, PathElementType.QUAD_TO, 3f, 0f, 4f, 3f);
- assertElement(pi, PathElementType.CURVE_TO, 5f, -1f, 6f, 5f, 7f, -5f);
- assertElement(pi, PathElementType.CLOSE);
- assertNoElement(pi);
-
- tr = new Transform2D();
- tr.makeTranslationMatrix(3.4f, 4.5f);
- pi = this.r.getPathIterator(tr);
- assertElement(pi, PathElementType.MOVE_TO, 4.4f, 5.5f);
- assertElement(pi, PathElementType.LINE_TO, 5.4f, 6.5f);
- assertElement(pi, PathElementType.QUAD_TO, 6.4f, 4.5f, 7.4f, 7.5f);
- assertElement(pi, PathElementType.CURVE_TO, 8.4f, 3.5f, 9.4f, 9.5f, 10.4f, -.5f);
- assertElement(pi, PathElementType.CLOSE);
- assertNoElement(pi);
- }
-
- /**
- */
- public void testTransformTransform2D() {
- Transform2D tr = new Transform2D();
- tr.makeTranslationMatrix(3.4f, 4.5f);
- Transform2D tr2 = new Transform2D();
- tr2.makeRotationMatrix(5.6f);
-
- Path2f clone = this.r.clone();
- clone.transform(tr);
-
- PathIterator2f pi = clone.getPathIterator();
- assertElement(pi, PathElementType.MOVE_TO, 4.4f, 5.5f);
- assertElement(pi, PathElementType.LINE_TO, 5.4f, 6.5f);
- assertElement(pi, PathElementType.QUAD_TO, 6.4f, 4.5f, 7.4f, 7.5f);
- assertElement(pi, PathElementType.CURVE_TO, 8.4f, 3.5f, 9.4f, 9.5f, 10.4f, -.5f);
- assertElement(pi, PathElementType.CLOSE);
- assertNoElement(pi);
-
- clone = this.r.clone();
- clone.transform(tr2);
-
- pi = clone.getPathIterator();
- assertElement(pi, PathElementType.MOVE_TO, 1.406832516382571f, 0.144299240637928f);
- assertElement(pi, PathElementType.LINE_TO, 2.813665032765142f, 0.288598481275856f);
- assertElement(pi, PathElementType.QUAD_TO, 2.32669763553075f, -1.89379991361696f,
- 4.996063427657964f, -0.198368915958538f);
- assertElement(pi, PathElementType.CURVE_TO, 3.24656275467893f, -3.93189906787186f,
- 7.8097284604231056f, 0.0902295653173185f,
- 2.27262796021014f, -8.29669585765750f);
- assertElement(pi, PathElementType.CLOSE);
- assertNoElement(pi);
-
- Transform2D tr3 = new Transform2D();
- tr3.mul(tr, tr2);
- clone = this.r.clone();
- clone.transform(tr3);
-
- pi = clone.getPathIterator();
- assertElement(pi, PathElementType.MOVE_TO, 4.80683251638257f, 4.64429924063793f);
- assertElement(pi, PathElementType.LINE_TO, 6.21366503276514f, 4.78859848127586f);
- assertElement(pi, PathElementType.QUAD_TO, 5.72669763553075f, 2.60620008638304f,
- 8.39606342765796f, 4.30163108404146f);
- assertElement(pi, PathElementType.CURVE_TO, 6.646562754678927f, 0.568100932128142f,
- 11.20972846042311f, 4.59022956531732f, 5.67262796021014f, -3.79669585765750f);
- assertElement(pi, PathElementType.CLOSE);
- assertNoElement(pi);
- }
-
- /**
- */
- public void testCreateTransformedShape2D() {
- Transform2D tr = new Transform2D();
- tr.makeTranslationMatrix(3.4f, 4.5f);
- Path2f p2 = (Path2f)this.r.createTransformedShape(tr);
-
- PathIterator2f pi = p2.getPathIterator();
- assertElement(pi, PathElementType.MOVE_TO, 4.4f, 5.5f);
- assertElement(pi, PathElementType.LINE_TO, 5.4f, 6.5f);
- assertElement(pi, PathElementType.QUAD_TO, 6.4f, 4.5f, 7.4f, 7.5f);
- assertElement(pi, PathElementType.CURVE_TO, 8.4f, 3.5f, 9.4f, 9.5f, 10.4f, -.5f);
- assertElement(pi, PathElementType.CLOSE);
- assertNoElement(pi);
- }
-
- /**
- */
- public void testContainsFloatfloat() {
- assertFalse(this.r.contains(0f, 0f));
- assertFalse(this.r.contains(4f, 3f));
- assertFalse(this.r.contains(2f, 2f));
- assertFalse(this.r.contains(2f, 2f));
- assertTrue(this.r.contains(2f, 1f));
- assertTrue(this.r.contains(5f, 0f));
- assertFalse(this.r.contains(-1f, -1f));
- }
-
- /**
- */
- public void testContainsRectangle2f() {
- assertFalse(this.r.contains(new Rectangle2f(0f, 0f, 1f, 1f)));
- assertFalse(this.r.contains(new Rectangle2f(4f, 3f, 1f, 1f)));
- assertFalse(this.r.contains(new Rectangle2f(2f, 2f, 1f, 1f)));
- assertFalse(this.r.contains(new Rectangle2f(2f, 1f, 1f, 1f)));
- assertTrue(this.r.contains(new Rectangle2f(3f, 0f, 1f, 1f)));
- assertFalse(this.r.contains(new Rectangle2f(-1f, -1f, 1f, 1f)));
- assertFalse(this.r.contains(new Rectangle2f(4f, -3f, 1f, 1f)));
- assertFalse(this.r.contains(new Rectangle2f(-3f, 4f, 1f, 1f)));
- assertFalse(this.r.contains(new Rectangle2f(6f, -5f, 1f, 1f)));
- assertFalse(this.r.contains(new Rectangle2f(4f, 0f, 1f, 1f)));
- assertFalse(this.r.contains(new Rectangle2f(5f, 0f, 1f, 1f)));
- assertFalse(this.r.contains(new Rectangle2f(.01f, .01f, 1f, 1f)));
- }
-
- /**
- */
- public void testIntersectsRectangle2f() {
- assertFalse(this.r.intersects(new Rectangle2f(0f, 0f, 1f, 1f)));
- assertFalse(this.r.intersects(new Rectangle2f(4f, 3f, 1f, 1f)));
- assertFalse(this.r.intersects(new Rectangle2f(2f, 2f, 1f, 1f)));
- assertTrue(this.r.intersects(new Rectangle2f(2f, 1f, 1f, 1f)));
- assertTrue(this.r.intersects(new Rectangle2f(3f, 0f, 1f, 1f)));
- assertFalse(this.r.intersects(new Rectangle2f(-1f, -1f, 1f, 1f)));
- assertTrue(this.r.intersects(new Rectangle2f(4f, -3f, 1f, 1f)));
- assertFalse(this.r.intersects(new Rectangle2f(-3f, 4f, 1f, 1f)));
- assertTrue(this.r.intersects(new Rectangle2f(6f, -5f, 1f, 1f)));
- assertFalse(this.r.intersects(new Rectangle2f(4f, 0f, 1f, 1f)));
- assertFalse(this.r.intersects(new Rectangle2f(5f, 0f, 1f, 1f)));
- assertTrue(this.r.intersects(new Rectangle2f(.01f, .01f, 1f, 1f)));
- }
-
- /**
- */
- public void testIntersectsEllipse2f() {
- assertFalse(this.r.intersects(new Ellipse2f(0f, 0f, 1f, 2f)));
- assertFalse(this.r.intersects(new Ellipse2f(4f, 3f, 1f, 2f)));
- assertFalse(this.r.intersects(new Ellipse2f(2f, 2f, 1f, 2f)));
- assertTrue(this.r.intersects(new Ellipse2f(2f, 1f, 1f, 2f)));
- assertTrue(this.r.intersects(new Ellipse2f(3f, 0f, 1f, 2f)));
- assertFalse(this.r.intersects(new Ellipse2f(-1f, -1f, 1f, 2f)));
- assertTrue(this.r.intersects(new Ellipse2f(4f, -3f, 1f, 2f)));
- assertFalse(this.r.intersects(new Ellipse2f(-3f, 4f, 1f, 2f)));
- assertTrue(this.r.intersects(new Ellipse2f(6f, -5f, 1f, 2f)));
- assertTrue(this.r.intersects(new Ellipse2f(4f, 0f, 1f, 2f)));
- assertFalse(this.r.intersects(new Ellipse2f(6f, 0f, 1f, 2f)));
- }
-
- /**
- */
- public void testIntersectsCircle2f() {
- assertFalse(this.r.intersects(new Circle2f(0f, 0f, 1f)));
- assertTrue(this.r.intersects(new Circle2f(4f, 3f, 1f)));
- assertTrue(this.r.intersects(new Circle2f(2f, 2f, 1f)));
- assertTrue(this.r.intersects(new Circle2f(2f, 1f, 1f)));
- assertTrue(this.r.intersects(new Circle2f(3f, 0f, 1f)));
- assertFalse(this.r.intersects(new Circle2f(-1f, -1f, 1f)));
- assertTrue(this.r.intersects(new Circle2f(4f, -3f, 1f)));
- assertFalse(this.r.intersects(new Circle2f(-3f, 4f, 1f)));
- assertTrue(this.r.intersects(new Circle2f(6f, -5f, 1f)));
- assertTrue(this.r.intersects(new Circle2f(4f, 0f, 1f)));
- assertTrue(this.r.intersects(new Circle2f(5f, 0f, 1f)));
- assertFalse(this.r.intersects(new Circle2f(.01f, .01f, 1f)));
- assertFalse(this.r.intersects(new Circle2f(6f, 2f, .8f)));
- }
-
- /**
- */
- public void testIntersectsSegment2f() {
- assertFalse(this.r.intersects(new Segment2f(0f, 0f, 1f, 1f)));
- assertTrue(this.r.intersects(new Segment2f(4f, 3f, 1f, 1f)));
- assertTrue(this.r.intersects(new Segment2f(2f, 2f, 1f, 1f)));
- assertTrue(this.r.intersects(new Segment2f(2f, 1f, 1f, 1f)));
- assertTrue(this.r.intersects(new Segment2f(3f, 0f, 1f, 1f)));
- assertFalse(this.r.intersects(new Segment2f(-1f, -1f, 1f, 1f)));
- assertTrue(this.r.intersects(new Segment2f(4f, -3f, 1f, 1f)));
- assertFalse(this.r.intersects(new Segment2f(4f, -3f, 1f, 0f)));
- assertFalse(this.r.intersects(new Segment2f(-3f, 4f, 1f, 1f)));
- assertTrue(this.r.intersects(new Segment2f(6f, -5f, 1f, 1f)));
- assertFalse(this.r.intersects(new Segment2f(6f, -5f, 1f, 0f)));
- assertTrue(this.r.intersects(new Segment2f(4f, 0f, 1f, 1f)));
- assertTrue(this.r.intersects(new Segment2f(5f, 0f, 1f, 1f)));
- assertFalse(this.r.intersects(new Segment2f(.01f, .01f, 1f, 1f)));
- }
-
- @Override
- public void testToBoundingBox() {
- Rectangle2f bb = this.r.toBoundingBox();
- assertEpsilonEquals(1f, bb.getMinX());
- assertEpsilonEquals(-5f, bb.getMinY());
- assertEpsilonEquals(7f, bb.getMaxX());
- assertEpsilonEquals(5f, bb.getMaxY());
- }
-
- /**
- */
- public void testRemoveLast() {
- PathIterator2f pi = this.r.getPathIterator();
- assertElement(pi, PathElementType.MOVE_TO, 1f, 1f);
- assertElement(pi, PathElementType.LINE_TO, 2f, 2f);
- assertElement(pi, PathElementType.QUAD_TO, 3f, 0f, 4f, 3f);
- assertElement(pi, PathElementType.CURVE_TO, 5f, -1f, 6f, 5f, 7f, -5f);
- assertElement(pi, PathElementType.CLOSE);
- assertNoElement(pi);
-
- this.r.removeLast();
-
- pi = this.r.getPathIterator();
- assertElement(pi, PathElementType.MOVE_TO, 1f, 1f);
- assertElement(pi, PathElementType.LINE_TO, 2f, 2f);
- assertElement(pi, PathElementType.QUAD_TO, 3f, 0f, 4f, 3f);
- assertElement(pi, PathElementType.CURVE_TO, 5f, -1f, 6f, 5f, 7f, -5f);
- assertNoElement(pi);
-
- this.r.removeLast();
-
- pi = this.r.getPathIterator();
- assertElement(pi, PathElementType.MOVE_TO, 1f, 1f);
- assertElement(pi, PathElementType.LINE_TO, 2f, 2f);
- assertElement(pi, PathElementType.QUAD_TO, 3f, 0f, 4f, 3f);
- assertNoElement(pi);
-
- this.r.removeLast();
-
- pi = this.r.getPathIterator();
- assertElement(pi, PathElementType.MOVE_TO, 1f, 1f);
- assertElement(pi, PathElementType.LINE_TO, 2f, 2f);
- assertNoElement(pi);
-
- this.r.removeLast();
-
- pi = this.r.getPathIterator();
- assertElement(pi, PathElementType.MOVE_TO, 1f, 1f);
- assertNoElement(pi);
-
- this.r.removeLast();
-
- pi = this.r.getPathIterator();
- assertNoElement(pi);
-
- this.r.removeLast();
-
- pi = this.r.getPathIterator();
- assertNoElement(pi);
- }
-
- /**
- */
- public void testSetLastPointFloatFloat() {
- PathIterator2f pi = this.r.getPathIterator();
- assertElement(pi, PathElementType.MOVE_TO, 1f, 1f);
- assertElement(pi, PathElementType.LINE_TO, 2f, 2f);
- assertElement(pi, PathElementType.QUAD_TO, 3f, 0f, 4f, 3f);
- assertElement(pi, PathElementType.CURVE_TO, 5f, -1f, 6f, 5f, 7f, -5f);
- assertElement(pi, PathElementType.CLOSE);
- assertNoElement(pi);
-
- this.r.setLastPoint(123.456f, 789.1011f);
-
- pi = this.r.getPathIterator();
- assertElement(pi, PathElementType.MOVE_TO, 1f, 1f);
- assertElement(pi, PathElementType.LINE_TO, 2f, 2f);
- assertElement(pi, PathElementType.QUAD_TO, 3f, 0f, 4f, 3f);
- assertElement(pi, PathElementType.CURVE_TO, 5f, -1f, 6f, 5f, 123.456f, 789.1011f);
- assertElement(pi, PathElementType.CLOSE);
- assertNoElement(pi);
- }
-
- /**
- */
- public void testRemoveFloatFloat() {
- PathIterator2f pi = this.r.getPathIterator();
- assertElement(pi, PathElementType.MOVE_TO, 1f, 1f);
- assertElement(pi, PathElementType.LINE_TO, 2f, 2f);
- assertElement(pi, PathElementType.QUAD_TO, 3f, 0f, 4f, 3f);
- assertElement(pi, PathElementType.CURVE_TO, 5f, -1f, 6f, 5f, 7f, -5f);
- assertElement(pi, PathElementType.CLOSE);
- assertNoElement(pi);
-
- this.r.remove(2f, 2f);
-
- pi = this.r.getPathIterator();
- assertElement(pi, PathElementType.MOVE_TO, 1f, 1f);
- assertElement(pi, PathElementType.QUAD_TO, 3f, 0f, 4f, 3f);
- assertElement(pi, PathElementType.CURVE_TO, 5f, -1f, 6f, 5f, 7f, -5f);
- assertElement(pi, PathElementType.CLOSE);
- assertNoElement(pi);
-
- this.r.remove(4f, 3f);
-
- pi = this.r.getPathIterator();
- assertElement(pi, PathElementType.MOVE_TO, 1f, 1f);
- assertElement(pi, PathElementType.CURVE_TO, 5f, -1f, 6f, 5f, 7f, -5f);
- assertElement(pi, PathElementType.CLOSE);
- assertNoElement(pi);
-
- this.r.remove(6f, 5f);
-
- pi = this.r.getPathIterator();
- assertElement(pi, PathElementType.MOVE_TO, 1f, 1f);
- assertElement(pi, PathElementType.CLOSE);
- assertNoElement(pi);
-
- this.r.remove(6f, 5f);
-
- pi = this.r.getPathIterator();
- assertElement(pi, PathElementType.MOVE_TO, 1f, 1f);
- assertElement(pi, PathElementType.CLOSE);
- assertNoElement(pi);
- }
-
- /**
- */
- public void testContainsPointPoint2D() {
- PathIterator2f pi = this.r.getPathIterator();
- assertElement(pi, PathElementType.MOVE_TO, 1f, 1f);
- assertElement(pi, PathElementType.LINE_TO, 2f, 2f);
- assertElement(pi, PathElementType.QUAD_TO, 3f, 0f, 4f, 3f);
- assertElement(pi, PathElementType.CURVE_TO, 5f, -1f, 6f, 5f, 7f, -5f);
- assertElement(pi, PathElementType.CLOSE);
- assertNoElement(pi);
-
- assertTrue(this.r.containsPoint(new Point2f(2f, 2f)));
- assertFalse(this.r.containsPoint(new Point2f(4f, 4f)));
- assertTrue(this.r.containsPoint(new Point2f(6f, 5f)));
- assertFalse(this.r.containsPoint(new Point2f(-1f, 6f)));
- assertFalse(this.r.containsPoint(new Point2f(1234f, 5678f)));
- }
-
-}
\ No newline at end of file