本文整理汇总了Python中map.Map.get_direction_relative_north方法的典型用法代码示例。如果您正苦于以下问题:Python Map.get_direction_relative_north方法的具体用法?Python Map.get_direction_relative_north怎么用?Python Map.get_direction_relative_north使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类map.Map
的用法示例。
在下文中一共展示了Map.get_direction_relative_north方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_pos_by_dist_and_dir
# 需要导入模块: from map import Map [as 别名]
# 或者: from map.Map import get_direction_relative_north [as 别名]
def update_pos_by_dist_and_dir(self, distance, direction):
"""
params:
distance - distance went through
direction - angles relative to the west (clockwise)
"""
dirRelativeNorth = Map.get_direction_relative_north(self.building, self.level, direction)
northAt = Map.get_north_at(self.building, self.level)
userDir = dirRelativeNorth + northAt # relative to map
userDir = userDir % 360
if not self.nextLoc:
self.nextLoc = self.get_next_location(self.pos[0], self.pos[1])
movingDir = Map.get_direction(self.pos[0], self.nextLoc["x"],
self.pos[1], self.nextLoc["y"]) # relative to map
relativeDir = movingDir - userDir
# if relativeDir > 0, it's at user's rhs, else lhs
if relativeDir > 180:
relativeDir -= 360
if relativeDir < -180:
relativeDir += 360
(x, y, newDir) = Map.get_direction_details(self.building, self.level, distance, direction + relativeDir)
vec1X = self.pos[0] - float(self.nextLoc["x"])
vec1Y = self.pos[1] - float(self.nextLoc["y"])
vec2X = self.pos[0] + x - float(self.nextLoc["x"])
vec2Y = self.pos[1] + y - float(self.nextLoc["y"])
isSameDirection = (vec1X * vec2X + vec1Y * vec2Y > 0)
isReachNextLoc = self.is_reach_node(self.nextLoc, self.pos[0] + x, self.pos[1] + y)
isWentPass = not isSameDirection and not isReachNextLoc
if isWentPass:
self.reachedLoc.append(self.nextLoc["nodeName"])
self.update_pos(x, y)
示例2: get_next_instruction
# 需要导入模块: from map import Map [as 别名]
# 或者: from map.Map import get_direction_relative_north [as 别名]
def get_next_instruction(self, direction):
"""
param: direction relative to the west
"""
dirRelativeNorth = Map.get_direction_relative_north(self.building, self.level, direction)
relativeDir, dist, nextLocNode = self.get_next_location_by_direction(dirRelativeNorth)
side = "right hand side" if relativeDir >= 0 else "left hand side"
if self.isGivingIdInstruction:
self.isGivingIdInstruction = False
nextNode = nextLocNode['nodeId']
uselessNodeNamePattern = re.compile("^P\d+$")
if nextLocNode['nodeName'] not in self.spokenList and not uselessNodeNamePattern.match(nextLocNode['nodeName']):
nextNode += " " + nextLocNode['nodeName']
self.spokenList.append(nextLocNode['nodeName'])
return Navigation.INSTRUCTION.format(nextNode)
else:
self.isGivingIdInstruction = True
return Navigation.INSTRUCTION_ANGLE.format(side, abs(relativeDir))