(placed: PlacedPoint[])
| 11 | } |
| 12 | |
| 13 | export function buildGrid(placed: PlacedPoint[]): Map<string, number[]> { |
| 14 | const grid = new Map<string, number[]>(); |
| 15 | placed.forEach((p, i) => { |
| 16 | const key = `${Math.floor(p.x / GRID_CELL)},${Math.floor(p.y / GRID_CELL)}`; |
| 17 | const cell = grid.get(key); |
| 18 | if (cell) cell.push(i); |
| 19 | else grid.set(key, [i]); |
| 20 | }); |
| 21 | return grid; |
| 22 | } |
| 23 | |
| 24 | export function findNearest( |
| 25 | placed: PlacedPoint[], |
no test coverage detected