// returns 0-2 _unique_ points.
// res[0] lies on the left side of line (a-->b)
vector<pt> cross(const pt &a, double r1, pt b,
                 double r2) {
  b = b - a;
  if (fabs(b.dist2()) < eps) {
    if (fabs(r1) < eps && fabs(r2) < eps)
      return vector<pt>(1, a);

    assert(fabs(r1 - r2) > eps);
    return vector<pt>();
  }
  vector<pt> res = cross(b, r2,
      line(2 * b.x, 2 * b.y,
           sqr(r2) - sqr(r1) -
           sqr(b.x) - sqr(b.y)));
  for (int i = 0; i < sz(res); i++)
    res[i] = res[i] + a;
  return res;
}
예제 #2
0
bool rcmp(pt a, pt b) {
  a = a - _root; b = b - _root;
  int s = a * b;
  if (s) return s > 0;
  return a.dist2() < b.dist2();
}