Package org.apache.commons.math3.geometry.euclidean.twod

Examples of org.apache.commons.math3.geometry.euclidean.twod.Vector2D


                             1.0e-10);
    }

    @Test
    public void testOffset() {
        Line l = new Line(new Vector2D(2, 1), new Vector2D(-2, -2), 1.0e-10);
        Assert.assertEquals(-5.0, l.getOffset(new Vector2D(5, -3)), 1.0e-10);
        Assert.assertEquals(+5.0, l.getOffset(new Vector2D(-5, 2)), 1.0e-10);
    }
View Full Code Here


        Assert.assertEquals(+5.0, l.getOffset(new Vector2D(-5, 2)), 1.0e-10);
    }

    @Test
    public void testDistance() {
        Line l = new Line(new Vector2D(2, 1), new Vector2D(-2, -2), 1.0e-10);
        Assert.assertEquals(+5.0, l.distance(new Vector2D(5, -3)), 1.0e-10);
        Assert.assertEquals(+5.0, l.distance(new Vector2D(-5, 2)), 1.0e-10);
    }
View Full Code Here

        Assert.assertEquals(+5.0, l.distance(new Vector2D(-5, 2)), 1.0e-10);
    }

    @Test
    public void testPointAt() {
        Line l = new Line(new Vector2D(2, 1), new Vector2D(-2, -2), 1.0e-10);
        for (double a = -2.0; a < 2.0; a += 0.2) {
            Point<Euclidean1D> pA = new Vector1D(a);
            Point<Euclidean2D> point = l.toSpace(pA);
            Assert.assertEquals(a, (l.toSubSpace(point)).getX(), 1.0e-10);
            Assert.assertEquals(0.0, l.getOffset(point),   1.0e-10);
View Full Code Here

        }
    }

    @Test
    public void testOriginOffset() {
        Line l1 = new Line(new Vector2D(0, 1), new Vector2D(1, 2), 1.0e-10);
        Assert.assertEquals(FastMath.sqrt(0.5), l1.getOriginOffset(), 1.0e-10);
        Line l2 = new Line(new Vector2D(1, 2), new Vector2D(0, 1), 1.0e-10);
        Assert.assertEquals(-FastMath.sqrt(0.5), l2.getOriginOffset(), 1.0e-10);
    }
View Full Code Here

        Assert.assertEquals(-FastMath.sqrt(0.5), l2.getOriginOffset(), 1.0e-10);
    }

    @Test
    public void testParallel() {
        Line l1 = new Line(new Vector2D(0, 1), new Vector2D(1, 2), 1.0e-10);
        Line l2 = new Line(new Vector2D(2, 2), new Vector2D(3, 3), 1.0e-10);
        Assert.assertTrue(l1.isParallelTo(l2));
        Line l3 = new Line(new Vector2D(1, 0), new Vector2D(0.5, -0.5), 1.0e-10);
        Assert.assertTrue(l1.isParallelTo(l3));
        Line l4 = new Line(new Vector2D(1, 0), new Vector2D(0.5, -0.51), 1.0e-10);
        Assert.assertTrue(! l1.isParallelTo(l4));
    }
View Full Code Here

    @Test(expected=ConvergenceException.class)
    public void testConvergenceException() {
        final Collection<Vector2D> points = new ArrayList<Vector2D>();

        points.add(new Vector2D(1, 1));
        points.add(new Vector2D(1, 5));
        points.add(new Vector2D(0, 7));
        points.add(new Vector2D(1, 10));
        points.add(new Vector2D(1, 20));
        points.add(new Vector2D(20, 20));
        points.add(new Vector2D(20, 40));
        points.add(new Vector2D(40, 1));

        @SuppressWarnings("unused")
        final ConvexHull2D hull = new MonotoneChain(true, 1).generate(points);
    }
View Full Code Here

    }

    @Test
    public void testTransform() throws MathIllegalArgumentException {

        Line l1 = new Line(new Vector2D(1.0 ,1.0), new Vector2D(4.0 ,1.0), 1.0e-10);
        Transform<Euclidean2D, Euclidean1D> t1 =
            Line.getTransform(new AffineTransform(0.0, 0.5, -1.0, 0.0, 1.0, 1.5));
        Assert.assertEquals(0.5 * FastMath.PI,
                            ((Line) t1.apply(l1)).getAngle(),
                            1.0e-10);

        Line l2 = new Line(new Vector2D(0.0, 0.0), new Vector2D(1.0, 1.0), 1.0e-10);
        Transform<Euclidean2D, Euclidean1D> t2 =
            Line.getTransform(new AffineTransform(0.0, 0.5, -1.0, 0.0, 1.0, 1.5));
        Assert.assertEquals(FastMath.atan2(1.0, -2.0),
                            ((Line) t2.apply(l2)).getAngle(),
                            1.0e-10);
View Full Code Here

    }

    @Test
    public void testIntersection() {
        Line    l1 = new Line(new Vector2D( 0, 1), new Vector2D(1, 2), 1.0e-10);
        Line    l2 = new Line(new Vector2D(-1, 2), new Vector2D(2, 1), 1.0e-10);
        Vector2D p  = l1.intersection(l2);
        Assert.assertEquals(0.5, p.getX(), 1.0e-10);
        Assert.assertEquals(1.5, p.getY(), 1.0e-10);
    }
View Full Code Here

    }

    @Test
    public void testAllIdentical() {
        final Collection<Vector2D> points = new ArrayList<Vector2D>();
        points.add(new Vector2D(1, 1));
        points.add(new Vector2D(1, 1));
        points.add(new Vector2D(1, 1));
        points.add(new Vector2D(1, 1));

        final ConvexHull2D hull = generator.generate(points);
        Assert.assertTrue(hull.getVertices().length == 1);
    }
View Full Code Here

    }

    @Test
    public void testCollinearPoints() {
        final Collection<Vector2D> points = new ArrayList<Vector2D>();
        points.add(new Vector2D(1, 1));
        points.add(new Vector2D(2, 2));
        points.add(new Vector2D(2, 4));
        points.add(new Vector2D(4, 1));
        points.add(new Vector2D(10, 1));

        final ConvexHull2D hull = generator.generate(points);
        checkConvexHull(points, hull);
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.math3.geometry.euclidean.twod.Vector2D

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.