/// <summary> /// 拟合求圆 /// </summary> /// <param name="IDian"></param> public void niHeQiuYuan(IDianWeiData IDian) { /*********************转换数据************************/ List <double> x_column_ = new List <double>(); List <double> y_row_ = new List <double>(); foreach (string num in IDian.X_column) { x_column_.Add(Convert.ToDouble(num)); } foreach (string num in IDian.Y_row) { y_row_.Add(Convert.ToDouble(num)); } /*******************数据赋值*************************/ HTuple column_x = new HTuple(); HTuple row_y = new HTuple(); int x_i = 0; foreach (double x_ in x_column_) { column_x[x_i] = x_; row_y[x_i] = y_row_[x_i]; x_i += 1; } /****************求圆心********************/ HTuple hv_Column = new HTuple(); HTuple hv_Row = new HTuple(); HTuple hv_Radius = new HTuple(); HTuple hv_StartPhi = new HTuple(); HTuple hv_EndPhi = new HTuple(); HTuple hv_PointOrder = new HTuple(); HObject contour = new HObject(); HOperatorSet.GenEmptyObj(out contour); HOperatorSet.GenContourPolygonXld(out contour, row_y, column_x); HOperatorSet.FitCircleContourXld(contour, "algebraic", -1, 0, 0, 3, 2, out hv_Row, out hv_Column, out hv_Radius, out hv_StartPhi, out hv_EndPhi, out hv_PointOrder); IDian.Yuan_xin_x_column = (double)hv_Column; IDian.Yuan_xin_y_row = (double)hv_Row; IDian.Yuan_ban_jing_r = (double)hv_Radius; IDian.Yuan_kai_shi_jiao = (double)hv_StartPhi; IDian.Yuan_jie_su_jiao = (double)hv_EndPhi; }
/// <summary> /// 写入数据 /// </summary> /// <param name="IDian"></param> /// <param name="x_"></param> /// <param name="y_"></param> public void xieRuShuJu(IDianWeiData IDian, List <string> x_, List <string> y_) { if (x_.Count == y_.Count) { foreach (string x_str_ in x_) { IDian.X_column.Add(x_str_); } foreach (string y_str in y_) { IDian.Y_row.Add(y_str); } } else { MessageBox.Show("数据有错"); } }