public static final Vector nearestPointOnLineSegment(Vector line0, Vector line1, Vector point) {
		double lenSq = line0.distanceSq(line1);
		if(lenSq == 0.0) {
			return line0.clone();
		}
		
		Vector pv = point.clone().sub(line0);
		Vector wv = line1.clone().sub(line0);
		
		double t = pv.dot(wv) / lenSq;
		if(t <= 0) {
			return line0.clone();
		} else if(t >= 1) {
			return line1.clone();
		}
		
		return pv.set(line0).add(wv.scale(t));
	}