wallRepulsion

fun <A : AgentLike> wallRepulsion(graph: GridGraph, cellSize: Double, origin: Point2D, scanRadius: Double, minDistance: Double = 0.0, falloff: (distance: Double) -> Double): Force<A>(source)

Exponential repulsion from blocked cells (walls) in a GridGraph. Walls are treated as solid cell-sized bounding boxes: the force per cell uses the closest point on that cell's box to the agent's position. Scans a square of cells of radius ceil(scanRadius/cellSize) around the agent's current cell; cells outside that scan don't contribute.

Parameters

graph

the lattice whose blocked cells produce force

cellSize

side length of each cell in continuous space

origin

continuous-space anchor of cell (0, 0)

scanRadius

distance beyond which cells stop contributing

minDistance

lower clamp on d to keep falloff finite at contact

falloff

a function returning force magnitude given clamped distance