code: public double distanceSqCorner( Point2D_F64 p ) {
  		double best = Double.MAX_VALUE;
  		for (int i = 0; i < 4; i++) {
  			double d = square.get(i).distance2(p);
  			if( d < best ) {
  				best = d;
  			}
  		}
  		return best;
  	}
docs: Finds the Euclidean distance squared of the closest corner to point p