docs: private static double getSegDistSq(double px, double py, Coordinate a, Coordinate b) {
          double x = a.x;
          double y = a.y;
          double dx = b.x - x;
          double dy = b.y - y;
  
          if (dx != 0f || dy != 0f) {
              double t = ((px - x) * dx + (py - y) * dy) / (dx * dx + dy * dy);
  
              if (t > 1) {
                  x = b.x;
                  y = b.y;
              } else if (t > 0) {
                  x += dx * t;
                  y += dy * t;
              }
          }
  
          dx = px - x;
          dy = py - y;
  
          return dx * dx + dy * dy;
      }