|
point perpencenter(point a, point b, point c){
line u, v;
u.a = c;
u.b.x = u.a.x - a.y + b.y;
u.b.y = u.a.y + a.x - b.x;
v.a = b;
v.b.x = v.a.x - a.y + c.y;
v.b.y = v.a.y + a.x - c.x;
return intersection(u, v);
}
//重心
//到三角形三顶点距离的平方和最小的点
//三角形内到三边距离之积最大的点
point barycenter(point a, point b, point c){
line u, v;
u.a.x = (a.x + b.x) / 2;
u.a.y = (a.y + b.y) / 2;
u.b = c;
v.a.x = (a.x + c.x) / 2;
v.a.y = (a.y + c.y) / 2;
v.b = b;
return intersection(u, v);
}
//费马点
//到三角形三顶点距离之和最小的点
point fermentpoint(point a, point b, point c){
point u, v;
double step = fabs(a.x) + fabs(a.y) + fabs(b.x) + fabs(b.y) + fabs(c.x) + fabs(c.y);
int i, j, k;
u.x = (a.x + b.x + c.x) / 3;
u.y = (a.y + b.y + c.y) / 3;
while (step > 1e-10)
for (k = 0; k < 10; step /= 2, k++)
for (i = -1; i <= 1; i++)
for (j = -1; j <= 1; j++){
v.x = u.x + step*i;
v.y = u.y + step*j;
if (distance(u, a) + distance(u, b) + distance(u, c) > distance(v, a) + distance(v, b) + distance(v, c))
u = v;
}
return u;
}
int main()
{
int n;
std::cin >> n;
while (n--)
{
point a, b, c;
std::cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y;
point center = perpencenter(a, b, c);
printf("%.4f %.4f\n", center.x, center.y);
}
}
|