【计算几何,向量,圆】

struct Vector
{
    double x, y;
    Vector() {}
    Vector(double a, double b) { x = a; y = b; }
    Vector operator-(Vector a) { return Vector(x - a.x, y - a.y); }
    Vector(Vector b, Vector a) { x = a.x - b.x; y = a.y - b.y; }
    Vector operator+(Vector a) { return Vector(x + a.x, y + a.y); }
    double Dot(Vector a) { return x * a.x + y * a.y; }
    double Cross(Vector a) { return x * a.y - y * a.x; }
    double Length() { return sqrt(x*x + y * y); }
};
struct circle
{
    Vector pt;
    double r;
    circle() {}
    circle(double x, double y, double z) { pt = Vector(x, y); r = z; }
    circle(int i) { scanf("%lf%lf%lf", &pt.x, &pt.y, &r); }
    inline double Area() {//面积
        return PI * r*r;
    }
    inline bool Intersect(circle C) {//相交
        double len = (C.pt - pt).Length();
        return Compare(len, (C.r + r)) < 0 && Compare(len, fabs(C.r - r)) > 0;
    }
    inline bool Inscribe(circle C) {//内切
        return Compare((C.pt - pt).Length(), fabs(C.r - r)) == 0;
    }
    inline bool External_Cutting(circle C) {//外切
        return Compare((C.pt - pt).Length(), fabs(C.r + r)) == 0;
    }
    inline double Perimeter() { return PI * 2 * r; }//周长
};

你可能感兴趣的:(计算几何)