public PointData(PointPos _AStartPoint, double _g, double _h, PointData _parent) { pointPos = _AStartPoint; g = _g; h = _h; parent = _parent; }
public PointInfo(int _x, int _y, PointEnum _pointType, GameObject _go) { pointPos = new PointPos(_x, _y); pointType = _pointType; go = _go; if (go != null) { renderer = go.GetComponent <MeshRenderer>(); } }
/// <summary> /// 计算G /// </summary> /// <param name="data">传入的点信息</param> /// <returns>G值的计算</returns> public static double CalG(PointData data, PointPos newPos, bool isStraightLine) { double result = data.g + (isStraightLine ? StraightLine : SlantLine); double temp = 0; var _type = MainMap[newPos.x, newPos.y].PointType; switch (_type) { case PointEnum.Normal: temp = 1; break; case PointEnum.Hard: temp = 10; break; } return(result + temp); }
/// <summary> /// 传入地图信息 /// </summary> /// <param name="s">起点</param> /// <param name="e">终点</param> /// <returns>能否进行寻路</returns> private static bool GenerateMap(PointPos s, PointPos e) { if (MainMap == null) { var main = MainGameManager.Instance; MainMap = main.MapArray; Max_PNT = new PointPos(main.Width, main.Height); } if (s.Equals(e)) { Debug.Log("起点和终点相同"); return(false); } Start_Pnt = s; End_Pnt = e; return(true); }
/// <summary> /// 计算并存储所有的点 /// </summary> public List<PointPos> ComputingAllPos() { posList = new List<PointPos>(); ComputingAHL(); float x,v, d,r, md,nd,re,k, w, w1, w2, w3, w4, jiao, a1, a2, a3, a4; w = 0; jiao = SwirlAngle * Mathf.PI / 180; v = Speed; d = PipeDiameter; k = GasWaterProp ; r = d / 2; md = 998.2f * k + (1 - k) * 0.6679f; nd = 0.001003f * k + (1 - k) * 1.1087f * Mathf.Pow(10,-5); re = md * v * d / nd; a1 = 3.8317f * r / 2 - 0.25f * Mathf.Pow((3.8317f * r / 2), 3) + Mathf.Pow((3.8317f * r / 2), 5) / 12 - Mathf.Pow((3.8317f * r / 2), 7) / 288; a2 = 7.0156f * r / 2 - 0.25f * Mathf.Pow((7.0156f * r / 2), 3) + Mathf.Pow((7.0156f * r / 2), 5) / 12 - Mathf.Pow((7.0156f * r / 2), 7) / 288; a3 = 10.1735f * r / 2 - 0.25f * Mathf.Pow((10.1735f * r / 2), 3) + Mathf.Pow((10.1735f * r / 2), 5) / 12 - Mathf.Pow((10.1735f * r / 2), 7) / 288; a4 = 13.3237f * r / 2 - 0.25f * Mathf.Pow((13.3237f * r / 2), 3) + Mathf.Pow((13.3237f * r / 2), 5) / 12 - Mathf.Pow((13.3237f * r / 2), 7) / 288; x = 0.0f; do { x += 0.1f; w1 = 7.78f * Mathf.Tan(jiao) / 2 / Mathf.PI * a1 *Mathf.Exp(-(16.675f) * (1 + (4.15f * Mathf.Pow(10 , (-3)) * Mathf.Pow(re , 0.86f))) / re * x); w2 = 5.26f * Mathf.Tan(jiao) / 2 / Mathf.PI * a2 * Mathf.Exp(-(55.714f) * (1 + (4.15f * Mathf.Pow(10, (-3)) * Mathf.Pow(re, 0.86f))) / re * x); w3 = 3.93f * Mathf.Tan(jiao) / 2 / Mathf.PI * a3 * Mathf.Exp(-(117.86f) * (1 + (4.15f * Mathf.Pow(10, (-3)) * Mathf.Pow(re, 0.86f))) / re * x); w4 = 3.16f * Mathf.Tan(jiao) / 2 / Mathf.PI * a4 * Mathf.Exp(-(203.73f) * (1 + (4.15f * Mathf.Pow(10, (-3)) * Mathf.Pow(re, 0.86f))) / re * x); //记录一个y方向最大值 if(w1 + w2 + w3 + w4 > w) { MaxYValue = w1 + w2 + w3 + w4; } w = w1 + w2 + w3 + w4; PointPos pos = new PointPos(x, w); posList.Add(pos); } while (w>0.0035); MaxXValue = x; return posList; }
/// <summary> /// 获取曼哈顿距离 /// </summary> /// <param name="pnt">传入的点信息</param> /// <returns>H值的曼哈顿距离</returns> private static double HManhattanDistance(PointPos pnt) { return(Math.Abs(pnt.x - End_Pnt.x) + Math.Abs(pnt.y - End_Pnt.y)); }
/// <summary> /// 计算H的抽象方法 /// 里面包含了权重的计算 /// </summary> /// <param name="pnt">传入的点信息</param> /// <returns>H值的计算的抽象方法</returns> public static double CalH(PointPos pnt) { return(HManhattanDistance(pnt)); }
public static bool FindPath(PointPos s, PointPos e, out List <PointData> pathList) { pathList = null; return(GenerateMap(s, e) && Search(out pathList)); }
private static bool Search(out List <PointData> pathList) { //是否走过 bool[,] goMap = new bool[Max_PNT.x, Max_PNT.y]; //起点数据 PointData startData = new PointData(Start_Pnt, 0, 0, null); //最后一个点的数据 用于反推 PointData endData = null; //用List集合做"开启列表" 来记录扩展的点 List <PointData> openList = new List <PointData>(); //把起点放入开启列表 openList.Add(startData); //是否完成 bool isFinish = false; while (!isFinish && openList.Count > 0) {//找到终点或者"开启列表"为空的时候退出循环 openList.Sort((x, y) => { return(x.F.CompareTo(y.F)); }); PointData data = openList[0]; openList.RemoveAt(0); PointPos point = data.pointPos; //将取出的点表示为已访问点 if (!goMap[point.x, point.y]) { goMap[point.x, point.y] = true; } else { continue; } int[,] nowDir = IsEight ? eightDirects : fourDirects; for (int i = 0; i < nowDir.GetLength(0); i++) { bool isStraight = IsEight ? Mathf.Abs(nowDir[i, 0]) != Mathf.Abs(nowDir[i, 1]) : true; PointPos newPoint = new PointPos(point.x + nowDir[i, 0], point.y + nowDir[i, 1]); if (newPoint.x >= 0 && newPoint.x < Max_PNT.x && newPoint.y >= 0 && newPoint.y < Max_PNT.y) { if (MainMap[newPoint.x, newPoint.y].PointType == PointEnum.Cannot) { continue; } //查找判断点是否在"开启列表"中 PointData tempData = openList.Find(x => x.pointPos.Equals(newPoint)); double tempG = CalG(data, newPoint, isStraight); if (tempData != null) { if (tempData.g > tempG) { tempData.g = tempG; tempData.parent = data; } } else { double h = CalH(newPoint); PointData newData = new PointData(newPoint, tempG, h, data); openList.Add(newData); if (MainMap[newPoint.x, newPoint.y].PointType == PointEnum.End) { endData = newData; isFinish = true; break; } } } } } //反向查找 找出路径 pathList = new List <PointData>(); pathList.Add(endData); PointData pointData = endData; while (pointData != null) { PointPos point = pointData.pointPos; if (goMap[point.x, point.y]) { goMap[point.x, point.y] = false; pathList.Add(pointData); } pointData = pointData.parent; } pathList.Add(startData); pathList.Reverse(); return(true); }
/// <summary> /// 获取欧几里得距离 /// </summary> /// <param name="pnt"></param> /// <returns>H值的Pow欧几里得离</returns> private static double HPowEuclidianDistance(PointPos pnt) { return(Math.Pow(pnt.x - End_Pnt.x, 2) + Math.Pow(pnt.y - End_Pnt.y, 2)); }
/// <summary> /// 获取欧几里得距离 /// </summary> /// <param name="pnt">传入的点信息</param> /// <returns>H值的欧几里得距离</returns> private static double HEuclidianDistance(PointPos pnt) { return(Math.Sqrt(HPowEuclidianDistance(pnt))); }
public bool Equals(PointPos obj) { return(x == obj.x && y == obj.y); }
public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = 41; if (Type != null) { hashCode = hashCode * 59 + Type.GetHashCode(); } if (Visible != null) { hashCode = hashCode * 59 + Visible.GetHashCode(); } if (ShowLegend != null) { hashCode = hashCode * 59 + ShowLegend.GetHashCode(); } if (LegendGroup != null) { hashCode = hashCode * 59 + LegendGroup.GetHashCode(); } if (Opacity != null) { hashCode = hashCode * 59 + Opacity.GetHashCode(); } if (UId != null) { hashCode = hashCode * 59 + UId.GetHashCode(); } if (Ids != null) { hashCode = hashCode * 59 + Ids.GetHashCode(); } if (CustomData != null) { hashCode = hashCode * 59 + CustomData.GetHashCode(); } if (Meta != null) { hashCode = hashCode * 59 + Meta.GetHashCode(); } if (MetaArray != null) { hashCode = hashCode * 59 + MetaArray.GetHashCode(); } if (SelectedPoints != null) { hashCode = hashCode * 59 + SelectedPoints.GetHashCode(); } if (HoverInfo != null) { hashCode = hashCode * 59 + HoverInfo.GetHashCode(); } if (HoverInfoArray != null) { hashCode = hashCode * 59 + HoverInfoArray.GetHashCode(); } if (HoverLabel != null) { hashCode = hashCode * 59 + HoverLabel.GetHashCode(); } if (Stream != null) { hashCode = hashCode * 59 + Stream.GetHashCode(); } if (Transforms != null) { hashCode = hashCode * 59 + Transforms.GetHashCode(); } if (UiRevision != null) { hashCode = hashCode * 59 + UiRevision.GetHashCode(); } if (Y != null) { hashCode = hashCode * 59 + Y.GetHashCode(); } if (X != null) { hashCode = hashCode * 59 + X.GetHashCode(); } if (X0 != null) { hashCode = hashCode * 59 + X0.GetHashCode(); } if (Y0 != null) { hashCode = hashCode * 59 + Y0.GetHashCode(); } if (Name != null) { hashCode = hashCode * 59 + Name.GetHashCode(); } if (Orientation != null) { hashCode = hashCode * 59 + Orientation.GetHashCode(); } if (Bandwidth != null) { hashCode = hashCode * 59 + Bandwidth.GetHashCode(); } if (ScaleGroup != null) { hashCode = hashCode * 59 + ScaleGroup.GetHashCode(); } if (ScaleMode != null) { hashCode = hashCode * 59 + ScaleMode.GetHashCode(); } if (SpanMode != null) { hashCode = hashCode * 59 + SpanMode.GetHashCode(); } if (Span != null) { hashCode = hashCode * 59 + Span.GetHashCode(); } if (Line != null) { hashCode = hashCode * 59 + Line.GetHashCode(); } if (FillColor != null) { hashCode = hashCode * 59 + FillColor.GetHashCode(); } if (Points != null) { hashCode = hashCode * 59 + Points.GetHashCode(); } if (Jitter != null) { hashCode = hashCode * 59 + Jitter.GetHashCode(); } if (PointPos != null) { hashCode = hashCode * 59 + PointPos.GetHashCode(); } if (Width != null) { hashCode = hashCode * 59 + Width.GetHashCode(); } if (Marker != null) { hashCode = hashCode * 59 + Marker.GetHashCode(); } if (Text != null) { hashCode = hashCode * 59 + Text.GetHashCode(); } if (TextArray != null) { hashCode = hashCode * 59 + TextArray.GetHashCode(); } if (HoverText != null) { hashCode = hashCode * 59 + HoverText.GetHashCode(); } if (HoverTextArray != null) { hashCode = hashCode * 59 + HoverTextArray.GetHashCode(); } if (HoverTemplate != null) { hashCode = hashCode * 59 + HoverTemplate.GetHashCode(); } if (HoverTemplateArray != null) { hashCode = hashCode * 59 + HoverTemplateArray.GetHashCode(); } if (Box != null) { hashCode = hashCode * 59 + Box.GetHashCode(); } if (MeanLine != null) { hashCode = hashCode * 59 + MeanLine.GetHashCode(); } if (Side != null) { hashCode = hashCode * 59 + Side.GetHashCode(); } if (OffsetGroup != null) { hashCode = hashCode * 59 + OffsetGroup.GetHashCode(); } if (AlignmentGroup != null) { hashCode = hashCode * 59 + AlignmentGroup.GetHashCode(); } if (Selected != null) { hashCode = hashCode * 59 + Selected.GetHashCode(); } if (Unselected != null) { hashCode = hashCode * 59 + Unselected.GetHashCode(); } if (HoverOn != null) { hashCode = hashCode * 59 + HoverOn.GetHashCode(); } if (XAxis != null) { hashCode = hashCode * 59 + XAxis.GetHashCode(); } if (YAxis != null) { hashCode = hashCode * 59 + YAxis.GetHashCode(); } if (IdsSrc != null) { hashCode = hashCode * 59 + IdsSrc.GetHashCode(); } if (CustomDataSrc != null) { hashCode = hashCode * 59 + CustomDataSrc.GetHashCode(); } if (MetaSrc != null) { hashCode = hashCode * 59 + MetaSrc.GetHashCode(); } if (HoverInfoSrc != null) { hashCode = hashCode * 59 + HoverInfoSrc.GetHashCode(); } if (YSrc != null) { hashCode = hashCode * 59 + YSrc.GetHashCode(); } if (XSrc != null) { hashCode = hashCode * 59 + XSrc.GetHashCode(); } if (TextSrc != null) { hashCode = hashCode * 59 + TextSrc.GetHashCode(); } if (HoverTextSrc != null) { hashCode = hashCode * 59 + HoverTextSrc.GetHashCode(); } if (HoverTemplateSrc != null) { hashCode = hashCode * 59 + HoverTemplateSrc.GetHashCode(); } return(hashCode); } }
public bool Equals([AllowNull] Violin other) { if (other == null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return((Type == other.Type && Type != null && other.Type != null && Type.Equals(other.Type)) && (Visible == other.Visible && Visible != null && other.Visible != null && Visible.Equals(other.Visible)) && (ShowLegend == other.ShowLegend && ShowLegend != null && other.ShowLegend != null && ShowLegend.Equals(other.ShowLegend)) && (LegendGroup == other.LegendGroup && LegendGroup != null && other.LegendGroup != null && LegendGroup.Equals(other.LegendGroup)) && (Opacity == other.Opacity && Opacity != null && other.Opacity != null && Opacity.Equals(other.Opacity)) && (UId == other.UId && UId != null && other.UId != null && UId.Equals(other.UId)) && (Equals(Ids, other.Ids) || Ids != null && other.Ids != null && Ids.SequenceEqual(other.Ids)) && (Equals(CustomData, other.CustomData) || CustomData != null && other.CustomData != null && CustomData.SequenceEqual(other.CustomData)) && (Meta == other.Meta && Meta != null && other.Meta != null && Meta.Equals(other.Meta)) && (Equals(MetaArray, other.MetaArray) || MetaArray != null && other.MetaArray != null && MetaArray.SequenceEqual(other.MetaArray)) && (SelectedPoints == other.SelectedPoints && SelectedPoints != null && other.SelectedPoints != null && SelectedPoints.Equals(other.SelectedPoints)) && (HoverInfo == other.HoverInfo && HoverInfo != null && other.HoverInfo != null && HoverInfo.Equals(other.HoverInfo)) && (Equals(HoverInfoArray, other.HoverInfoArray) || HoverInfoArray != null && other.HoverInfoArray != null && HoverInfoArray.SequenceEqual(other.HoverInfoArray)) && (HoverLabel == other.HoverLabel && HoverLabel != null && other.HoverLabel != null && HoverLabel.Equals(other.HoverLabel)) && (Stream == other.Stream && Stream != null && other.Stream != null && Stream.Equals(other.Stream)) && (Equals(Transforms, other.Transforms) || Transforms != null && other.Transforms != null && Transforms.SequenceEqual(other.Transforms)) && (UiRevision == other.UiRevision && UiRevision != null && other.UiRevision != null && UiRevision.Equals(other.UiRevision)) && (Equals(Y, other.Y) || Y != null && other.Y != null && Y.SequenceEqual(other.Y)) && (Equals(X, other.X) || X != null && other.X != null && X.SequenceEqual(other.X)) && (X0 == other.X0 && X0 != null && other.X0 != null && X0.Equals(other.X0)) && (Y0 == other.Y0 && Y0 != null && other.Y0 != null && Y0.Equals(other.Y0)) && (Name == other.Name && Name != null && other.Name != null && Name.Equals(other.Name)) && (Orientation == other.Orientation && Orientation != null && other.Orientation != null && Orientation.Equals(other.Orientation)) && (Bandwidth == other.Bandwidth && Bandwidth != null && other.Bandwidth != null && Bandwidth.Equals(other.Bandwidth)) && (ScaleGroup == other.ScaleGroup && ScaleGroup != null && other.ScaleGroup != null && ScaleGroup.Equals(other.ScaleGroup)) && (ScaleMode == other.ScaleMode && ScaleMode != null && other.ScaleMode != null && ScaleMode.Equals(other.ScaleMode)) && (SpanMode == other.SpanMode && SpanMode != null && other.SpanMode != null && SpanMode.Equals(other.SpanMode)) && (Equals(Span, other.Span) || Span != null && other.Span != null && Span.SequenceEqual(other.Span)) && (Line == other.Line && Line != null && other.Line != null && Line.Equals(other.Line)) && (FillColor == other.FillColor && FillColor != null && other.FillColor != null && FillColor.Equals(other.FillColor)) && (Points == other.Points && Points != null && other.Points != null && Points.Equals(other.Points)) && (Jitter == other.Jitter && Jitter != null && other.Jitter != null && Jitter.Equals(other.Jitter)) && (PointPos == other.PointPos && PointPos != null && other.PointPos != null && PointPos.Equals(other.PointPos)) && (Width == other.Width && Width != null && other.Width != null && Width.Equals(other.Width)) && (Marker == other.Marker && Marker != null && other.Marker != null && Marker.Equals(other.Marker)) && (Text == other.Text && Text != null && other.Text != null && Text.Equals(other.Text)) && (Equals(TextArray, other.TextArray) || TextArray != null && other.TextArray != null && TextArray.SequenceEqual(other.TextArray)) && (HoverText == other.HoverText && HoverText != null && other.HoverText != null && HoverText.Equals(other.HoverText)) && (Equals(HoverTextArray, other.HoverTextArray) || HoverTextArray != null && other.HoverTextArray != null && HoverTextArray.SequenceEqual(other.HoverTextArray)) && (HoverTemplate == other.HoverTemplate && HoverTemplate != null && other.HoverTemplate != null && HoverTemplate.Equals(other.HoverTemplate)) && (Equals(HoverTemplateArray, other.HoverTemplateArray) || HoverTemplateArray != null && other.HoverTemplateArray != null && HoverTemplateArray.SequenceEqual(other.HoverTemplateArray)) && (Box == other.Box && Box != null && other.Box != null && Box.Equals(other.Box)) && (MeanLine == other.MeanLine && MeanLine != null && other.MeanLine != null && MeanLine.Equals(other.MeanLine)) && (Side == other.Side && Side != null && other.Side != null && Side.Equals(other.Side)) && (OffsetGroup == other.OffsetGroup && OffsetGroup != null && other.OffsetGroup != null && OffsetGroup.Equals(other.OffsetGroup)) && (AlignmentGroup == other.AlignmentGroup && AlignmentGroup != null && other.AlignmentGroup != null && AlignmentGroup.Equals(other.AlignmentGroup)) && (Selected == other.Selected && Selected != null && other.Selected != null && Selected.Equals(other.Selected)) && (Unselected == other.Unselected && Unselected != null && other.Unselected != null && Unselected.Equals(other.Unselected)) && (HoverOn == other.HoverOn && HoverOn != null && other.HoverOn != null && HoverOn.Equals(other.HoverOn)) && (XAxis == other.XAxis && XAxis != null && other.XAxis != null && XAxis.Equals(other.XAxis)) && (YAxis == other.YAxis && YAxis != null && other.YAxis != null && YAxis.Equals(other.YAxis)) && (IdsSrc == other.IdsSrc && IdsSrc != null && other.IdsSrc != null && IdsSrc.Equals(other.IdsSrc)) && (CustomDataSrc == other.CustomDataSrc && CustomDataSrc != null && other.CustomDataSrc != null && CustomDataSrc.Equals(other.CustomDataSrc)) && (MetaSrc == other.MetaSrc && MetaSrc != null && other.MetaSrc != null && MetaSrc.Equals(other.MetaSrc)) && (HoverInfoSrc == other.HoverInfoSrc && HoverInfoSrc != null && other.HoverInfoSrc != null && HoverInfoSrc.Equals(other.HoverInfoSrc)) && (YSrc == other.YSrc && YSrc != null && other.YSrc != null && YSrc.Equals(other.YSrc)) && (XSrc == other.XSrc && XSrc != null && other.XSrc != null && XSrc.Equals(other.XSrc)) && (TextSrc == other.TextSrc && TextSrc != null && other.TextSrc != null && TextSrc.Equals(other.TextSrc)) && (HoverTextSrc == other.HoverTextSrc && HoverTextSrc != null && other.HoverTextSrc != null && HoverTextSrc.Equals(other.HoverTextSrc)) && (HoverTemplateSrc == other.HoverTemplateSrc && HoverTemplateSrc != null && other.HoverTemplateSrc != null && HoverTemplateSrc.Equals(other.HoverTemplateSrc))); }