SGU 414 圓的正交

2021-07-10 18:30:52 字數 1880 閱讀 6644

#include #include #include #include #include using namespace std;

const int maxn = 1e5 + 10;

int kase, t, n;

struct point

};typedef point vector;

typedef vectorpolygon;

vector operator +(vector a, vector b)//

vector operator -(point a, point b)//

vector operator *(vector a, double p)//

vector operator /(vector a, double p)//

bool operator <(const point &a, const point &b)//

const double eps = 1e-4;

int dcmp(double x)//

bool operator ==(const point &a, const point &b)//

double dot(vector a, vector b)//

double length(vector a)//

double cross(vector a, vector b)//

double angle(vector a, vector b)//

double distance(point a, point b)

double distance2(point a, point b)

struct circle

; circle(point c, double r): c(c), r(r) {}

bool operator < (const circle &other) const

bool operator == (const circle &other) const

point point(double a)

bool oncircle(point a) };

circle c[maxn];

circle read_circle()

struct math_line

else

}math_line(circle a, circle b)

math_line(double a = 0, double b = 0, double c = 0): a(a), b(b), c(c) {}

int line_state(const math_line &other) const

else return 1;//相交

} point getlineintersection(const math_line &other) const };

circle center;

int solve()

else if (!(l1.getlineintersection(math_line(c[i], c[i + 1])) == pre)) return -1;

} if (first == 0) return 1;

else return -2; }}

int main(int argc, char const *argv)

return 0;

}

兩個圓的正交圓圓心在直線上,滿足到兩圓心距離之差等於半徑之差。

特殊情況:兩圓重合,只計算乙個即可,兩元同心,必然無解。

那麼兩條不重合直線就可以確定唯一的圓心,去計算r是否相同即可。

你問我所有直線都重合怎麼辦?實際只有一條直線,那麼就是有多解。

對負數開方居然導致presentation error,令我十分吃驚。