@Test public void testScaling() { final int TRIALS = 100; final int CHECKS = 10; for (int i = 0; i < TRIALS; i++) { List<Point> points = makeRandomPoints(rand.nextInt(300) + 1); Circle reference = SmallestEnclosingCircle.makeCircle(points); for (int j = 0; j < CHECKS; j++) { double scale = rand.nextGaussian(); List<Point> newPoints = new ArrayList<>(); for (Point p : points) newPoints.add(new Point(p.x * scale, p.y * scale)); Circle scaled = SmallestEnclosingCircle.makeCircle(newPoints); assertEquals(reference.c.x * scale, scaled.c.x, EPSILON); assertEquals(reference.c.y * scale, scaled.c.y, EPSILON); assertEquals(reference.r * Math.abs(scale), scaled.r, EPSILON); } } }
public static Circle makeCircle(List<Point> points) { List<Point> shuffled = new ArrayList<>(points); Collections.shuffle(shuffled, new Random()); Circle c = null; for (int i = 0; i < shuffled.size(); i++) { Point p = shuffled.get(i); if (c == null || !c.contains(p)) c = makeCircleOnePoint(shuffled.subList(0, i + 1), p); } return c; }
SmallestEnclosingCircle { public static Circle makeCircle(List<Point> points) { List<Point> shuffled = new ArrayList<>(points); Collections.shuffle(shuffled, new Random()); Circle c = null; for (int i = 0; i < shuffled.size(); i++) { Point p = shuffled.get(i); if (c == null || !c.contains(p)) c = makeCircleOnePoint(shuffled.subList(0, i + 1), p); } return c; } }
SmallestEnclosingCircle { public static Circle makeCircle(List<Point> points) { List<Point> shuffled = new ArrayList<>(points); Collections.shuffle(shuffled, new Random()); Circle c = null; for (int i = 0; i < shuffled.size(); i++) { Point p = shuffled.get(i); if (c == null || !c.contains(p)) c = makeCircleOnePoint(shuffled.subList(0, i + 1), p); } return c; }  }
SmallestEnclosingCircle { public static Circle makeCircle(List<Point> points) { List<Point> shuffled = new ArrayList<>(points); Collections.shuffle(shuffled, new Random()); Circle c = null; for (int i = 0; i < shuffled.size(); i++) { Point p = shuffled.get(i); if (c == null || !c.contains(p)) c = makeCircleOnePoint(shuffled.subList(0, i + 1), p); } return c; }  static Circle makeCircle(List<Point> points); }
SmallestEnclosingCircle { public static Circle makeCircle(List<Point> points) { List<Point> shuffled = new ArrayList<>(points); Collections.shuffle(shuffled, new Random()); Circle c = null; for (int i = 0; i < shuffled.size(); i++) { Point p = shuffled.get(i); if (c == null || !c.contains(p)) c = makeCircleOnePoint(shuffled.subList(0, i + 1), p); } return c; }  static Circle makeCircle(List<Point> points);  }