Package geometry.java

Examples of geometry.java.Point


    // [{0.9404276009849271,0.4637809707158117}, {0.1343379470719266,0.856418745571239}, {0.41495871815701435,0.787983871063451}, {0.37085043512217486,0.7525604213257733}, {0.09576133429466949,0.8725551197532135}]
    @Test
    public void testDivideAndConquer() {
        List<Point> points = new ArrayList<>();
        for (int i = 0; i < 100; i++) {
            points.add(new Point(Math.random(), Math.random()));
        }
        Point[] inputA = points.toArray(new Point[points.size()]);
        Arrays.sort(inputA, Point.COMPARE_X);
        Point[] inputB = Arrays.copyOf(inputA, inputA.length);
       
View Full Code Here


            }
        return closest;
    }
    @Test
    public void testOptimizedBruteForce() {
        Point a = new Point(0.0, 2.0);
        Point b = new Point(2, 0);
        Point c = new Point(0.0, 2.0);
       
        Pair closest = Points.optimizedBruteForce(new Point[]{a, b, c});
        assertEquals(new Pair(a,c), closest);
    }
View Full Code Here

        Pair closest = Points.optimizedBruteForce(new Point[]{a, b, c});
        assertEquals(new Pair(a,c), closest);
    }
    @Test
    public void testClosestInStrip() {
        Point[] strip = { new Point(0, 1.2), new Point(0, 0.8), new Point(1, 0.9),
                new Point(1, 1.1), new Point(2, 1.3), new Point(2, 0.9) };
        Pair res = Points.closestInStrip(strip, 1.0);
        Pair exp = new Pair(new Point(1, 0.9), new Point(1, 1.1));
        assertEquals(exp, res);
    }
View Full Code Here

    private boolean same(Point[] as, Point[] bs) {
        return new HashSet<>(Arrays.asList(as)).equals(new HashSet<>(Arrays.asList(bs)));
    }
    @Test
    public void testPointEquals() {
        Point a = new Point(0.0, 2.0);
        Point b = new Point(2, 0);
        Point c = new Point(0.0, 2.0);
       
        assertTrue(a.equals(c));
        assertTrue(c.equals(a));
        assertFalse(a.equals(b));
       
        assertEquals(a, c);
        assertEquals(c, a);
        assertNotEquals(a, b);
View Full Code Here

        assertNotEquals(a, b);
       
    }
    @Test
    public void testDistFromX() {
        Point[] points = { new Point(-1, 0), new Point(0,0), new Point (-1, 1), new Point(0.5, 1),
                new Point(1, 0), new Point(1, -1) };
        Arrays.sort(points, Point.COMPARE_X);
        Point[] expected1 = { new Point(0,0), new Point(0.5, 1),
                new Point(1, 0), new Point(1, -1) };
        // mid is (0.5,1); xdist strictly less than
        Point[] result = Points.midStrip(points, 3, 1.0);
        assertTrue(same(expected1, result));
       
        // mid is (0.5,1)
        Point[] expected2 = { new Point(0.5, 1) };
        result = Points.midStrip(points, 3, 0.5);
        assertTrue(same(expected2, result));
    }
View Full Code Here

        result = Points.midStrip(points, 3, 0.5);
        assertTrue(same(expected2, result));
    }
    @Test
    public void testClosestPairSimple() {
        Point a = new Point(0, 0);
        Point b = new Point(0, 3);
        Pair res = Points.divideAndConquer(a, b);
        assertEquals(new Pair(a, b), res);
        Point c = new Point(3, 4);
        res = Points.divideAndConquer(a, b, c);
        assertEquals(new Pair(a, b), res);
    }
View Full Code Here

TOP

Related Classes of geometry.java.Point

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.