dist/jcanvas-crescents.js
function getIntersection(x0, y0, r0, x1, y1, r1) {
	var dx = x1 - x0,
		dy = y1 - y0,
		d = sqrt(pow(dx, 2) + pow(dy, 2)),
		a = (pow(d, 2) + pow(r0, 2) - pow(r1, 2)) / (2 * d),
		x2 = x0 + (dx * a / d),
		y2 = y0 + (dy * a / d),
		h = sqrt(pow(r0, 2) - pow(a, 2)),
		rx = -dy * (h / d),
		ry = dx * (h / d),
		xi = x2 + rx,
		yi = y2 + ry;

	// Check if circles do not intersect or overlap completely
	if (d > (r0 + r1) || d < Math.abs(r0 - r1)) {
		return false;
	}
	return [xi, yi];
}
function getIntersection(x0, y0, r0, x1, y1, r1) {
	var dx = x1 - x0,
		dy = y1 - y0,
		d = sqrt(pow(dx, 2) + pow(dy, 2)),
		a = (pow(d, 2) + pow(r0, 2) - pow(r1, 2)) / (2 * d),
		x2 = x0 + (dx * a / d),
		y2 = y0 + (dy * a / d),
		h = sqrt(pow(r0, 2) - pow(a, 2)),
		rx = -dy * (h / d),
		ry = dx * (h / d),
		xi = x2 + rx,
		yi = y2 + ry;

	// Check if circles do not intersect or overlap completely
	if (d > (r0 + r1) || d < Math.abs(r0 - r1)) {
		return false;
	}
	return [xi, yi];
}
function getIntersection ( x0 , y0 , r0 , x1 , y1 , r1 ) { var dx = x1 - x0 , dy = y1 - y0 , d = sqrt ( pow ( dx , 2 ) + pow ( dy , 2 ) ) , a = ( pow ( d , 2 ) + pow ( r0 , 2 ) - pow ( r1 , 2 ) ) / ( 2 * d ) , x2 = x0 + ( dx * a / d ) , y2 = y0 + ( dy * a / d ) , h = sqrt ( pow ( r0 , 2 ) - pow ( a , 2 ) ) , rx = - dy * ( h / d ) , ry = dx * ( h / d ) , xi = x2 + rx , yi = y2 + ry ; // Check if circles do not intersect or overlap completely if ( d > ( r0 + r1 ) || d < Math . abs ( r0 - r1 ) ) { return false ; } return [ xi , yi ] ; }
Get the topmost intersection point of two circles
Get the topmost intersection point of two circles