structpt3{Doublex, Y, z;};intSolvecenterpointofcircle (Std::vector<pt3> PT,Doublecenterpoint[]) { DoubleA1, B1, C1, D1; DoubleA2, B2, C2, D2; DoubleA3, B3, C3, D3; DoubleX1 = pt[0].x, y1 = pt[0].y, Z1 = pt[0].z; Doublex2 = pt[1].x, y2 = pt[1].y, z2 = pt[1].z; Doublex3 = pt[2].x, y3 = pt[2].y, z3 = pt[2].z; A1= (y1*z2-y2*z1-y1*z3 + y3*z1 + y2*z3-y3*z2); B1=-(x1*z2-x2*z1-x1*z3 + x3*z1 + x2*z3-x3*z2); C1= (X1*y2-x2*y1-x1*y3 + x3*y1 + x2*y3-x3*y2); D1=-(x1*y2*z3-x1*y3*z2-x2*y1*z3 + x2*y3*z1 + x3*y1*z2-x3*y2*Z1); A2=2* (X2-x1); B2=2* (Y2-y1); C2=2* (Z2-Z1); D2= x1 * x1 + y1 * y1 + z1 * z1-x2 * x2-y2 * Y2-Z2 *Z2; A3=2* (X3-x1); B3=2* (Y3-y1); C3=2* (Z3-Z1); D3= x1 * x1 + y1 * y1 + z1 * z1-x3 * x3-y3 * y3-z3 *Z3; centerpoint[0] =-(b1*c2*d3-b1*c3*d2-b2*c1*d3 + b2*c3*d1 + b3*c1*d2-b3*c2*D1)/(a1*b2*c3-a1*b3*c2-a2*b1*c3 + a2*b3*c1 + a3*b1*c2-a3*b2*C1); centerpoint[1] = (a1*c2*d3-a1*c3*d2-a2*c1*d3 + a2*c3*d1 + a3*c1*d2-a3*c2*D1)/(a1*b2*c3-a1*b3*c2-a2*b1*c3 + a2*b3*c1 + a3*b1*c2-a3*b2*C1); centerpoint[2] =-(a1*b2*d3-a1*b3*d2-a2*b1*d3 + a2*b3*d1 + a3*b1*d2-a3*b2*D1)/(a1*b2*c3-a1*b3*c2-a2*b1*c3 + a2*b3*c1 + a3*b1*c2-a3*b2*C1); return 0;}
Derivation Process Reference:
http://blog.csdn.net/yanmy2012/article/details/8111600
Known space three points, solving circumscribed Circle Center coordinates, C + + programming implementation