當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。