I needed to calculate the intersecting points between two circles in Java and ended up with :
public XYPoint[] intersect(Circle b) {
double d = c.distance(b.c);
if (d >= r + b.r || r + d < b.r || b.r + d < r)
return null;
double ax2 = c.x * c.x;
double ay2 = c.y * c.y;
double bx2 = b.c.x * b.c.x;
double by2 = b.c.y * b.c.y;
double ar2 = r * r;
double br2 = b.r * b.r;
double lx = 2.0 * (b.c.x - c.x);
double ly = 2.0 * (b.c.y - c.y);
double l = ar2 - br2 - ax2 - ay2 + bx2 + by2;
double qa = lx * lx + ly * ly;
