code: public float calculatePointSegmentSquareDistance (T out, T a, T b, T c) {
  		out.set(a);
  		tmpB.set(b);
  		tmpC.set(c);
  
  		T ab = tmpB.sub(a);
  		float abLen2 = ab.len2();
  		if (abLen2 != 0) {
  			float t = (tmpC.sub(a)).dot(ab) / abLen2;
  			out.mulAdd(ab, MathUtils.clamp(t, 0, 1));
  		}
  
  		return out.dst2(c);
  	}
docs: Returns the square distance of the nearest point on line segment {@code a-b}, from point {@code c}. Also, the {@code out}
  vector is assigned to the nearest point.
  @param out the output vector that contains the nearest point on return
  @param a the start point of the line segment
  @param b the end point of the line segment
  @param c the point to calculate the distance from