判断两个圆的关系 特殊情况的考虑
作者:
WindSkyEnd
,
2024-11-24 16:16:27
,
所有人可见
,
阅读 1
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <sstream>
using namespace std;
typedef long long ll;
int main() {
int t;
cin >> t;
while (t--) {
double x1, y1, r1, x2, y2, r2;
cin >> x1 >> y1 >> r1 >> x2 >> y2 >> r2;
double dis = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); //圆心距
if (dis > (r1 + r2)) cout << "Disjoint" << endl; //同一个圆的情况考虑
else if (dis == (r1 + r2)) cout << "Externally" << endl;
else if (dis == abs(r1 - r2)) cout << "Internally" << endl;
else if (dis < abs(r1 - r2)) cout << "Contain" << endl;
else if (dis > abs(r1 - r2) && dis < abs(r1 + r2))
//相交圆的判断 圆心距大于半径差 小于半径和
cout << "Intersect" << endl;
else cout << "Unable to judge";
}
return 0;
}