public static boolean isConvex( Polygon2D_I32 poly ) {
		// if the cross product of all consecutive triples is positive or negative then it is convex

		final int N = poly.size();
		int numPositive = 0;
		for (int i = 0; i < N; i++) {
			int j = (i+1)%N;
			int k = (i+2)%N;

			Point2D_I32 a = poly.vertexes.data[i];
			Point2D_I32 b = poly.vertexes.data[j];
			Point2D_I32 c = poly.vertexes.data[k];

			int dx0 = a.x-b.x;
			int dy0 = a.y-b.y;

			int dx1 = c.x-b.x;
			int dy1 = c.y-b.y;

			int z = dx0 * dy1 - dy0 * dx1;
			if( z > 0 )
				numPositive++;
			// z can be zero if there are duplicate points.
			// not sure if it should throw an exception if its "bad" or not
		}

		return( numPositive == 0 || numPositive == N );
	}
public static boolean isConvex( Polygon2D_I32 poly ) {
		

		final int N = poly.size();
		int numPositive = 0;
		for (int i = 0; i < N; i++) {
			int j = (i+1)%N;
			int k = (i+2)%N;

			Point2D_I32 a = poly.vertexes.data[i];
			Point2D_I32 b = poly.vertexes.data[j];
			Point2D_I32 c = poly.vertexes.data[k];

			int dx0 = a.x-b.x;
			int dy0 = a.y-b.y;

			int dx1 = c.x-b.x;
			int dy1 = c.y-b.y;

			int z = dx0 * dy1 - dy0 * dx1;
			if( z > 0 )
				numPositive++;
			
			
		}

		return( numPositive == 0 || numPositive == N );
	}
public static boolean isConvex ( Polygon2D_I32 poly ) { // if the cross product of all consecutive triples is positive or negative then it is convex final int N = poly . size ( ) ; int numPositive = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int j = ( i + 1 ) % N ; int k = ( i + 2 ) % N ; Point2D_I32 a = poly . vertexes . data [ i ] ; Point2D_I32 b = poly . vertexes . data [ j ] ; Point2D_I32 c = poly . vertexes . data [ k ] ; int dx0 = a . x - b . x ; int dy0 = a . y - b . y ; int dx1 = c . x - b . x ; int dy1 = c . y - b . y ; int z = dx0 * dy1 - dy0 * dx1 ; if ( z > 0 ) numPositive ++ ; // z can be zero if there are duplicate points. // not sure if it should throw an exception if its "bad" or not } return ( numPositive == 0 || numPositive == N ) ; }
Determines if the polugon is convex or concave.

@param poly Polygon
@return true if convex and false if concave
Determines if the polugon is convex or concave .