PitchKit
API Reference@pitchkit/coreFunctions

computeVoronoiCells()

function computeVoronoiCells(sites, bounds): Point[][];

Defined in: packages/core/src/geometry/voronoi.ts:76

Bounded Voronoi tessellation via half-plane intersection: each site's cell starts as the full bounds rectangle and gets clipped by the perpendicular-bisector half-plane against every other site (keeping the side closer to this site). O(n²) clips total — core has no runtime dependencies (heatmap/colormap.ts), so this stands in for a Delaunay-based library (e.g. d3-delaunay) at the point counts a pitch plot needs (tens of players, not thousands).

Coincident sites produce a zero-magnitude bisector normal and are simply skipped for that pair (clipping against a degenerate half-plane would otherwise collapse the cell to nothing for both sites).

Parameters

ParameterType
sitesreadonly Point[]
boundsRect

Returns

Point[][]

On this page