private Coordinate[] reduce(Coordinate[] inputPts){
  Coordinate[] polyPts=computeOctRing(inputPts);
  if (polyPts == null)   return inputPts;
  TreeSet reducedSet=new TreeSet();
  for (int i=0; i < polyPts.length; i++) {
    reducedSet.add(polyPts[i]);
  }
  for (int i=0; i < inputPts.length; i++) {
    if (!CGAlgorithms.isPointInRing(inputPts[i],polyPts)) {
      reducedSet.add(inputPts[i]);
    }
  }
  Coordinate[] reducedPts=CoordinateArrays.toCoordinateArray(reducedSet);
  if (reducedPts.length < 3)   return padArray3(reducedPts);
  return reducedPts;
}

private Coordinate [ ] reduce ( Coordinate [ ] inputPts ) { Coordinate [ ] polyPts = computeOctRing ( inputPts ) ; if ( polyPts == null ) return inputPts ; TreeSet reducedSet = new TreeSet ( ) ; for ( int i = 0 ; i < polyPts . length ; i ++ ) { reducedSet . add ( polyPts [ i ] ) ; } for ( int i = 0 ; i < inputPts . length ; i ++ ) { if ( ! CGAlgorithms . isPointInRing ( inputPts [ i ] , polyPts ) ) { reducedSet . add ( inputPts [ i ] ) ; } } Coordinate [ ] reducedPts = CoordinateArrays . toCoordinateArray ( reducedSet ) ; if ( reducedPts . length < 3 ) return padArray3 ( reducedPts ) ; return reducedPts ; }
uses a heuristic to reduce the number of points scanned to compute the hull . the heuristic is to find a polygon guaranteed to be in ( or on ) the hull , and eliminate all points inside it . a quadrilateral defined by the extremal points in the four orthogonal directions can be used , but even more inclusive is to use an octilateral defined by the points in the 8 cardinal directions . < p > note that even if the method used to determine the polygon vertices is not 100 % robust , this does not affect the robustness of the convex hull . < p > to satisfy the requirements of the graham scan algorithm , the returned array has at least 3 entries .
