本文整理汇总了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;
}
示例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;
}
示例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
}
}
示例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);
}
示例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");
}
示例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);
}
示例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);
}