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