本文整理汇总了Python中matplotlib.path.Path.intersects_bbox方法的典型用法代码示例。如果您正苦于以下问题:Python Path.intersects_bbox方法的具体用法?Python Path.intersects_bbox怎么用?Python Path.intersects_bbox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.path.Path
的用法示例。
在下文中一共展示了Path.intersects_bbox方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: evaluate
# 需要导入模块: from matplotlib.path import Path [as 别名]
# 或者: from matplotlib.path.Path import intersects_bbox [as 别名]
def evaluate(param, old):
#print waypoints[-1]
#if sqrt(pow(param[0] - old[0], 2) + pow(param[1] - old[1], 2)) > max_distance:
# return 900
verts = [(old[0], old[1]),
(param[0], param[1]),]
path = Path(verts, codes)
for obstacle in obstacles:
if sqrt(pow(param[0] - obstacle.get_xy()[0], 2) + pow(param[1] - obstacle.get_xy()[1], 2)) < 10:
if path.intersects_bbox(obstacle.get_bbox()):
return 900
return sqrt(pow(param[0] - 10, 2) + pow(param[1] - 10, 2))
示例2: Rectangle
# 需要导入模块: from matplotlib.path import Path [as 别名]
# 或者: from matplotlib.path.Path import intersects_bbox [as 别名]
from pylab import *
import numpy as np
from matplotlib.transforms import Bbox
from matplotlib.path import Path
from matplotlib.patches import Rectangle
rect = Rectangle((-1, -1), 2, 2, facecolor="#aaaaaa")
gca().add_patch(rect)
bbox = Bbox.from_bounds(-1, -1, 2, 2)
for i in range(12):
vertices = (np.random.random((4, 2)) - 0.5) * 6.0
vertices = np.ma.masked_array(vertices, [[False, False], [True, True], [False, False], [False, False]])
path = Path(vertices)
if path.intersects_bbox(bbox):
color = 'r'
else:
color = 'b'
plot(vertices[:,0], vertices[:,1], color=color)
show()
示例3: print
# 需要导入模块: from matplotlib.path import Path [as 别名]
# 或者: from matplotlib.path.Path import intersects_bbox [as 别名]
sb = points[0][0]
eb = points[1][1]
print (nb, wb, sb, eb)
#Size of the tasks, into how many rows and columns should the area be divided.
task_cols = 40
task_rows = 30
ns_step = (sb - nb) / task_cols
we_step = (eb - wb) / task_rows
task_counter = 0
for row in range(task_rows):
wbr = wb + row * we_step
ebr = wb + (row + 1) * we_step
for col in range(task_cols):
nbc = nb + col * ns_step
sbc = nb + (col + 1) * ns_step
if islandPolygon.intersects_bbox(Bbox([[nbc, wbr], [sbc, ebr]])):
boundary = 0.01
task_info = dict(question=app_config['question'], n_answers=int(args.number_answers),
westbound=wbr, eastbound=ebr, northbound=nbc, southbound=sbc,
westmapbound=wbr - boundary, eastmapbound=ebr + boundary,
northmapbound=nbc + boundary, southmapbound=sbc - boundary,
location=str(row) + "_" + str(col), batch=args.batch)
response = pbclient.create_task(app_id, task_info)
check_api_error(response)
task_counter += 1
print(task_counter)
if args.update_template:
print "Updating app template"
try:
response = pbclient.find_app(short_name=app_config['short_name'])