class LineMath {

	public static Vector2 nearestPointOnLineSegment(final ILine line, final IVector2 point)
	{
		final double lambda = getLeadPointLambda(point, line);
		if (isLambdaInRange(lambda, 0, 1))
		{
			return getPointOnLineForLambda(line, lambda);
		}
		final double dist1 = VectorMath.distancePPSqr(line.getStart(), point);
		final double dist2 = VectorMath.distancePPSqr(line.getEnd(), point);
		return Vector2.copy(dist1 < dist2 ? line.getStart() : line.getEnd());
	}

	@SuppressWarnings("unused") private  LineMath();

}