/** @return the index of the last point in the monotone chain */ private int findChainEnd(Coordinate[] pts, int start) { // determine quadrant for chain int chainQuad = Quadrant.quadrant(pts[start], pts[start + 1]); int last = start + 1; while (last < pts.length) { // if (last - start > 100) break; // compute quadrant for next possible segment in chain int quad = Quadrant.quadrant(pts[last - 1], pts[last]); if (quad != chainQuad) break; last++; } return last - 1; }