Examples of Vector2d


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

    @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

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

        //            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

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

                { 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

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

    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

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

        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

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

    }

    public double[] target() {
        final double[] t = new double[points.size() * 2];
        for (int i = 0; i < points.size(); i++) {
            final Vector2D p = points.get(i);
            final int index = i * 2;
            t[index]     = p.getX();
            t[index + 1] = p.getY();
        }

        return t;
    }
View Full Code Here

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

        final double r = params[2];

        final double[] model = new double[points.size() * 2];

        for (int i = 0; i < points.size(); i++) {
            final Vector2D p = points.get(i);

            // Find the circle point closest to the observed point
            // (observed points are points add through the addPoint method above)
            final double dX = cx - p.getX();
            final double dY = cy - p.getY();
            final double scaling = r / FastMath.hypot(dX, dY);
            final int index  = i * 2;
            model[index]     = cx - scaling * dX;
            model[index + 1] = cy - scaling * dY;

 
View Full Code Here

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

        final DerivativeStructure r = params[2];

        final DerivativeStructure[] model = new DerivativeStructure[points.size() * 2];

        for (int i = 0; i < points.size(); i++) {
            final Vector2D p = points.get(i);

            // Find the circle point closest to the observed point
            // (observed points are points add through the addPoint method above)
            final DerivativeStructure dX = cx.subtract(p.getX());
            final DerivativeStructure dY = cy.subtract(p.getY());
            final DerivativeStructure scaling = r.divide(dX.multiply(dX).add(dY.multiply(dY)).sqrt());
            final int index  = i * 2;
            model[index]     = cx.subtract(scaling.multiply(dX));
            model[index + 1] = cy.subtract(scaling.multiply(dY));

View Full Code Here

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

    private Vector2D create() {
        final double t = tP.sample();
        final double pX = cX.sample() + radius * FastMath.cos(t);
        final double pY = cY.sample() + radius * FastMath.sin(t);

        return new Vector2D(pX, pY);
    }
View Full Code Here

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

    public CircleScalar() {
        points  = new ArrayList<Vector2D>();
    }

    public void addPoint(double px, double py) {
        points.add(new Vector2D(px, py));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.