﻿ Two circles intersection calculator
Two circles intersection calculator
 Circles form:     (x-a)2 + (y-b)2 = r2 Circle 1: ( x - )2 + ( y - )2 = 2 Circle 2: ( x - )2 + ( y - )2 = 2
 Circles form:     x2 + y2 + Ax + By + C = 0 Circle 1: x2 + y2 + x + y + = 0 Circle 2: x2 + y2 + x + y + = 0
 Intersection coordinates (x , y): Line passing through intersection points: Distance between circles centers: Equation of the line passing circles centers: Common area between circles: Circle 1 - x and y axis intercepts: Circle 2 - x and y axis intercepts:
 Lapping area between 2 circles Intercepts of a circle and the axis jscript code to find intersection points Two circles tangency
 Two circles intersection equations ▲
Intersection points (x1 , y1) and
(x2 , y2) between two circles. NOTE:   if   a   is negative as in the equation   (x − a)2 + ⋯. then the center of the circle is at the positive x axis. The intersection points should be only real numbers.
Example: if circle center is at the point (-2 , 3) then the circle equation is:    (x + 2)2 + (y – 3)2 = 0

∂ is the area of the triangle formed by the two circle centers and one of the intersection point. The sides of this triangle are S, r0 and r1 , the area is calculated by Heron' s formula.
 Example: given two circles: (x – 1)2 + (y – 2)2 = 9     and (x – 3)2 + (y + 1)2 = 16 Find the intersection points and the distance between circles centers.
Solution:   from circles equations
 a = 1 b = 2 r0 = 3 c = 3 d = – 1 r1 = 4
∂ = 5.19 (intersection points exists)
The circles intersects at the points: (3.86 , 2.91) and (– 0.94 , – 0.29)
Equation of the line connecting intersection points:
y = 0.66x + 0.33
Equation of the line connecting the two circles centers:
y = – 1.5x + 3.5
Distance between circles centers:  Distance between two circles centers: Conditions for intersection between two circles:
r0 + r1 > D       and       D > |r0 – r1|

Equation of the line connecting the two intersection points: Equation of the line connecting the two centers of the circles: Two circles intersection points:   Distance between two circles centers: Condition for intersection between two circles: and Equation of the line connecting the two intersection points:
(B – E)y + (A – D)x + (C – F) = 0
 (slope) (line equation) Equation of the line connecting the two centers of the circles:
 (slope) (line) Two circles intersection points:   Two circles tangency ▲
Two circles tangency point (xt , yt):
centers of the circles are at (x1, y1) and (x2, y2)  Example: Find the tangency point of
 the circles: (x − 4)2 + ( y + 1)2 = 9 and (x + 1)2 + ( y + 1)2 = 4
Check if the circles are tangent:
(− 4 − 1)2 + (1 − 1) = (3 ± 2)2
25 = (3 + 2)2 = 25       outer tangent  (x − x1)2 + (y − y1)2 = r12     and     (x − x2)2 + (y − y2)2 = r22
Condition for tangency of two circles:
(x1 − x2)2 + (y1 − y2)2 = (r1 ± r2)2
(+ sign is for external tangency and − for internal tangency)
If we have the two radii r1 and r2 and the distance between the centers  d,  then conditions for tangency are:
 Outer circles tangency: r1 + r2 = d Inner circles tangency: |r1 − r2| = d

Tangency point coordinate:  (+ sign is for external tangency and − for internal tangency).
x2 + y2 + Ax + By + C = 0     and     x2 + y2 + Dx + Ey + F = 0
Condition for tangency of two circles: Tangency point coordinate:  Two circles tangency conditions ▲
Description                   Condition Circles equations:
(x − x1)2 + (y − y1)2 = r12
(x − x2)2 + (y − y2)2 = r22
Distance between circles centers  d  is: d < |r1 − r2| Inner tangency
|r1 − r2| Intersecting circles
|r1 − r2| < d < r1 + r2 Outer tangency
d = r1 + r2 Intersecting circles
d > r1 + r2
 Intercepts of a circle and the x and y axis ▲ Example: Find the x and y axis intercepts points of the circle
(x − 4)2 + (y + 1)2 = 16
Solution: for the y axis intercepts insert the value:     x = 0
Then we get:         y2 + 2y + 1 = 0
There is only one solution:     y = -1
That is the case when   a = r,   so the circle is tangent to the y axis at point         y = -1
For the x axis intercepts we insert the value:     y = 0
x2 − 8x + 1 = 0
And the x axis intercepts are at:
 x1 = 7.87 x2 = 0.127

Example: Find the x and y axis intercepts points of the circle
x2 + y2 + 6x − 16 = 0
Solution: for the y axis intercepts insert x = 0
y2 − 16 = 0
 y1 = 4 y2 = -4
for the x axis intercepts insert y = 0
x2 + 6x − 16 = 0
 x1 = 2 x2 = -8
Circle equation:      (x − a)2 + (y − b)2 = r2
In order to find the circle intercepts with the y axis substitute the value x = 0 in the circle equation and solve for y.
a2 + (y − b)2 = r2
y2 − 2by + a2 + b2 − r2 = 0
We got a quadratic equation with the y unknown.  When     r > a    then 2 y axis intercepts points exists.
When     r = a    then the circle is tangent to the y axis.
When     r < a    then the circle does not intercepts the y axis.
Apply the same steps to find the intercepts with the x axis there   y = 0  When     r > b    then 2 x axis intercepts points exists.
When     r = b    then the circle is tangent to the x axis.
When     r < b    then the circle does not intercepts the x axis.
Circle equation:      x2 + y2 + Ax + By + C = r2
Substitute     x = 0     for y axis intercepts points:
y2 + By + C = 0  Substitute     y = 0     for x axis intercepts points:
x2 + Ax + C = 0  jscript code to calculate two circles intersection points ▲
//Definition of a circle object
function circle(a, b, r) { this.a = a; this.b = b; this.r = r; }
// This values should be declared as global variables
// so their values can be used without return their values
var x1, y1, x2, y2;
function calculateIntersection() {
// Calling function
var circle1 = new circle(2, 4, 5);
var circle2 = new circle(-1, 0, 3);
if (twoCirclesIntersection(circle1, circle2)) {
// If true - then the circles intersects
// the intersection points are given by (x1, y1) and (x2, y2)
..... Continue with desirable code .....
}
}
function twoCirclesIntersection(c1, c2){
//**************************************************************
//Calculating intersection coordinates (x1, y1) and (x2, y2) of
//two circles of the form (x - c1.a)^2 + (y - c1.b)^2 = c1.r^2
//                        (x - c2.a)^2 + (y - c2.b)^2 = c2.r^2
//
// Return value:   true if the two circles intersects
//                 false if the two circles do not intersects
//**************************************************************
var val1, val2, test;
// Calculating distance between circles centers
var D = Math.sqrt((c1.a - c2.a) * (c1.a - c2.a) + (c1.b - c2.b) * (c1.b - c2.b));
if (((c1.r + c2.r) >= D) && (D >= Math.abs(c1.r - c2.r))) {
// Two circles intersects or tangent
// Area according to Heron's formula
//----------------------------------
var a1 = D + c1.r + c2.r;
var a2 = D + c1.r - c2.r;
var a3 = D - c1.r + c2.r;
var a4 = -D + c1.r + c2.r;
var area = Math.sqrt(a1 * a2 * a3 * a4) / 4;
// Calculating x axis intersection values
//---------------------------------------
val1 = (c1.a + c2.a) / 2 + (c2.a - c1.a) * (c1.r * c1.r - c2.r * c2.r) / (2 * D * D);
val2 = 2 * (c1.b - c2.b) * area / (D * D);
x1 = val1 + val2;
x2 = val1 - val2;
// Calculating y axis intersection values
//---------------------------------------
val1 = (c1.b + c2.b) / 2 + (c2.b - c1.b) * (c1.r * c1.r - c2.r * c2.r) / (2 * D * D);
val2 = 2 * (c1.a - c2.a) * area / (D * D);
y1 = val1 - val2;
y2 = val1 + val2;
// Intersection pointsare (x1, y1) and (x2, y2)
// Because for every x we have two values of y, and the same thing for y,
// we have to verify that the intersection points as chose are on the
// circle otherwise we have to swap between the points
test = Math.abs((x1 - c1.a) * (x1 - c1.a) + (y1 - c1.b) * (y1 - c1.b) - c1.r * c1.r);
if (test > 0.0000001) {
// point is not on the circle, swap between y1 and y2
// the value of 0.0000001 is arbitrary chose, smaller values are also OK
// do not use the value 0 because of computer rounding problems
var tmp = y1;
y1 = y2;
y2 = tmp;
}
return true;
}
else {
// circles are not intersecting each other
return false;
}
}