/* Calculates the intersection of the circle (x1, Y1, R) and the circle (X2, Y2, R). array p Stores the center (1 ~ N-1) and intersection (n ~), Array radius storage radius count is used to record the intersection points (including the number of centers) */For (INT I = 0; I <n; I ++) {// initialize double X1, y1, R; X1 = P [I]. x, Y1 = P [I]. y, r = radius [I]; double X2, Y2, R; x2 = P [J]. x, y2 = P [J]. y, r = radius [J]; double D = dist (x1, Y1, X2, Y2 ); // obtain the two circular centers from if (D> r + R | D <F (r-r) continue; // If (x1 = X2 & Y1 = Y2) continue when the two circles are separated; // else if (Y1 = Y2 & X1! = X2) {double A = (R * r-r * r)-(x1 * x1-x2 * x2)/(2 * x2-2 * X1 ); if (D = f (r-r) | D = R + r) // only one intersection point P [count]. X = A, P [count]. y = Y1, Count ++; else // two intersections {double T = r * r-(a-x1) * (a-x1); P [count]. X = A, P [count]. y = Y1 + SQRT (t), Count ++; P [count]. X = A, P [count]. y = y1-sqrt (t), Count ++;} else if (Y1! = Y2) {Double K, DISP; k = (2 * x1-2 * x2)/(2 * y2-2 * Y1); disp = (R * r-r * r) -(x1 * x1-x2 * x2)-(Y1 * y1-y2 * Y2)/(2 * y2-2 * Y1); // line offset double A, B, C; A = (k * k + 1); B = (2 * (disp-y1) * K-2 * X1); C = (disp-y1) * (disp-y1) -R * r + X1 * x1; double disc; disc = B * B-4 * a * C; // a quadratic equation discriminant if (D = f (r-r) | D = R + r) {P [count]. X = (-B)/(2 * A), P [count]. y = K * P [count]. X + disp, Count ++;} else {P [count]. X = (-B) + SQRT (disc)/(2 * A), P [count]. y = K * P [count]. X + disp, Count ++; P [count]. X = (-B)-SQRT (disc)/(2 * A), P [count]. y = K * P [count]. X + disp, Count ++ ;}}}