src/index.js
function polygonRemoveCollinearPoints(polygon, precision){
    var num = 0;
    for(var i=polygon.length-1; polygon.length>3 && i>=0; --i){
        if(collinear(polygonAt(polygon, i-1),polygonAt(polygon, i),polygonAt(polygon, i+1),precision)){
            // Remove the middle point
            polygon.splice(i%polygon.length,1);
            num++;
        }
    }
    return num;
}
function polygonRemoveCollinearPoints(polygon, precision){
    var num = 0;
    for(var i=polygon.length-1; polygon.length>3 && i>=0; --i){
        if(collinear(polygonAt(polygon, i-1),polygonAt(polygon, i),polygonAt(polygon, i+1),precision)){
            // Remove the middle point
            polygon.splice(i%polygon.length,1);
            num++;
        }
    }
    return num;
}
function polygonRemoveCollinearPoints ( polygon , precision ) { var num = 0 ; for ( var i = polygon . length - 1 ; polygon . length > 3 && i >= 0 ; -- i ) { if ( collinear ( polygonAt ( polygon , i - 1 ) , polygonAt ( polygon , i ) , polygonAt ( polygon , i + 1 ) , precision ) ) { // Remove the middle point polygon . splice ( i % polygon . length , 1 ) ; num ++ ; } } return num ; }
Remove collinear points in the polygon.
@method removeCollinearPoints
@param  {Number} [precision] The threshold angle to use when determining whether two edges are collinear. Use zero for finest precision.
@return {Number}           The number of points removed
Remove collinear points in the polygon .