}    for (int i = 0; i < npoints; i++) { int priorx = curx; int priory = cury; curx = xpoints[i]; cury = ypoints[i]; if (priorx == curx) { if (curx < x || curx >= x + w) continue; if ((cury >= y + h && priory <= y) || (cury <= y && priory >= y + h)) return true; continue; } if (priory == cury) { if (cury < y || cury >= y + h) continue; if ((curx >= x + w && priorx <= x) || (curx <= x && priorx >= x + w)) return true; continue; }  double slope = (double) (cury - priory) / (curx - priorx); double intersect = slope * (x - curx) + cury; if (intersect > y && intersect < y + h)
if ((evaluateCrossings(x, y, false, BIG_VALUE) & 1) != 0)
  public boolean intersects(double x, double y, double w, double h)  {    // First, the obvious bounds checks.    if (w <= 0 || h <= 0 || npoints == 0 ||        ! getBounds().intersects(x, y, w, h))      return false; // Disjoint bounds.    if ((x <= bounds.x && x + w >= bounds.x + bounds.width         && y <= bounds.y && y + h >= bounds.y + bounds.height)        || contains(x, y))      return true; // Rectangle contains the polygon, or one point matches.    // If any vertex is in the rectangle, the two might intersect.    int curx = 0;    int cury = 0;    for (int i = 0; i < npoints; i++)      {        curx = xpoints[i];        cury = ypoints[i];        if (curx >= x && curx < x + w && cury >= y && cury < y + h            && contains(curx, cury)) // Boundary check necessary.          return true;      }    // Finally, if at least one of the four bounding lines intersect any    // segment of the polygon, return true. Be careful of the semantics of    // Shape; coinciding lines do not necessarily return true.    for (int i = 0; i < npoints; i++)      {        int priorx = curx;        int priory = cury;        curx = xpoints[i];        cury = ypoints[i];        if (priorx == curx) // Vertical segment.          {            if (curx < x || curx >= x + w) // Outside rectangle.              continue;            if ((cury >= y + h && priory <= y)                || (cury <= y && priory >= y + h))              return true; // Bisects rectangle.            continue;          }        if (priory == cury) // Horizontal segment.          {            if (cury < y || cury >= y + h) // Outside rectangle.              continue;            if ((curx >= x + w && priorx <= x)                || (curx <= x && priorx >= x + w))              return true; // Bisects rectangle.            continue;          }        // Slanted segment.        double slope = (double) (cury - priory) / (curx - priorx);        double intersect = slope * (x - curx) + cury;        if (intersect > y && intersect < y + h) // Intersects left edge.          return true;        intersect = slope * (x + w - curx) + cury;        if (intersect > y && intersect < y + h) // Intersects right edge.          return true;        intersect = (y - cury) / slope + curx;        if (intersect > x && intersect < x + w) // Intersects bottom edge.          return true;        intersect = (y + h - cury) / slope + cury;        if (intersect > x && intersect < x + w) // Intersects top edge.          return true;      }    return false;  }