private static boolean isNonLeft(int i0,int i1,int i2,int i3,double[] pts){
  double l1, l2, l4, l5, l6, angle1, angle2, angle;
  l1=Math.sqrt(Math.pow(pts[i2 + 1] - pts[i1 + 1],2) + Math.pow(pts[i2] - pts[i1],2));
  l2=Math.sqrt(Math.pow(pts[i3 + 1] - pts[i2 + 1],2) + Math.pow(pts[i3] - pts[i2],2));
  l4=Math.sqrt(Math.pow(pts[i3 + 1] - pts[i0 + 1],2) + Math.pow(pts[i3] - pts[i0],2));
  l5=Math.sqrt(Math.pow(pts[i1 + 1] - pts[i0 + 1],2) + Math.pow(pts[i1] - pts[i0],2));
  l6=Math.sqrt(Math.pow(pts[i2 + 1] - pts[i0 + 1],2) + Math.pow(pts[i2] - pts[i0],2));
  angle1=Math.acos(((l2 * l2) + (l6 * l6) - (l4 * l4)) / (2 * l2 * l6));
  angle2=Math.acos(((l6 * l6) + (l1 * l1) - (l5 * l5)) / (2 * l6 * l1));
  angle=(Math.PI - angle1) - angle2;
  if (angle <= 0.0) {
    return (true);
  }
 else {
    return (false);
  }
}

private static boolean isNonLeft ( int i0 , int i1 , int i2 , int i3 , double [ ] pts ) { double l1 , l2 , l4 , l5 , l6 , angle1 , angle2 , angle ; l1 = Math . sqrt ( Math . pow ( pts [ i2 + 1 ] - pts [ i1 + 1 ] , 2 ) + Math . pow ( pts [ i2 ] - pts [ i1 ] , 2 ) ) ; l2 = Math . sqrt ( Math . pow ( pts [ i3 + 1 ] - pts [ i2 + 1 ] , 2 ) + Math . pow ( pts [ i3 ] - pts [ i2 ] , 2 ) ) ; l4 = Math . sqrt ( Math . pow ( pts [ i3 + 1 ] - pts [ i0 + 1 ] , 2 ) + Math . pow ( pts [ i3 ] - pts [ i0 ] , 2 ) ) ; l5 = Math . sqrt ( Math . pow ( pts [ i1 + 1 ] - pts [ i0 + 1 ] , 2 ) + Math . pow ( pts [ i1 ] - pts [ i0 ] , 2 ) ) ; l6 = Math . sqrt ( Math . pow ( pts [ i2 + 1 ] - pts [ i0 + 1 ] , 2 ) + Math . pow ( pts [ i2 ] - pts [ i0 ] , 2 ) ) ; angle1 = Math . acos ( ( ( l2 * l2 ) + ( l6 * l6 ) - ( l4 * l4 ) ) / ( 2 * l2 * l6 ) ) ; angle2 = Math . acos ( ( ( l6 * l6 ) + ( l1 * l1 ) - ( l5 * l5 ) ) / ( 2 * l6 * l1 ) ) ; angle = ( Math . PI - angle1 ) - angle2 ; if ( angle <= 0.0 ) { return ( true ) ; } else { return ( false ) ; } }
convex hull helper method for detecting a non left turn about 3 points
