private boolean has_colinear(ArrayList<PlaPointInt> corners_list,PlaPointInt a_point){
  int count=corners_list.size();
  if (count < 2)   return false;
  for (int index=0; index < count - 1; index++) {
    PlaPointInt start=corners_list.get(index);
    PlaPointInt end=corners_list.get(index + 1);
    if (a_point.side_of(start,end) != PlaSide.COLLINEAR)     continue;
    double d_start_p=start.distance_square(a_point);
    double d_p_end=a_point.distance_square(end);
    double d_start_end=start.distance_square(end);
    if (d_start_end >= d_start_p) {
      if (d_start_end >= d_p_end) {
        return true;
      }
 else {
        corners_list.set(index,a_point);
        return true;
      }
    }
 else {
      if (d_start_end >= d_p_end) {
        corners_list.set(index + 1,a_point);
        return true;
      }
 else {
        corners_list.set(index,a_point);
        return true;
      }
    }
  }
  return false;
}

private boolean has_colinear ( ArrayList < PlaPointInt > corners_list , PlaPointInt a_point ) { int count = corners_list . size ( ) ; if ( count < 2 ) return false ; for ( int index = 0 ; index < count - 1 ; index ++ ) { PlaPointInt start = corners_list . get ( index ) ; PlaPointInt end = corners_list . get ( index + 1 ) ; if ( a_point . side_of ( start , end ) != PlaSide . COLLINEAR ) continue ; double d_start_p = start . distance_square ( a_point ) ; double d_p_end = a_point . distance_square ( end ) ; double d_start_end = start . distance_square ( end ) ; if ( d_start_end >= d_start_p ) { if ( d_start_end >= d_p_end ) { return true ; } else { corners_list . set ( index , a_point ) ; return true ; } } else { if ( d_start_end >= d_p_end ) { corners_list . set ( index + 1 , a_point ) ; return true ; } else { corners_list . set ( index , a_point ) ; return true ; } } } return false ; }
thest if the given point is somewhat colinear and should not be inserted note it is quite possible that the given point replaces a point already in the list
