private static Set<VoronoiPoint> getSortedPointSet(List<VoronoiPoint> points) {

        final VoronoiPoint lowest = getLowestPoint(points);

        TreeSet<VoronoiPoint> set = new TreeSet<>(new Comparator<VoronoiPoint>() {
            @Override
            public int compare(VoronoiPoint a, VoronoiPoint b) {

                if (a == b || a.equals(b)) {
                    return 0;
                }

                // use longs to guard against int-underflow
                double thetaA = Math.atan2((long) a.y - lowest.y, (long) a.x - lowest.x);
                double thetaB = Math.atan2((long) b.y - lowest.y, (long) b.x - lowest.x);

                if (thetaA < thetaB) {
                    return -1;
                } else if (thetaA > thetaB) {
                    return 1;
                } else {
                    // collinear with the 'lowest' point, let the point closest to it come first

                    // use longs to guard against int-over/underflow
                    double distanceA = Math.sqrt(((lowest.x - a.x) * (lowest.x - a.x)) +
                            ((lowest.y - a.y) * (lowest.y - a.y)));
                    double distanceB = Math.sqrt(((lowest.x - b.x) * (lowest.x - b.x)) +
                            ((lowest.y - b.y) * (lowest.y - b.y)));

                    if (distanceA < distanceB) {
                        return -1;
                    } else {
                        return 1;
                    }
                }
            }
        });

        set.addAll(points);

        return set;
    }
Returns a sorted set of points from the list <code>points</code>. The
set of points are sorted in increasing order of the angle they and the
lowest point <tt>P</tt> make with the x-axis. If tow (or more) points
form the same angle towards <tt>P</tt>, the one closest to <tt>P</tt>
comes first.

@param points the list of points to sort.
@return       a sorted set of points from the list <code>points</code>.
@see GrahamScan#getLowestPoint(java.util.List)
vorolay/src/main/java/quatja/com/vorolay/GrahamScan.java