add various direction examples
This commit is contained in:
parent
556241bae3
commit
4cbd15bc0d
4 changed files with 63 additions and 1 deletions
|
|
@ -70,6 +70,10 @@ class DangerMap:
|
|||
safe_distances = np.maximum(distances, 0.1)
|
||||
self.grid = np.where(distances < self.safety_threshold, self.k / (safe_distances**2), 0.0).astype(np.float32)
|
||||
|
||||
def is_within_bounds(self, x: float, y: float) -> bool:
|
||||
"""Check if a coordinate is within the design bounds."""
|
||||
return self.minx <= x <= self.maxx and self.miny <= y <= self.maxy
|
||||
|
||||
def get_cost(self, x: float, y: float) -> float:
|
||||
"""Get the proximity cost at a specific coordinate."""
|
||||
ix = int((x - self.minx) / self.resolution)
|
||||
|
|
@ -77,4 +81,4 @@ class DangerMap:
|
|||
|
||||
if 0 <= ix < self.width_cells and 0 <= iy < self.height_cells:
|
||||
return float(self.grid[ix, iy])
|
||||
return 1e6 # Outside bounds is expensive
|
||||
return 1e15 # Outside bounds is impossible
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue