def shortest_path(mgrid, domain, targets, obstacles, buffer_radius):
"""Vector field guiding towards targets."""
obstacles_buffered = obstacles.buffer(buffer_radius).intersection(domain)
dmap_targets = distance_map(mgrid, targets, obstacles_buffered)
dir_map_targets = direction_map(dmap_targets)
# Fill values between buffered region and obstacles
mask = np.full(mgrid.shape, False, dtype=np.bool_)
draw_geom(obstacles, mask, mgrid.indicer, True)
fill_missing(np.logical_xor(mask, dir_map_targets[0].mask),
*mgrid.values, *dir_map_targets)
return dir_map_targets, dmap_targets
评论列表
文章目录