private List<Point> divide(List<Point> points, Point p1, Point p2) {
        
        List<Point> hull = new ArrayList<>();
        
        if (points.isEmpty()) {
            return hull;
        } else if (points.size() == 1) {
            hull.add(points.get(0));
            return hull;
        }
        
        Point maxDistancePoint = points.get(0);
        List<Point> l1 = new LinkedList<>();
        List<Point> l2 = new LinkedList<>();
        double distance = 0.0;
        for (Point point : points) {
            if (point.getDistanceToLine(p1, p2) > distance) {
                distance = point.getDistanceToLine(p1, p2);
                maxDistancePoint = point;
            }
        }
        
        points.remove(maxDistancePoint);
        
        for (Point point : points) {
            if (point.isLeftOfLine(p1, maxDistancePoint)) {
                l1.add(point);
            } else if (point.isLeftOfLine(maxDistancePoint, p2)) {
                l2.add(point);
            }
        }
        
        points.clear();
        
        List <Point> hullPart = divide(l1, p1, maxDistancePoint);
        hull.addAll(hullPart);
        hull.add(maxDistancePoint);
        hullPart = divide(l2, maxDistancePoint, p2);
        hull.addAll(hullPart);
        
        return hull;
    }