src/index.js
function polygonMakeCCW(polygon){
    var br = 0,
        v = polygon;

    // find bottom right point
    for (var i = 1; i < polygon.length; ++i) {
        if (v[i][1] < v[br][1] || (v[i][1] === v[br][1] && v[i][0] > v[br][0])) {
            br = i;
        }
    }

    // reverse poly if clockwise
    if (!isLeft(polygonAt(polygon, br - 1), polygonAt(polygon, br), polygonAt(polygon, br + 1))) {
        polygonReverse(polygon);
        return true;
    } else {
        return false;
    }
}
function polygonMakeCCW(polygon){
    var br = 0,
        v = polygon;

    // find bottom right point
    for (var i = 1; i < polygon.length; ++i) {
        if (v[i][1] < v[br][1] || (v[i][1] === v[br][1] && v[i][0] > v[br][0])) {
            br = i;
        }
    }

    // reverse poly if clockwise
    if (!isLeft(polygonAt(polygon, br - 1), polygonAt(polygon, br), polygonAt(polygon, br + 1))) {
        polygonReverse(polygon);
        return true;
    } else {
        return false;
    }
}
function polygonMakeCCW ( polygon ) { var br = 0 , v = polygon ; // find bottom right point for ( var i = 1 ; i < polygon . length ; ++ i ) { if ( v [ i ] [ 1 ] < v [ br ] [ 1 ] || ( v [ i ] [ 1 ] === v [ br ] [ 1 ] && v [ i ] [ 0 ] > v [ br ] [ 0 ] ) ) { br = i ; } } // reverse poly if clockwise if ( ! isLeft ( polygonAt ( polygon , br - 1 ) , polygonAt ( polygon , br ) , polygonAt ( polygon , br + 1 ) ) ) { polygonReverse ( polygon ) ; return true ; } else { return false ; } }
Make sure that the polygon vertices are ordered counter-clockwise.
@method makeCCW
Make sure that the polygon vertices are ordered counter - clockwise .