double A=0.5*(m_X1*m_X1-m_X2*m_X2+m_Y1*m_Y1-m_Y2*m_Y2+m_Z1*m_Z1-m_Z2*m_Z2);
double B=0.5*(m_X1*m_X1-m_X3*m_X3+m_Y1*m_Y1-m_Y3*m_Y3+m_Z1*m_Z1-m_Z3*m_Z3);
double a1=m_X1-m_X2;
double b1=m_Y1-m_Y2;
double c1=m_Z1-m_Z2;
double a2=m_X1-m_X3;
double b2=m_Y1-m_Y3;
double c2=m_Z1-m_Z3;
double E=b2*a1-b1*a2;
double F=a2*b1-a1*b2;
double G=b2*A-b1*B;
double H=b1*c2-b2*c1;
double J=a2*A-a1*B;
double K=a1*c2-a2*c1;
double E1=a1*c2-a2*c1;
double F1=a2*c1-a1*c2;
double G1=c2*A-c1*B;
double H1=b2*c1-b1*c2;
double J1=a2*A-a1*B;
double K1=a1*b2-a2*b1;
double E2=b1*c2-b2*c1;
double F2=b2*c1-b1*c2;
double G2=c2*A-c1*B;
double H2=a2*c1-a1*c2;
double J2=b2*A-b1*B;
double K2=a2*b1-a1*b2;
double z,y,x;
if (abs(E)>0.00000000000000000000001&&abs(F)>0.000000000000000001)
{
z=(2*m_X1*H/E+2*m_Y1*K/F+2*m_Z1-2*G*H/(E*E)-2*J*K/(F*F))/(2*(H*H/(E*E)+K*K/(F*F)+1));
x=(G+H*z)/E;
y=(J+K*z)/F;
}
else
{
if (abs(E1)>0.00000000000000000000001&&abs(F1)>0.000000000000000001)
{
y=(2*m_X1*H1/E1+2*m_Z1*K1/F1+2*m_Y1-2*G1*H1/(E1*E1)-2*J1*K1/(F1*F1))/(2*(H1*H1/(E1*E1)+K1*K1/(F1*F1)+1));
x=(G1+H1*y)/E1;
z=(J1+K1*y)/F1;
}
else
{
if (abs(E2)>0.00000000000000000000001&&abs(F2)>0.000000000000000001)
{
x=(2*m_Y1*H2/E2+2*m_Z1*K2/F2+2*m_X1-2*G2*H2/(E2*E2)-2*J2*K2/(F2*F2))/(2*(H2*H2/(E2*E2)+K2*K2/(F2*F2)+1));
y=(G2+H2*x)/E2;
z=(J2+K2*x)/F2;
}
else
{
AfxMessageBox("三点共线");
m_X="";
m_Y="";
m_Z="";
UpdateData(FALSE);
return ;
}
}
}
this->m_X.Format("%f",x);
this->m_Y.Format("%f",y);
this->m_Z.Format("%f",z);