﻿ 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:
 Notes:

 Lapping area between 2 circles Intercepts of a circle and the axis JScript code to find intersection points Two circles tangency
 Intersection summary Two circles tangency Two circles tangency conditions Intercepts of a circle Example 1 Example 2 Example 3 JScript code for intersection points
 Two circles intersection equations summary ▲
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 centre’s 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  axes ▲ 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.
 x1,2 = 0 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 intercept the y axis.
Apply the same steps to find the intercepts with the  x  axis there   y = 0
 y1,2 = 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 intercepts with the  y  axis:         y2 + By + C = 0
 x1,2 = 0 Substitute   y = 0   for intercepts with the x axis:         x2 + Ax + C = 0
 y1,2 = 0 Example 1 - x and y axes intercepts ▲
Find the x and y axis intercepts points of the circle:    x2 + y2 + 6x − 16 = 0.
For the  y  axis intercepts substitute   x = 0   into the circle equation:     y2 − 16 = 0.
And the  y  axis intercepts are:         y1 = 4         y2 = −4.
For the  x  axis intercepts substitute   y = 0   into the circle equation:     x2 + 6x − 16 = 0.
 The solution of this quadratic equation are: And the x axis intercepts are:         x1 = 2         x2 = −8
 Example 2 - x and y axes intercepts ▲
Find the  x  and  y  axes intercepts points of the circle    (x − 4)2 + (y + 1)2 = 16. for the y axis intercepts insert the value:   x = 0   to get:
y2 + 2y + 1 = 0
 The solution of this equation is: Because there is only one solution to this equation, the circle must be tangent to the y axis at point   (0 , −1).
For the  x  axis intercepts we insert the value:   y = 0   And get the quadratic equation:       x2 − 8x + 1 = 0.
 The solution of this equation is: And the x axes intercepts are at:   (7.873 , 0)   and  (0.127 , 0).
 Example 3 - Two circles overlapping area ▲
Find the overlapping area between the two circles given by the equations:    (x − 4)2 + (y + 2)2 = 16
and    (x + 2)2 + (y − 3)2 = 36. 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 intersect
// 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 intersect
//                 false if the two circles do not intersect
//**************************************************************
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 points are (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;
}
}