Function: cellsVsDistance()
cellsVsDistance(
player,byFoot,cell?):CellVsLeague[]
Defined in: packages/sdvplot/src/shots/distance.ts:178
Player cells against the league FG% at the cell centre's distance, floor(|centre| / 10) ft, falling back one
foot when that bin is empty (blazing-the-nets master src/components/Hexagon/index.js:44-49). cell is a
hexagon radius (default 10, master's) or any binner lattice, e.g. { shape: "square", side: 10 }. byFoot is
read as feet, so it must be 1-ft bins from 0 (fgPctByDistance(league)), else InputError.
The distance is Math.hypot(x, y), a deliberate divergence from master's Math.sqrt(x ** 2 + y ** 2)
(src/lib/distance.js:3-4). On a hexagon centre exactly a whole number of feet out, such as (15√3, 15) at 3 ft,
master's sqrt returns 29.999…96 and reads the foot below; hypot reads the true foot. On the real BKN fixture at
radius 10 that is 13 of 374 cells, among them the cells beside the rim (0.572 at 3 ft, where master reads 0.669
at 2 ft). Every other cell reads master's foot.
Parameters
player
readonly ShotRow[]
byFoot
readonly DistanceBin[]
cell?
number | BinnerOptions
Returns
Example
import { cellsVsDistance, fgPctByDistance } from "@sportsdataverse/sdvplot/shots";
// Brooklyn shots from the sportsdataverse-data nba_stats_shots release, 2025-26
const made = { x_legacy: 0, y_legacy: 0, shot_distance: 0, shot_value: 2, shot_result: "Made" };
const missed = { ...made, shot_result: "Missed" };
cellsVsDistance([made], fgPctByDistance([made, missed]), { shape: "square", side: 10 });