src/main/java/de/javagl/geom/Projections.java
/**
     * Drop the perpendicular on the line (x0,y0)-(x1,y1) from the point (x,y) 
     * and store the result in the given point and return it. If the given 
     * result point is <code>null</code>, then a new point will be created
     * and returned
     * 
     * @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
     * @param x The x-coordinate of the point to drop from
     * @param y The y-coordinate of the point to drop from
     * @param result The point that will store the result
     * @return The result
     */
Drop the perpendicular on the line (x0,y0)-(x1,y1) from the point (x,y)
and store the result in the given point and return it. If the given
result point is null, then a new point will be created
and returned


Drop the perpendicular on the line ( x0 y0 ) - ( x1 y1 ) from the point ( x y ) and store the result in the given point and return it . If the given result point is null then a new point will be created and returned
public static Point2D dropPerpendicular(
        double x0, double y0, 
        double x1, double y1,
        double x, double y,
        Point2D result)
    {
        double dx = x1 - x0;
        double dy = y1 - y0;
        double invLength = 1.0 / Math.sqrt(dx * dx + dy * dy);
        double dirX = dx * invLength;
        double dirY = dy * invLength;
        double pdx = x - x0;
        double pdy = y - y0;
        double dot = dirX * pdx + dirY * pdy;
        double resultX = x0 + dirX * dot;
        double resultY = y0 + dirY * dot;
        if (result == null)
        {
            return new Point2D.Double(resultX, resultY);
        }
        result.setLocation(resultX, resultY);
        return result;
    }
public static Point2D dropPerpendicular ( double x0 , double y0 , double x1 , double y1 , double x , double y , Point2D result ) { double dx = x1 - x0 ; double dy = y1 - y0 ; double invLength = 1.0 / Math . sqrt ( dx * dx + dy * dy ) ; double dirX = dx * invLength ; double dirY = dy * invLength ; double pdx = x - x0 ; double pdy = y - y0 ; double dot = dirX * pdx + dirY * pdy ; double resultX = x0 + dirX * dot ; double resultY = y0 + dirY * dot ; if ( result == null ) { return new Point2D . Double ( resultX , resultY ) ; } result . setLocation ( resultX , resultY ) ; return result ; }
Drop the perpendicular on the line (x0,y0)-(x1,y1) from the point (x,y)
 and store the result in the given point and return it.
Drop the perpendicular on the line ( x0 y0 ) - ( x1 y1 ) from the point ( x y ) and store the result in the given point and return it .