阅读背景:

两圆相交到两球相交

来源:互联网 

首先,定义一些东西

const double PI = acos(-1.0);
typedef struct point {
    double x,y;
    point() {
    }
    point(double a, double b) {
        x = a;
        y = b;
    }
    point operator -(const point &b)const {     //返回减去后的新点
        return point(x - b.x, y - b.y);
    }
    point operator +(const point &b)const {     //返回加上后的新点
        return point(x + b.x, y + b.y);
    }
    point operator *(const double &k)const {    //返回相乘后的新点
        return point(x * k, y * k);
    }
    point operator /(const double &k)const {    //返回相除后的新点
        return point(x / k, y / k);
    }
    double operator ^(const point &b)const {    //叉乘
        return x*b.y - y*b.x;
    }
    double operator *(const point &b)const {    //点乘
        return x*b.x + y*b.y;
    }
}point;
typedef struct circle {//圆
    double r;
    point centre;
}circle;

double dist(point p1, point p2) {       //返回平面上两点距离
    return sqrt((p1 - p2)*(p1 - p2));
}const double PI = acos(-1.0);
typed



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: