【计算几何,向量,圆】

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; }//周长
};
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值