private string calcHalfOpened(List<Barier> bariers, double WpDop, out double Wp, out double q) { Wp = 0; double q0 = 0.0038 * R * R - 0.5762 * R + 50.857; if (bariers.Count==1) { Wp = calcBarier(bariers[0]); q = q0 + Wp; if (Wp < WpDop) return "Пригоден"; else return "Непригоден"; } else { bool prevousMerged = false; Barier barier = null; for (int i=1; i<bariers.Count; i++) { if (prevousMerged)//если предыдыщие препятствия слились { if (merge(barier, bariers[i])) { //слияние препятствий Barier newBarier = new Barier(interval); newBarier.addPoint(barier.points[0]); double middlePointX = barier.points[1].X + (bariers[i].points[1].X - barier.points[1].X) / 2; double middlePointY = barier.points[1].Y > bariers[i].points[1].Y ? barier.points[1].Y : bariers[i].points[1].Y; newBarier.addPoint(new PointPair(middlePointX, middlePointY)); newBarier.addPoint(bariers[i].points[2]); Wp += calcBarier(newBarier); barier = newBarier; prevousMerged = true; i++; } else { Wp += calcBarier(bariers[i]); prevousMerged = false; } } else { if (merge(bariers[i-1], bariers[i])) { //слияние препятствий Barier newBarier = new Barier(interval); newBarier.addPoint(bariers[i - 1].points[0]); double middlePointX = bariers[i - 1].points[1].X + (bariers[i].points[1].X - bariers[i - 1].points[1].X) / 2; double middlePointY = bariers[i - 1].points[1].Y > bariers[i].points[1].Y ? bariers[i - 1].points[1].Y : bariers[i].points[1].Y; newBarier.addPoint(new PointPair(middlePointX, middlePointY)); newBarier.addPoint(bariers[i].points[2]); barier = newBarier; Wp += calcBarier(barier); prevousMerged = true; i++; } else { Wp += calcBarier(bariers[i - 1]); Wp += calcBarier(bariers[i]); prevousMerged = false; } } } q = q0 + Wp; if (Wp < WpDop) return "Пригоден"; else return "Непригоден"; } }
private string calcClosed(List<Barier> bariers, double WpDop, out double Wp, out double q) { List<Barier> closedBariers = new List<Barier>(); for (int i = 0; i < bariers.Count; i++) if (bariers[i].points[1].Y >= (interval.profile.points).SplineInterpolateX(bariers[i].points[1].X, tension)) { closedBariers.Add(bariers[i]); } Wp = 0; double q0 = 0.0038 * R * R - 0.5762 * R + 50.857; if (bariers.Count == 1) { Wp = calcBarier(bariers[0]); q = q0 + Wp; if (Wp < WpDop) return "Пригоден"; else return "Непригоден"; } else { if (closedBariers.Count == 1) { #region Одно препятствие закрывающее линию прямой видимости bool prevousMerged = false; Barier barier = null; for (int i = 1; i < bariers.Count; i++) { if (prevousMerged)//если предыдыщие препятствия слились { if (merge(barier, bariers[i])) { //слияние препятствий Barier newBarier = new Barier(interval); newBarier.addPoint(barier.points[0]); double middlePointX = barier.points[1].X + (bariers[i].points[1].X - barier.points[1].X) / 2; double middlePointY = barier.points[1].Y > bariers[i].points[1].Y ? barier.points[1].Y : bariers[i].points[1].Y; newBarier.addPoint(new PointPair(middlePointX, middlePointY)); newBarier.addPoint(bariers[i].points[2]); Wp += calcBarier(newBarier); barier = newBarier; prevousMerged = true; i++; } else { Wp += calcBarier(bariers[i]); prevousMerged = false; } } else { if (merge(bariers[i - 1], bariers[i])) { //слияние препятствий Barier newBarier = new Barier(interval); newBarier.addPoint(bariers[i - 1].points[0]); double middlePointX = bariers[i - 1].points[1].X + (bariers[i].points[1].X - bariers[i - 1].points[1].X) / 2; double middlePointY = bariers[i - 1].points[1].Y > bariers[i].points[1].Y ? bariers[i - 1].points[1].Y : bariers[i].points[1].Y; newBarier.addPoint(new PointPair(middlePointX, middlePointY)); newBarier.addPoint(bariers[i].points[2]); barier = newBarier; Wp += calcBarier(barier); prevousMerged = true; i++; } else { Wp += calcBarier(bariers[i - 1]); Wp += calcBarier(bariers[i]); prevousMerged = false; } } } q = q0 + Wp; if (Wp < WpDop) return "Пригоден"; else return "Непригоден"; #endregion } else { #region Несколько препятствий закрывающих линию прямой видимости PointPair A = closedBariers[0].points[0]; PointPair B = closedBariers[0].points[1]; PointPair C = closedBariers[0].points[2]; double Y = B.Y - (((A.Y - C.Y) * B.X + (A.X * C.Y - A.Y * C.X)) / (C.X - A.X));//высота У(см. формулу 15 в методичке Садомовского) double r = C.X - A.X; //ширина препятствия double Rpr = (r * r) / (8 * Y);//формула 15(Садомовский) double K = B.X / R; double H0 = ((PointPairList)interval.lineOfSight.Points).SplineInterpolateX(B.X, tension) - interval.H0.SplineInterpolateX(B.X, tension); double Mu = Math.Pow((R * R * K * K * (1 - K) * (1 - K)) / (H0 * Rpr), 0.333); PointPairList line = new PointPairList(); line.Add(interval.profile.points[0]); line.Add(new PointPair(closedBariers[closedBariers.Count - 1].points[1])); PointPairList points = getIntersections(line, closedBariers[0].points); double H = closedBariers[0].points[1].Y - points[0].Y; double h = H / H0; double Wp0 = 15.832 * Math.Pow(Mu, -0.853); Wp = Wp0 * (1 - h); A = closedBariers[closedBariers.Count-1].points[0]; B = closedBariers[closedBariers.Count-1].points[1]; C = closedBariers[closedBariers.Count-1].points[2]; Y = B.Y - (((A.Y - C.Y) * B.X + (A.X * C.Y - A.Y * C.X)) / (C.X - A.X));//высота У(см. формулу 15 в методичке Садомовского) r = C.X - A.X; //ширина препятствия Rpr = (r * r) / (8 * Y);//формула 15(Садомовский) K = B.X / R; H0 = ((PointPairList)interval.lineOfSight.Points).SplineInterpolateX(B.X, tension) - interval.H0.SplineInterpolateX(B.X, tension); Mu = Math.Pow((R * R * K * K * (1 - K) * (1 - K)) / (H0 * Rpr), 0.333); line = new PointPairList(); line.Add(interval.profile.points[interval.profile.points.Count-1]); line.Add(new PointPair(closedBariers[0].points[1])); points = getIntersections(line, closedBariers[closedBariers.Count - 1].points); H = closedBariers[closedBariers.Count - 1].points[1].Y - points[0].Y; h = H / H0; Wp0 = 15.832 * Math.Pow(Mu, -0.853); Wp += Wp0 * (1 - h); q = q0 + Wp; if (Wp < WpDop) return "Пригоден"; else return "Непригоден"; #endregion } } }