src/index.js
function collinear(a,b,c,thresholdAngle) {
    if(!thresholdAngle){
        return triangleArea(a, b, c) === 0;
    } else {
        var ab = tmpPoint1,
            bc = tmpPoint2;

        ab[0] = b[0]-a[0];
        ab[1] = b[1]-a[1];
        bc[0] = c[0]-b[0];
        bc[1] = c[1]-b[1];

        var dot = ab[0]*bc[0] + ab[1]*bc[1],
            magA = Math.sqrt(ab[0]*ab[0] + ab[1]*ab[1]),
            magB = Math.sqrt(bc[0]*bc[0] + bc[1]*bc[1]),
            angle = Math.acos(dot/(magA*magB));
        return angle < thresholdAngle;
    }
}
function collinear(a,b,c,thresholdAngle) {
    if(!thresholdAngle){
        return triangleArea(a, b, c) === 0;
    } else {
        var ab = tmpPoint1,
            bc = tmpPoint2;

        ab[0] = b[0]-a[0];
        ab[1] = b[1]-a[1];
        bc[0] = c[0]-b[0];
        bc[1] = c[1]-b[1];

        var dot = ab[0]*bc[0] + ab[1]*bc[1],
            magA = Math.sqrt(ab[0]*ab[0] + ab[1]*ab[1]),
            magB = Math.sqrt(bc[0]*bc[0] + bc[1]*bc[1]),
            angle = Math.acos(dot/(magA*magB));
        return angle < thresholdAngle;
    }
}
function collinear ( a , b , c , thresholdAngle ) { if ( ! thresholdAngle ) { return triangleArea ( a , b , c ) === 0 ; } else { var ab = tmpPoint1 , bc = tmpPoint2 ; ab [ 0 ] = b [ 0 ] - a [ 0 ] ; ab [ 1 ] = b [ 1 ] - a [ 1 ] ; bc [ 0 ] = c [ 0 ] - b [ 0 ] ; bc [ 1 ] = c [ 1 ] - b [ 1 ] ; var dot = ab [ 0 ] * bc [ 0 ] + ab [ 1 ] * bc [ 1 ] , magA = Math . sqrt ( ab [ 0 ] * ab [ 0 ] + ab [ 1 ] * ab [ 1 ] ) , magB = Math . sqrt ( bc [ 0 ] * bc [ 0 ] + bc [ 1 ] * bc [ 1 ] ) , angle = Math . acos ( dot / ( magA * magB ) ) ; return angle < thresholdAngle ; } }
Check if three points are collinear
@method collinear
@param  {Array} a
@param  {Array} b
@param  {Array} c
@param  {Number} [thresholdAngle=0] Threshold angle to use when comparing the vectors. The function will return true if the angle between the resulting vectors is less than this value. Use zero for max precision.
@return {Boolean}
Check if three points are collinear