@Test public void testHullPropertiesRandomly() { final int TRIALS = 100000; for (int i = 0; i < TRIALS; i++) { int len = rand.nextInt(100); List<Point> points = new ArrayList<>(); if (rand.nextBoolean()) { for (int j = 0; j < len; j++) points.add(new Point(rand.nextGaussian(), rand.nextGaussian())); } else { for (int j = 0; j < len; j++) points.add(new Point(rand.nextInt(10), rand.nextInt(10))); } List<Point> hull = ConvexHull.makeHull(points); assertTrue(isPolygonConvex(hull)); for (Point p : points) assertTrue(isPointInConvexPolygon(hull, p)); if (!points.isEmpty()) { int dupe = rand.nextInt(10) + 1; for (int j = 0; j < dupe; j++) points.add(points.get(rand.nextInt(points.size()))); List<Point> nextHull = ConvexHull.makeHull(points); assertEquals(hull, nextHull); } } }
public static List<Point> makeHull(List<Point> points) { List<Point> newPoints = new ArrayList<>(points); Collections.sort(newPoints); return makeHullPresorted(newPoints); }
ConvexHull { public static List<Point> makeHull(List<Point> points) { List<Point> newPoints = new ArrayList<>(points); Collections.sort(newPoints); return makeHullPresorted(newPoints); } }
ConvexHull { public static List<Point> makeHull(List<Point> points) { List<Point> newPoints = new ArrayList<>(points); Collections.sort(newPoints); return makeHullPresorted(newPoints); }  }
ConvexHull { public static List<Point> makeHull(List<Point> points) { List<Point> newPoints = new ArrayList<>(points); Collections.sort(newPoints); return makeHullPresorted(newPoints); }  static List<Point> makeHull(List<Point> points); static List<Point> makeHullPresorted(List<Point> points); }
ConvexHull { public static List<Point> makeHull(List<Point> points) { List<Point> newPoints = new ArrayList<>(points); Collections.sort(newPoints); return makeHullPresorted(newPoints); }  static List<Point> makeHull(List<Point> points); static List<Point> makeHullPresorted(List<Point> points);  }