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


Python Circle.contains方法代码示例

本文整理汇总了Python中horizons.util.Circle.contains方法的典型用法代码示例。如果您正苦于以下问题:Python Circle.contains方法的具体用法?Python Circle.contains怎么用?Python Circle.contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在horizons.util.Circle的用法示例。


在下文中一共展示了Circle.contains方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_ground_units

# 需要导入模块: from horizons.util import Circle [as 别名]
# 或者: from horizons.util.Circle import contains [as 别名]
	def get_ground_units(self, position=None, radius=None):
		"""@see get_ships"""
		if position is not None and radius is not None:
			circle = Circle(position, radius)
			return [unit for unit in self.ground_units if circle.contains(unit.position)]
		else:
			return self.ground_units
开发者ID:aedificium,项目名称:aedificium,代码行数:9,代码来源:__init__.py

示例2: get_buildings

# 需要导入模块: from horizons.util import Circle [as 别名]
# 或者: from horizons.util.Circle import contains [as 别名]
	def get_buildings(self, position=None, radius=None):
		"""@see get_ships"""
		buildings = []
		if position is not None and radius is not None:
			circle = Circle(position, radius)
			for island in self.islands:
				for building in island.buildings:
					if circle.contains(building.position.center()):
						buildings.append(building)
			return buildings
		else:
			return [b for b in island.buildings for island in self.islands]
开发者ID:aedificium,项目名称:aedificium,代码行数:14,代码来源:__init__.py

示例3: get_ships

# 需要导入模块: from horizons.util import Circle [as 别名]
# 或者: from horizons.util.Circle import contains [as 别名]
	def get_ships(self, position=None, radius=None):
		"""Returns all ships on the map, optionally only those in range
		around the specified position.
		@param position: Point or Rect instance.
		@param radius: int radius to use.
		@return: List of ships.
		"""
		if position is not None and radius is not None:
			circle = Circle(position, radius)
			return [ship for ship in self.ships if circle.contains(ship.position)]
		else:
			return self.ships
开发者ID:aedificium,项目名称:aedificium,代码行数:14,代码来源:__init__.py


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