lib/toxi/geom/Polygon2D.js
function(){
            var isPositive = false,
                num = this.vertices.length,
                prev,
                next,
                d0,
                d1,
                newIsP;

            for( var i = 0; i < num; i++ ){
                prev = (i===0) ? num -1 : i - 1;
                next = (i===num-1) ? 0 : i + 1;
                d0 = this.vertices[i].sub(this.vertices[prev]);
                d1 = this.vertices[next].sub(this.vertices[i]);
                newIsP = (d0.cross(d1) > 0);
                if( i === 0 ) {
                    isPositive = true;
                } else if( isPositive != newIsP ) {
                    return false;
                }
            }
            return true;
        }
function(){
            var isPositive = false,
                num = this.vertices.length,
                prev,
                next,
                d0,
                d1,
                newIsP;

            for( var i = 0; i < num; i++ ){
                prev = (i===0) ? num -1 : i - 1;
                next = (i===num-1) ? 0 : i + 1;
                d0 = this.vertices[i].sub(this.vertices[prev]);
                d1 = this.vertices[next].sub(this.vertices[i]);
                newIsP = (d0.cross(d1) > 0);
                if( i === 0 ) {
                    isPositive = true;
                } else if( isPositive != newIsP ) {
                    return false;
                }
            }
            return true;
        }
function ( ) { var isPositive = false , num = this . vertices . length , prev , next , d0 , d1 , newIsP ; for ( var i = 0 ; i < num ; i ++ ) { prev = ( i === 0 ) ? num - 1 : i - 1 ; next = ( i === num - 1 ) ? 0 : i + 1 ; d0 = this . vertices [ i ] . sub ( this . vertices [ prev ] ) ; d1 = this . vertices [ next ] . sub ( this . vertices [ i ] ) ; newIsP = ( d0 . cross ( d1 ) > 0 ) ; if ( i === 0 ) { isPositive = true ; } else if ( isPositive != newIsP ) { return false ; } } return true ; }
Checks if the polygon is convex.
@return true, if convex.
Checks if the polygon is convex .