question: private boolean has_colinear ( PlaPointInt a_point ) { int count = point_alist . size ( ) ; if ( count < 2 ) return false ; for ( int index = 0 ; index < count - 1 ; index ++ ) { PlaPointInt start = point_alist . get ( index ) ; PlaPointInt end = point_alist . 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 { point_alist . set ( index , a_point ) ; return true ; } } else { if ( d_start_end >= d_p_end ) { point_alist . set ( index + 1 , a_point ) ; return true ; } else { point_alist . set ( index , a_point ) ; return true ; } } } return false ; }
target:  Return true if the given point is colinear with two points in the list and should NOT be added Now, the issue is that this point may be colinear (on the same line) but further away, so, it should be the one being kept, not the one currently in the list....