private void GetUrgData() { TH_RefreshUrgData.TH_data.IsGetting = true; while (TH_RefreshUrgData.TH_data.IsSetting) { ; } urgPoints = new List <UrgPoint>(); double sumDistance = 0; int N = 0; for (int i = 0; i < TH_RefreshUrgData.TH_data.distance.Count; i++) { if (TH_RefreshUrgData.TH_data.distance[i] == 0) { continue; } UrgPoint ipoint = new UrgPoint(); ipoint.X = TH_RefreshUrgData.TH_data.x[i]; ipoint.Y = TH_RefreshUrgData.TH_data.y[i]; urgPoints.Add(ipoint); N++; sumDistance += TH_RefreshUrgData.TH_data.distance[i]; } TH_RefreshUrgData.TH_data.IsGetting = false; CON_parameter.Fit_Error = sumDistance / N * CON_parameter.Fit_Percent; }
private void Pole2Rectangular(List <long> polePoints, double angelStart, double anglePace) { urgPoints = new List <UrgPoint>(); for (int i = 0; i < polePoints.Count; i++) { if (polePoints[i] == 0) { continue; } double angle = (angelStart + anglePace * i) * Math.PI / 180; UrgPoint urgPoint; urgPoint.X = polePoints[i] * Math.Cos(angle); urgPoint.Y = polePoints[i] * Math.Sin(angle); urgPoints.Add(urgPoint); } return; // 按X排序,由大到小 for (int i = 1; i < urgPoints.Count; i++) { for (int j = 0; j < urgPoints.Count - i; j++) { if (urgPoints[j].X >= urgPoints[j + 1].X) { continue; } UrgPoint Temp_urgPoint = new UrgPoint(); Temp_urgPoint = urgPoints[j]; urgPoints[j] = urgPoints[j + 1]; urgPoints[j + 1] = Temp_urgPoint; } } }