main/src/georegression/metric/ClosestPoint2D_F64.java
public static double closestPointT( LineParametric2D_F64 line, double x, double y, double scale ) {
		double sx = line.slope.x/scale;
		double sy = line.slope.y/scale;

		double t = sx * ( x - line.p.x ) + sy * ( y - line.p.y );
		t /= sx * sx + sy * sy;

		return t;
	}
public static double closestPointT( LineParametric2D_F64 line, double x, double y, double scale ) {
		double sx = line.slope.x/scale;
		double sy = line.slope.y/scale;

		double t = sx * ( x - line.p.x ) + sy * ( y - line.p.y );
		t /= sx * sx + sy * sy;

		return t;
	}
public static double closestPointT ( LineParametric2D_F64 line , double x , double y , double scale ) { double sx = line . slope . x / scale ; double sy = line . slope . y / scale ; double t = sx * ( x - line . p . x ) + sy * ( y - line . p . y ) ; t /= sx * sx + sy * sy ; return t ; }
<p>
Computes the closest point along the line as a function of 't':<br>
[x, y] = [x_0, y_0] + t·[slopeX, slopeY]
</p>

@param line The line along which the closest point is being found. Not modified.
@param scale Scale factor. used to avoid numerical issues
@param x Point's x-coordinate
@param y Point's y-coordinate
@return Distance as a function of 't'
<p > Computes the closest point along the line as a function of t : <br > [ x y ] = [ x_0 y_0 ] + t· [ slopeX slopeY ] < / p >