Skip to content

spatial-monorepo


spatial-monorepo / wayfinding/src / walkSupercoverLine

Function: walkSupercoverLine()

walkSupercoverLine(x0, y0, x1, y1): GridCell[]

Defined in: packages/wayfinding/src/raster.ts:21

Walks every grid cell a line segment passes through, in cell-index space.

This is a "supercover" line traversal (as opposed to plain Bresenham): when the segment crosses a lattice corner exactly, both of the corner-adjacent cells are visited on the way through rather than jumping straight to the diagonal cell. The result is always 4-connected — consecutive cells in the returned array are exactly one orthogonal step apart, so there is never a "diagonal gap" a search or a line-of-sight check could slip through undetected.

Coordinates are continuous (not required to be integers); the starting and ending cell are Math.floor'd. Used both to stroke wall boundaries (thickened) and, unthickened, as the raster hit-check behind hasLineOfSight.

Parameters

x0

number

y0

number

x1

number

y1

number

Returns

GridCell[]

Released under commercial licensing.