本文整理汇总了Python中map.Map.get_north_at方法的典型用法代码示例。如果您正苦于以下问题:Python Map.get_north_at方法的具体用法?Python Map.get_north_at怎么用?Python Map.get_north_at使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类map.Map
的用法示例。
在下文中一共展示了Map.get_north_at方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_pos_by_dist_and_dir
# 需要导入模块: from map import Map [as 别名]
# 或者: from map.Map import get_north_at [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_location_details
# 需要导入模块: from map import Map [as 别名]
# 或者: from map.Map import get_north_at [as 别名]
def get_next_location_details(self, direction, x, y):
"""
params:
current user's direction (relative to north 0~360d), current x & y pos
return:
distance to next loc, direction to next loc (relative to user) & next loc's node
"""
nextLocNode = self.get_next_location(x, y)
if self.nextLoc and self.nextLoc['nodeName'] in self.reachedLoc:
self.prevLoc = self.nextLoc
self.nextLoc = nextLocNode
dist = Map.get_distance(nextLocNode["x"], x, nextLocNode["y"], y)
northAt = Map.get_north_at(self.building, self.level)
userDir = direction + northAt # relative to map
userDir = userDir % 360
movingDir = Map.get_direction(x, nextLocNode["x"],
y, nextLocNode["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
return relativeDir, dist, nextLocNode