src/main/java/de/javagl/geom/Points.java
/**
     * Returns a comparator that compares points by their distance to
     * the specified reference point
     * 
     * @param x The x-coordinate of the reference point
     * @param y The y-coordinate of the reference point
     * @return The comparator
     */
Returns a comparator that compares points by their distance to
the specified reference point

@param x The x-coordinate of the reference point
@param y The y-coordinate of the reference point
@return The comparator
Returns a comparator that compares points by their distance to the specified reference point @param x The x - coordinate of the reference point @param y The y - coordinate of the reference point @return The comparator
public static Comparator<Point2D> byDistanceComparator(
        double x, double y)
    {
        return new Comparator<Point2D>()
        {
            @Override
            public int compare(Point2D p0, Point2D p1)
            {
                double dx0 = p0.getX() - x;
                double dy0 = p0.getY() - y;
                double dx1 = p1.getX() - x;
                double dy1 = p1.getY() - y;
                double d0 = dx0 * dx0 + dy0 * dy0;
                double d1 = dx1 * dx1 + dy1 * dy1;
                return Double.compare(d0, d1);
            }
        };
    }
public static Comparator < Point2D > byDistanceComparator ( double x , double y ) { return new Comparator < Point2D > ( ) { @ Override public int compare ( Point2D p0 , Point2D p1 ) { double dx0 = p0 . getX ( ) - x ; double dy0 = p0 . getY ( ) - y ; double dx1 = p1 . getX ( ) - x ; double dy1 = p1 . getY ( ) - y ; double d0 = dx0 * dx0 + dy0 * dy0 ; double d1 = dx1 * dx1 + dy1 * dy1 ; return Double . compare ( d0 , d1 ) ; } } ; }
Returns a comparator that compares points by their distance to
 the specified reference point
Returns a comparator that compares points by their distance to the specified reference point