clean up magic numbers, enable arbitrary gridding, add cache invalidatino
This commit is contained in:
parent
a77ae781a7
commit
519dd48131
1 changed files with 574 additions and 358 deletions
|
|
@ -119,9 +119,16 @@ class DangerMap:
|
|||
Returns:
|
||||
Pre-computed cost, or 1e15 if out of bounds.
|
||||
"""
|
||||
# Clamp to grid range to handle upper boundary exactly
|
||||
ix = int((x - self.minx) / self.resolution)
|
||||
iy = int((y - self.miny) / self.resolution)
|
||||
|
||||
# Handle exact upper boundary
|
||||
if ix == self.width_cells and abs(x - self.maxx) < 1e-9:
|
||||
ix = self.width_cells - 1
|
||||
if iy == self.height_cells and abs(y - self.maxy) < 1e-9:
|
||||
iy = self.height_cells - 1
|
||||
|
||||
if 0 <= ix < self.width_cells and 0 <= iy < self.height_cells:
|
||||
return float(self.grid[ix, iy])
|
||||
return 1e15 # Outside bounds is impossible
|
||||
return 1e15 # Outside bounds
|
||||
|
|
|
|||
Loading…
Reference in a new issue