本文整理汇总了Python中Math.point_orientation方法的典型用法代码示例。如果您正苦于以下问题:Python Math.point_orientation方法的具体用法?Python Math.point_orientation怎么用?Python Math.point_orientation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Math
的用法示例。
在下文中一共展示了Math.point_orientation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_next_move_to
# 需要导入模块: import Math [as 别名]
# 或者: from Math import point_orientation [as 别名]
def get_next_move_to(self, position, final_target):
"""Get the next point an agent following this path should move to.
Reference: Simple Stupid Funnel Algorithm
http://digestingduck.blogspot.com/2010/03/simple-stupid-funnel-algorithm.html
@type position: Vector
@param position: The position of the agent following the path
"""
current_polys = []
for poly in self._polygons:
if poly.contains_point(position):
current_polys.append(poly)
i = max((self._polygons.index(p) for p in current_polys))
if i == len(self._polygons)-1: return final_target
edge = self._polygons[i].neighbors[self._polygons[i+1]][1]
left, right = (edge[0], edge[1]) if Math.point_orientation(position, edge[0], edge[1]) else (edge[1], edge[0])
for j in range(i+1, len(self._polygons)-1):
edge = self._polygons[j].neighbors[self._polygons[j+1]][1]
new_left, new_right = (edge[0], edge[1]) if Math.point_orientation(position, edge[0], edge[1]) else (edge[1], edge[0])
# make the funnel smaller
if Math.point_orientation(position, left, new_left): left = new_left
if not Math.point_orientation(position, left, right):
return right
if not Math.point_orientation(position, right, new_right): right = new_right
if not Math.point_orientation(position, left, right):
return left
if Math.point_orientation(position, left, final_target): left = final_target
if not Math.point_orientation(position, left, right):
return right
if not Math.point_orientation(position, right, final_target): right = final_target
if not Math.point_orientation(position, left, right):
return left
return final_target