From 38e6e2b3d950cc6e922e234d4f1f0143ea06723e Mon Sep 17 00:00:00 2001 From: GoteGuru Date: Sat, 9 Apr 2022 13:50:00 +0000 Subject: [PATCH] findcell by coordinates --- modules/submap.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/submap.js b/modules/submap.js index 6b67ee79..f9b70bff 100644 --- a/modules/submap.js +++ b/modules/submap.js @@ -317,18 +317,18 @@ window.Submap = (function () { /* find the nearest cell accepted by filter f *and* having at * least one *neighbor* fulfilling filter g, up to cell-distance `max` * returns [cellid, neighbor] tuple or undefined if no such cell. - * accepts pointLike (object having .x and .y) + * accepts coordinates (x, y) */ - const findNearest = (f, g, max=3) => pointLike => { - const d2 = c => (pointLike.x-pack.cells.p[c][0])**2 + (pointLike.y-pack.cells.p[c][0])**2 - const startCell = findCell(pointLike.x, pointLike.y); + const findNearest = (f, g, max=3) => (px,py) => { + const d2 = c => (px-pack.cells.p[c][0])**2 + (py-pack.cells.p[c][0])**2 + const startCell = findCell(px, py); const tested = new Set([startCell]); // ignore analyzed cells const kernel = (cs, level) => { const [bestf, bestg] = cs.filter(f).reduce(([cf, cg], c) => { const neighbors = pack.cells.c[c]; - const bestg = neighbors.filter(g).reduce((u, x) => d2(c) d2(x)