private boolean isConvex ( double [ ] a , double [ ] b , double [ ] c ) { // We're using factor to improve numerical contrast for small polygons. double area = ( b [ 0 ] - a [ 0 ] ) * factor * ( c [ 1 ] - a [ 1 ] ) - ( c [ 0 ] - a [ 0 ] ) * factor * ( b [ 1 ] - a [ 1 ] ) ; return ( - 1e-13 < area && area < 1e-13 ) ? ( mdist ( b , c ) > mdist ( a , b ) + mdist ( a , c ) ) : ( area < 0 ) ; }
Simple convexity test .