public MaxPoints CharacterPoint(CalculationParameter CaculateParamater) { double MiddlePosition = CaculateParamater.Center; double R = CaculateParamater.R; int factor = CaculateParamater.Factor; MaxPoints res = new MaxPoints(); double x_Left = Math.Round(MiddlePosition - R, 2); double x_Right = Math.Round(MiddlePosition + R, 2); int IndexLeft = Location(AxisX, x_Left); int IndexRight = Location(AxisX, x_Right); List <double> K1 = QCDSDataFitWithDirection(factor, Define.LEFT_TO_RIGHT); List <double> K2 = QCDSDataFitWithDirection(factor, Define.RIGHT_TO_LEFT); List <double> X_Area = new List <double>(); List <double> Y_Area = new List <double>(); List <double> K1_Area = new List <double>(); List <double> K2_Area = new List <double>(); for (int i = IndexLeft; i <= IndexRight; i++) { X_Area.Add(AxisX[i]); Y_Area.Add(ProfileData_float[i]); K1_Area.Add(K1[i]); K2_Area.Add(K2[i]); } res = findMax(X_Area, Y_Area, K1_Area, K2_Area); return(res); }
public double GetPos(CalculationParameter CalculateParameter) { double MiddlePosition = CalculateParameter.Center; double R = CalculateParameter.R; int factor = CalculateParameter.Factor; MaxPoints CP = CharacterPoint(MiddlePosition, R, factor); return(Math.Round((CP.x[0] + CP.x[1]) - MiddlePosition, 2)); }
//返回轮廓的高度差,返回间隙高度差,焊缝高度差 public double GetHeightDifference(double MiddlePosition, double R, int factor) { double gapHeightDiff = 0; MaxPoints CP = CharacterPoint(MiddlePosition, R, factor); double x_Left = Math.Round(MiddlePosition - R, 2); double x_Right = Math.Round(MiddlePosition + R, 2); int IndexLeft = Location(AxisX, x_Left); //left start int IndexRight = Location(AxisX, x_Right); //right end int IndexLeftPoint = Location(AxisX, CP.x[0]); //left end int IndexRightPoint = Location(AxisX, CP.x[1]); //right start gapHeightDiff = gapHeightDifference(AxisX, ProfileData_float, IndexLeft, IndexLeftPoint, IndexRightPoint, IndexRight); return(gapHeightDiff); }
//返回焊缝轮廓的凸起 public double GetSeamDown(double MiddlePosition, double R, int factor) { double SeamDown = 0; MaxPoints CP = CharacterPoint(MiddlePosition, R, factor); int IndexLeftPoint = Location(AxisX, CP.x[0]); //left end int IndexRightPoint = Location(AxisX, CP.x[1]); //right start List <double> Seam = new List <double>(); for (int i = IndexLeftPoint; i <= IndexRightPoint; i++) { Seam.Add(ProfileData_float[i]); } SeamDown = Seam.Min() - CP.y.Min(); return(SeamDown); }
public double GetSeamUp(CalculationParameter CalculateParameter) { double MiddlePosition = CalculateParameter.Center; double R = CalculateParameter.R; int factor = CalculateParameter.Factor; double SeamUp = 0; MaxPoints CP = CharacterPoint(MiddlePosition, R, factor); int IndexLeftPoint = Location(AxisX, CP.x[0]); //left end int IndexRightPoint = Location(AxisX, CP.x[1]); //right start List <double> Seam = new List <double>(); for (int i = IndexLeftPoint; i <= IndexRightPoint; i++) { Seam.Add(ProfileData_float[i]); } SeamUp = Seam.Max() - CP.y.Max(); return(SeamUp); }
/* * MaxPoints.x contains the horizontal value of most left and most right,i.e [x1,x2],x1 is tht most left value * MaxPoints.y contains the vertical value of most left and most right,i.e [y1,y2],y1 is tht most left value * listK1, right to left * listK2, left to right */ private MaxPoints findMax(List <double> listX, List <double> listY, List <double> listK1, List <double> listK2) { MaxPoints max = new MaxPoints(); max.x = new List <double>(); max.y = new List <double>(); MaxPoints min = new MaxPoints(); min.x = new List <double>(); min.y = new List <double>(); // var v1, v2; max value //var v3, v4; min value int cnt = 0; List <double> tmp; bool isSummit = true; var v1 = listK1.Select((m, index) => new { index, m }).OrderByDescending(n => n.m).Last(); var v3 = listK1.Select((m, index) => new { index, m }).OrderByDescending(n => n.m).First(); var v2 = listK1.Select((m, index) => new { index, m }).OrderByDescending(n => n.m).Last(); var v4 = listK1.Select((m, index) => new { index, m }).OrderByDescending(n => n.m).First(); if (v1.index < v3.index) // summit,else valley { isSummit = true; } else { isSummit = false; } int a, b; while (isSummit) { cnt++; v1 = listK1.Select((m, index) => new { index, m }).OrderByDescending(n => n.m).Last(); v2 = listK2.Select((m, index) => new { index, m }).OrderByDescending(n => n.m).Last(); if (isSummit) { a = v1.index; b = v2.index; tmp = listK2; } else { b = v1.index; a = v2.index; tmp = listK1; } if (a > b && cnt < 2) //cnt < 2 to avoid infinate loop, it may happen { // set listK1[0-index] = 0 for (int i = 0; i <= a; i++) { tmp[i] = 0; continue; } } break; } cnt = 0; while (!isSummit) { cnt++; v3 = listK1.Select((m, index) => new { index, m }).OrderByDescending(n => n.m).First(); v4 = listK2.Select((m, index) => new { index, m }).OrderByDescending(n => n.m).First(); if (v3.index > v4.index && cnt < 2) //cnt < 2 to avoid infinate loop, it may happen { // set listK1[0-index] = 0 for (int i = 0; i <= v3.index; i++) { listK2[i] = 0; continue; } } break; } if (isSummit) { max.x.Add(listX[v1.index]); max.x.Add(listX[v2.index]); max.y.Add(listY[v1.index]); max.y.Add(listY[v2.index]); return(max); } else { min.x.Add(listX[v3.index]); min.x.Add(listX[v4.index]); min.y.Add(listY[v3.index]); min.y.Add(listY[v4.index]); return(min); } }
//返回轮廓特征点位置与中心位置的差,返回间隙位置,焊缝位置 public double GetPos(double MiddlePosition, double R, int factor) { MaxPoints CP = CharacterPoint(MiddlePosition, R, factor); return(Math.Round((CP.x[0] + CP.x[1]) - MiddlePosition, 2)); }
//返回轮廓特征点间隙,如为间隙则返回间隙宽度,如为焊缝则返回焊缝宽度 public double GetWidth(double MiddlePosition, double R, int factor) { MaxPoints CP = CharacterPoint(MiddlePosition, R, factor); return(Math.Round(CP.x[1] - CP.x[0], 2)); }