code: public int selectPoint( double x, double y ) {
          double mind = Double.POSITIVE_INFINITY;
          selection = -1;
          for( int i = 0; i < pts.size(); i++ ) {
              Coordinate coordinate = pts.get(i);
  
              double d = sqr(coordinate.x - x) + sqr(coordinate.y - y);
              if (d < mind && d < EPSILON) {
                  mind = d;
                  selection = i;
              }
          }
          return selection;
      }
docs: return index of control point near to (x,y) or -1 if nothing near