venn.js
function circleOverlap(r1, r2, d) {
        // no overlap
        if (d >= r1 + r2) {
            return 0;
        }

        // completely overlapped
        if (d <= Math.abs(r1 - r2)) {
            return Math.PI * Math.min(r1, r2) * Math.min(r1, r2);
        }

        var w1 = r1 - (d * d - r2 * r2 + r1 * r1) / (2 * d),
            w2 = r2 - (d * d - r1 * r1 + r2 * r2) / (2 * d);
        return circleArea(r1, w1) + circleArea(r2, w2);
    }
function circleOverlap(r1, r2, d) {
        // no overlap
        if (d >= r1 + r2) {
            return 0;
        }

        // completely overlapped
        if (d <= Math.abs(r1 - r2)) {
            return Math.PI * Math.min(r1, r2) * Math.min(r1, r2);
        }

        var w1 = r1 - (d * d - r2 * r2 + r1 * r1) / (2 * d),
            w2 = r2 - (d * d - r1 * r1 + r2 * r2) / (2 * d);
        return circleArea(r1, w1) + circleArea(r2, w2);
    }
function circleOverlap ( r1 , r2 , d ) { // no overlap if ( d >= r1 + r2 ) { return 0 ; } // completely overlapped if ( d <= Math . abs ( r1 - r2 ) ) { return Math . PI * Math . min ( r1 , r2 ) * Math . min ( r1 , r2 ) ; } var w1 = r1 - ( d * d - r2 * r2 + r1 * r1 ) / ( 2 * d ) , w2 = r2 - ( d * d - r1 * r1 + r2 * r2 ) / ( 2 * d ) ; return circleArea ( r1 , w1 ) + circleArea ( r2 , w2 ) ; }
Returns the overlap area of two circles of radius r1 and r2 - that
have their centers separated by distance d. Simpler faster
circle intersection for only two circles
Returns the overlap area of two circles of radius r1 and r2 - that have their centers separated by distance d . Simpler faster circle intersection for only two circles