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


Returns a comparator that compares points by their distance to the specified line
public static Comparator<Point2D> byDistanceToLineComparator(
        double x0, double y0, double x1, double y1)
    {
        return new Comparator<Point2D>()
        {
            @Override
            public int compare(Point2D p0, Point2D p1)
            {
                double d0 = Line2D.ptLineDistSq(
                    x0, y0, x1, y1, p0.getX(), p0.getY());
                double d1 = Line2D.ptLineDistSq(
                    x0, y0, x1, y1, p1.getX(), p1.getY());
                return Double.compare(d0, d1);
            }
        };
    }
public static Comparator < Point2D > byDistanceToLineComparator ( double x0 , double y0 , double x1 , double y1 ) { return new Comparator < Point2D > ( ) { @ Override public int compare ( Point2D p0 , Point2D p1 ) { double d0 = Line2D . ptLineDistSq ( x0 , y0 , x1 , y1 , p0 . getX ( ) , p0 . getY ( ) ) ; double d1 = Line2D . ptLineDistSq ( x0 , y0 , x1 , y1 , p1 . getX ( ) , p1 . getY ( ) ) ; return Double . compare ( d0 , d1 ) ; } } ; }
Returns a comparator that compares points by their distance to
 the specified line
Returns a comparator that compares points by their distance to the specified line