大数相乘?或 相加?
myCircle CPylonBackCheckView::FittingCircle(vector<int> XX, vector<int> YY , int NUM ){ myCircle circle; int x1 = 0,x2 = 0,x3 = 0; int y1 = 0,y2 = 0,y3 = 0; int x1y1 = 0,x1y2 = 0,x2y1 = 0; int xtemp = 0 ; for (int i = 0; i < NUM ; i++) { x1 = x1 + XX[i]; x2 = x2 + XX[i]*XX[i]; x3 = x3 + XX[i]*XX[i]*XX[i]; y1 = y1 + YY[i]; y2 = y2 + YY[i]*YY[i]; y3 = y3 + YY[i]*YY[i]*YY[i]; x1y1 = x1y1 + XX[i]*YY[i]; x1y2 = x1y2 + XX[i]*YY[i]*YY[i]; x2y1 = x2y1 + XX[i]*XX[i]*YY[i]; } long double C = NUM * x2 - x1 * x1; long double D = NUM * x1y1 - x1 * y1; long double E = NUM * x3 + NUM * x1y2 - (x2 + y2) * x1; long double G = NUM * y2 - y1 * y1; long double H = NUM * x2y1 + NUM * y3 - (x2 + y2) * y1; long double a = (H * D - E * G)/(C * G - D * D); long double b = (H * C - E * D)/(D * D - G * C); long double c = -(a * x1 + b * y1 + x2 + y2)/NUM; double A = a/(-2); //x坐标 double B = b/(-2); //y坐标 double R = sqrt(a * a + b * b - 4 * c)/2; circle.xCenter = int(A); circle.yCenter = int(B); circle.Radius = int(R); return circle;}