A *寻找最短路径,避免线路的障碍 [英] A* for finding shortest path and avoiding lines as obstacles

查看:213
本文介绍了A *寻找最短路径,避免线路的障碍的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得在二维的(最短)/(最佳)两点之间的距离。我必须避免形状是线,也可以连接在一起。如何重新present我可以游上的节点任何建议?我曾经想过做一个网格,但这听起来并不很准确或优雅。我认为一个节点作为不可行走如果任何点的线段的是一个正方形内侧(与该节点的正方形的中心)。

I have to get the (shortest)/(an optimal) distance between two points in 2D. I have to avoid shapes that are lines, that may be connected together. Any suggestion on how to represent the nodes I can travel on? I have thought of making a grid, but this doesn't sound very accurate or elegant. I would consider a node as unwalkable if any point of a line is inside a square (with the node being the center of the square).

一个例子是从点A到B点。

An example would be going from point A to B.

时的电网来解决这个推荐的方法是什么?感谢很多提前!

Is the grid the recommended way to solve this? Thanks A LOT in advance!

推荐答案

我认为这基本上是Larsmans的回答让多一点的算法:

I think this is essentially Larsmans' answer made a bit more algorithmic:

节点是障碍物顶点。每个内部顶点实际重新presents两个节点:所述凹和凸侧

Nodes of the graph are the obstacle vertices. Each internal vertex actually represents two nodes: the concave and the convex side.

  1. 推起始节点到优先级队列用欧几里德启发式的距离。
  2. 弹出从优先级队列的顶部节点。
  3. 请从节点到球门线相交测试(可能使用光线跟踪数据结构技术加速)。如果失败,
  4. 考虑从当前节点的光线以每隔一个顶点。如果有当前节点之间没有交叉点所考虑的顶点,而顶点是从当前节点的角度凸,顶点添加到优先级队列,排序使用在当前节点的累积距离加上从当前的距离节点到顶点加启发式距离。
  5. 返回2。

您必须做额外的pre处理的工作,如果有像'T'路口的障碍,我也不会感到惊讶地发现,它打破在许多情况下。你也许可以使事情更快地只考虑连接组件,当前节点和目标之间的谎言的顶点。

You have to do extra pre-processing work if there are things like 'T' junctions in the obstacles and I wouldn't be surprised to discover that it breaks in a number of cases. You might be able to make things faster by only considering the vertices of the connected component that lies between the current node and the goal.

因此​​,在你的榜样,在首先尝试的 A,B ,你推的 A,8 A,5 A,1 A,11 A,2 。考虑的第一个节点是 A,8 A,1 A,5 ,但他们不能出去和节点便可以将已经被推上了队列较短的累积距离。 A,2 A,11 将被视为与东西会从那里。

So in your example, after first attempting A,B, you'd push A,8, A,5, A,1, A,11, and A,2. The first nodes of consideration would be A,8, A,1, and A,5, but they can't get out and the nodes they can reach are already pushed on the queue with shorter accumulated distance. A,2 and A,11 will be considered and things will go from there.

这篇关于A *寻找最短路径,避免线路的障碍的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆