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


Python Math.point_orientation方法代码示例

本文整理汇总了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
开发者ID:tartley,项目名称:Py2D,代码行数:48,代码来源:Navigation.py


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