当前位置: 首页>>代码示例>>C#>>正文


C# Path.Reverse方法代码示例

本文整理汇总了C#中Path.Reverse方法的典型用法代码示例。如果您正苦于以下问题:C# Path.Reverse方法的具体用法?C# Path.Reverse怎么用?C# Path.Reverse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Path的用法示例。


在下文中一共展示了Path.Reverse方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: getPath

        private static Path getPath(Dictionary<Node, Node> moves, Node end)
        {
            Path path = new Path();

            path.AddNode(end);
            while (moves.ContainsKey(end))
            {
                end = moves[end];
                path.AddNode(end);
            }

            path.Reverse();

            return path;
        }
开发者ID:cedwards145,项目名称:ld33,代码行数:15,代码来源:AStarPathfinder.cs

示例2: Minkowki

      //------------------------------------------------------------------------------

      internal static Paths Minkowki(Path poly, Path path, bool IsSum, bool IsClosed)
      {
        int delta = (IsClosed ? 1 : 0);
        int polyCnt = poly.Count;
        int pathCnt = path.Count;
        Paths result = new Paths(pathCnt);
        if (IsSum)
          for (int i = 0; i < pathCnt; i++)
          {
            Path p = new Path(polyCnt);
            foreach (IntPoint ip in poly)
              p.Add(new IntPoint(path[i].X + ip.X, path[i].Y + ip.Y));
            result.Add(p);
          }
        else
          for (int i = 0; i < pathCnt; i++)
          {
            Path p = new Path(polyCnt);
            foreach (IntPoint ip in poly)
              p.Add(new IntPoint(path[i].X - ip.X, path[i].Y - ip.Y));
            result.Add(p);
          }

        Paths quads = new Paths((pathCnt + delta) * (polyCnt + 1));
        for (int i = 0; i <= pathCnt - 2 + delta; i++)
          for (int j = 0; j <= polyCnt - 1; j++)
          {
            Path quad = new Path(4);
            quad.Add(result[i % pathCnt][j % polyCnt]);
            quad.Add(result[(i + 1) % pathCnt][j % polyCnt]);
            quad.Add(result[(i + 1) % pathCnt][(j + 1) % polyCnt]);
            quad.Add(result[i % pathCnt][(j + 1) % polyCnt]);
            if (!Orientation(quad)) quad.Reverse();
            quads.Add(quad);
          }

        Clipper c = new Clipper();
        c.AddPaths(quads, PolyType.ptSubject, true);
        c.Execute(ClipType.ctUnion, result, PolyFillType.pftNonZero, PolyFillType.pftNonZero);
        return result;
      }
开发者ID:CharlesTaylor95,项目名称:clipper,代码行数:43,代码来源:clipper.cs

示例3: AStar

        public void AStar(Vector3 start, Vector3 end, OnPathComputed callback)
        {
            // Reset all scores and sets membership
            Reset();

            Node startNode = getClosestNode(start);
            Node endNode = getClosestNode(end);

            if (startNode == null || endNode == null) {
                callback(new Path());
                return;
            }

            PriorityQueue<Node> openSet = new PriorityQueue<Node>();

            openSet.Push(startNode); startNode.InOpenSet = true;

            Dictionary<Node, Node> parentPath = new Dictionary<Node, Node>();

            startNode.GScore = 0;
            startNode.FScore = startNode.GScore + heuristic(startNode, endNode);

            Path path = new Path();
            Node current = startNode;

            while (openSet.Count() > 0) {
                current = openSet.Pop(); // automatically do the remove part
                current.InOpenSet = false;

                if (current.Id == endNode.Id) {
                    path.Add(current.Position);
                    while (parentPath.ContainsKey(current)) {
                        current = parentPath[current];
                        path.Add(current.Position);
                    }

                    path.Reverse();
                    callback(path);
                    return;
                }

                current.InClosedSet = true;

                List<Node> neighbors = getNeighbors(current);

                for (int i = 0; i < neighbors.Count; ++i) {
                    Node neighbor = neighbors[i];
                    if (neighbor.InClosedSet) continue;

                    float gAttempt = current.GScore + euclidian(current, neighbor);

                    if (!neighbor.InOpenSet || gAttempt <= neighbor.GScore) {
                        parentPath[neighbor] = current;
                        neighbor.GScore = gAttempt;
                        neighbor.FScore = neighbor.GScore + heuristic(neighbor, endNode);
                        if (!neighbor.InOpenSet) {
                            openSet.Push(neighbor);
                            neighbor.InOpenSet = true;
                        }
                    }

                } // end loop neighbors

            }
        }
开发者ID:evilcandybag,项目名称:DwarfSplat,代码行数:65,代码来源:Graph.cs

示例4: Reverse_ReversesSegmentsThirdSegment_ForPath

            public void Reverse_ReversesSegmentsThirdSegment_ForPath()
            {
                // Arrange
                var sut = new Path(m_StartArcSegment,
                                   m_Line,
                                   m_EndArcSegment);

                // Act
                IPath reversed = sut.Reverse();

                IPolylineSegment[] segments = reversed.Segments.ToArray();
                IPolylineSegment segment = segments [ 2 ];

                // Assert
                Assert.AreEqual(m_StartArcSegment.EndPoint,
                                segment.StartPoint);
                Assert.AreEqual(m_StartArcSegment.StartPoint,
                                segment.EndPoint);
            }
开发者ID:tschroedter,项目名称:Selkie.WPF,代码行数:19,代码来源:PathTests.cs

示例5: Reverse_DoesNothing_ForSinglePoint

            public void Reverse_DoesNothing_ForSinglePoint()
            {
                // Arrange
                var startPoint = new Point(-10.0,
                                           -10.0);

                // Act
                var sut = new Path(startPoint);

                IPath actual = sut.Reverse();

                // Assert
                Assert.AreEqual(startPoint,
                                actual.StartPoint,
                                "StartPoint");
                Assert.AreEqual(0,
                                actual.Segments.Count(),
                                "Count");
            }
开发者ID:tschroedter,项目名称:Selkie.WPF,代码行数:19,代码来源:PathTests.cs

示例6: Reverse_ReturnsInstance_ForPolylineWithNoSegments

            public void Reverse_ReturnsInstance_ForPolylineWithNoSegments()
            {
                // Arrange
                var startPoint = new Point(0.0,
                                           0.0);
                var sut = new Path(startPoint);

                // Act
                IPath actual = sut.Reverse();

                // Assert
                Assert.AreEqual(startPoint,
                                actual.StartPoint);
            }
开发者ID:tschroedter,项目名称:Selkie.WPF,代码行数:14,代码来源:PathTests.cs

示例7: Reverse_CallsReverseOnPolyline_ForPolyline

            public void Reverse_CallsReverseOnPolyline_ForPolyline()
            {
                // Arrange
                var polylineReverse = Substitute.For <IPolyline>();
                var polyline = Substitute.For <IPolyline>();
                polyline.Segments.Returns(new[]
                                          {
                                              Substitute.For <IPolylineSegment>()
                                          });
                polyline.Reverse().Returns(polylineReverse);

                var sut = new Path(polyline);

                // Act
                IPath actual = sut.Reverse();

                // Assert
                Assert.AreEqual(polylineReverse,
                                actual.Polyline);
            }
开发者ID:tschroedter,项目名称:Selkie.WPF,代码行数:20,代码来源:PathTests.cs


注:本文中的Path.Reverse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。