>for(int right = 0; right < 2; right++) {
>for(int top = 0; top < 2; top++) {
>int apex_x = width * right;
>int apex_y = height * top;
より、それぞれpointsのindexが1,2,3,4の時、左上、左下、右上、右下からの要素について計算。
>Math.sqrt(Math.pow(x - apex_x, 2) + Math.pow(y - apex_y, 2));
で、その要素からの距離を出して、
>if (dist_apex < points[index].distance)
ですでに入ってる距離よりも小さければ代入。
初期値のときはDouble.MAX_VALUEなので確実に代入されるお、と。

コードの中に同じ部分があるcalcDistanceの計算は単なるピタゴラスの定理(sqrt(x^2+y^2))だよ。