#include<iostream>
using namespace std;
//空间中点的定义
class Point{
public:Point(double xx, double yy, double zz){
this->x = xx;
this->y = yy;
this->z = zz;
}
double GetX(){ return x; }
double GetY(){ return y; }
double GetZ(){ return z; }
Point(Point& point){}
private:double x, y, z;
};
//输出圆心和半径
void GetOut(double x, double y, double z, double r){
cout << x<<endl;
cout << y<<endl;
cout << z<<endl;
cout << r<<endl;
}
//圆心以及半径的计算
void getCircleCenter(Point &p1, Point &p2, Point &p3){
double k11, k12, k13, k14;
k11 = (p1.GetX() - p3.GetY())*(p2.GetZ() - p3.GetZ()) - (p2.GetY() - p3.GetY())*(p1.GetZ() - p3.GetZ());
k12 = (p2.GetX() - p3.GetX())*(p1.GetZ() - p3.GetZ()) - (p1.GetX() - p3.GetX())*(p2.GetZ() - p3.GetZ());
k13 = (p1.GetX() - p3.GetX())*(p2.GetY() - p3.GetY()) - (p2.GetX() - p3.GetX())*(p1.GetY() - p3.GetY());
k14 = -(k11*p3.GetX() + k12*p3.GetY() + p3.GetZ());
double k21, k22, k23, k24;
k21 = p2.GetX() - p1.GetX();
k22 = p2.GetY() - p1.GetY();
k23 = p2.GetZ() - p1.GetZ();
k24 = ((pow(p2.GetX(), 2) - pow(p1.GetX(), 2) + pow(p2.GetY(), 2) - pow(p1.GetY(), 2) + pow(p2.GetZ(), 2) - pow(p1.GetZ(), 2))) / 2.0;
double k31, k32, k33, k34;
k31 = p3.GetX() - p2.GetX();
k32 = p3.GetY() - p2.GetY();
k33 = p3.GetZ() - p2.GetZ();
k34 = ((pow(p3.GetX(), 2) - pow(p2.GetX(), 2) + pow(p3.GetY(), 2) - pow(p2.GetY(), 2) + pow(p3.GetZ(), 2) - pow(p2.GetZ(), 2))) / 2.0;
//求圆心半径
double x0, y0, z0, r;
x0 = (-k14*k22*k33 - k24*k32*k13 - k34*k12*k23 + k13*k22*k34 + k33*k12*k24 + k23*k32*k14) / (k11*k22*k33 + k12*k23*k31 + k21*k32*k13 - k13*k22*k31 - k12*k21*k33 - k23*k31*k11);
y0 = (-k11*k24*k33 - k21*k34*k13 - k14*k23*k31 + k13*k24*k31 + k23*k34*k11 + k14*k21*k33) / (k11*k22*k33 + k12*k23*k31 + k21*k32*k13 - k13*k22*k31 - k12*k21*k33 - k23*k31*k11);
z0 = (-k11*k22*k34 - k21*k32*k14 - k12*k24*k31 + k14*k22*k31 + k12*k21*k34 + k24*k32*k11) / (k11*k22*k33 + k12*k23*k31 + k21*k32*k13 - k13*k22*k31 - k12*k21*k33 - k23*k31*k11);
Point P0(x0, y0, z0);
r = sqrt(pow(p1.GetX() - P0.GetX(), 2) + pow(p1.GetY() - P0.GetY(), 2) + (pow(p1.GetZ() - P0.GetZ(), 2)));
pow(p1.GetZ() - P0.GetZ(), 2);
GetOut(x0, y0, z0, r);
}
int _tmain(int argc, _TCHAR* argv[])
{
Point P1(1, 0, 0);
Point P2(0, 0, 1);
Point P3(0, 1, 0);
getCircleCenter(P1, P2, P3);
return 0;
}