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

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


    }

    @Test
    public void testCollinearPointsIncluded() {
        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 = createConvexHullGenerator(true).generate(points);
        checkConvexHull(points, hull, true);
    }
View Full Code Here


    }

    @Test
    public void testCollinearPointsIncludedReverse() {
        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(10, 1));
        points.add(new Vector2D(4, 1));

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

    }

    @Test
    public void testIdenticalPoints() {
        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(1, 1));

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

    }

    @Test
    public void testIdenticalPoints2() {
        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(1, 1));

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

    }

    @Test
    public void testClosePoints() {
        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(1.00001, 1));

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

    @Test
    public void testCollinearPointOnExistingBoundary() {
        // MATH-1135: check that collinear points on the hull are handled correctly
        //            when only a minimal hull shall be constructed
        final Collection<Vector2D> points = new ArrayList<Vector2D>();
        points.add(new Vector2D(7.3152, 34.7472));
        points.add(new Vector2D(6.400799999999997, 34.747199999999985));
        points.add(new Vector2D(5.486399999999997, 34.7472));
        points.add(new Vector2D(4.876799999999999, 34.7472));
        points.add(new Vector2D(4.876799999999999, 34.1376));
        points.add(new Vector2D(4.876799999999999, 30.48));
        points.add(new Vector2D(6.0959999999999965, 30.48));
        points.add(new Vector2D(6.0959999999999965, 34.1376));
        points.add(new Vector2D(7.315199999999996, 34.1376));
        points.add(new Vector2D(7.3152, 30.48));

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

        //            for each algorithm.

        List<Vector2D> points = new ArrayList<Vector2D>();

        // first case: 3 points are collinear
        points.add(new Vector2D(16.078200000000184, -36.52519999989808));
        points.add(new Vector2D(19.164300000000186, -36.52519999989808));
        points.add(new Vector2D(19.1643, -25.28136477910407));
        points.add(new Vector2D(19.1643, -17.678400000004157));

        ConvexHull2D hull = createConvexHullGenerator(false).generate(points);
        checkConvexHull(points, hull);

        hull = createConvexHullGenerator(true).generate(points);
        checkConvexHull(points, hull, true);
       
        points.clear();
       
        // second case: multiple points are collinear
        points.add(new Vector2D(0, -29.959696875));
        points.add(new Vector2D(0, -31.621809375));
        points.add(new Vector2D(0, -28.435696875));
        points.add(new Vector2D(0, -33.145809375));
        points.add(new Vector2D(3.048, -33.145809375));
        points.add(new Vector2D(3.048, -31.621809375));
        points.add(new Vector2D(3.048, -29.959696875));
        points.add(new Vector2D(4.572, -33.145809375));
        points.add(new Vector2D(4.572, -28.435696875));

        hull = createConvexHullGenerator(false).generate(points);
        checkConvexHull(points, hull);

        hull = createConvexHullGenerator(true).generate(points);
View Full Code Here

                { 9, 1 }, { 9, 2 }, { 9, 3 }, { 9, 4 }, { 10, -3 }, { 10, -2 },
                { 10, -1 }, { 10, 0 }, { 10, 1 }, { 10, 2 }, { 10, 3 },
                { 11, -1 }, { 11, 0 }, { 11, 1 } };

        for (int[] line : data) {
            points.add(new Vector2D(line[0], line[1]));
        }

        Vector2D[] referenceHull = new Vector2D[] {
            new Vector2D(-11.0, -1.0),
            new Vector2D(-10.0, -3.0),
            new Vector2D( -6.0, -7.0),
            new Vector2D( -3.0, -8.0),
            new Vector2D3.0, -8.0),
            new Vector2D6.0, -7.0),
            new Vector2D( 10.0, -3.0),
            new Vector2D( 11.0, -1.0),
            new Vector2D( 11.01.0),
            new Vector2D( 10.03.0),
            new Vector2D6.07.0),
            new Vector2D3.08.0),
            new Vector2D( -3.08.0),
            new Vector2D( -6.07.0),
            new Vector2D(-10.03.0),
            new Vector2D(-11.01.0),
        };

        ConvexHull2D convHull = generator.generate(points);
        Region<Euclidean2D> hullRegion = convHull.createRegion();
View Full Code Here

    protected final List<Vector2D> createRandomPoints(int size) {
        // create the cloud container
        List<Vector2D> points = new ArrayList<Vector2D>(size);
        // fill the cloud with a random distribution of points
        for (int i = 0; i < size; i++) {
            points.add(new Vector2D(random.nextDouble() * 2.0 - 1.0, random.nextDouble() * 2.0 - 1.0));
        }
        return points;
    }
View Full Code Here

        final Vector2D[] points = hull.getVertices();
        int sign = 0;

        for (int i = 0; i < points.length; i++) {
            Vector2D p1 = points[i == 0 ? points.length - 1 : i - 1];
            Vector2D p2 = points[i];
            Vector2D p3 = points[i == points.length - 1 ? 0 : i + 1];

            Vector2D d1 = p2.subtract(p1);
            Vector2D d2 = p3.subtract(p2);

            Assert.assertTrue(d1.getNorm() > 1e-10);
            Assert.assertTrue(d2.getNorm() > 1e-10);

            final double cross = MathArrays.linearCombination(d1.getX(), d2.getY(), -d1.getY(), d2.getX());
            final int cmp = Precision.compareTo(cross, 0.0, tolerance);

            if (sign != 0 && cmp != sign) {
                if (includesCollinearPoints && cmp == 0) {
                    // in case of collinear points the cross product will be zero
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.