main/src/georegression/metric/Distance2D_F64.java
public static double distanceSq( LineParametric2D_F64 line, Point2D_F64 p ) {
		double scale = Math.max(Math.abs(line.slope.x),Math.abs(line.slope.y));

		double t = ClosestPoint2D_F64.closestPointT( line, p , scale);

		double a = (line.slope.x/scale) * t + line.p.x;
		double b = (line.slope.y/scale) * t + line.p.y;

		double dx = p.x - a;
		double dy = p.y - b;

		return dx * dx + dy * dy;
	}
public static double distanceSq( LineParametric2D_F64 line, Point2D_F64 p ) {
		double scale = Math.max(Math.abs(line.slope.x),Math.abs(line.slope.y));

		double t = ClosestPoint2D_F64.closestPointT( line, p , scale);

		double a = (line.slope.x/scale) * t + line.p.x;
		double b = (line.slope.y/scale) * t + line.p.y;

		double dx = p.x - a;
		double dy = p.y - b;

		return dx * dx + dy * dy;
	}
<p>
Returns the Euclidean distance squared of the closest point on the line from a point.
</p>

@param line A line segment. Not modified.
@param p The point. Not modified.
@return Euclidean distance squared to the closest point on the line is away from the point.