PitchKit
API Reference@pitchkit/coreFunctions

computeFlowBins()

function computeFlowBins(
   vectors, 
   binsX, 
   binsY, 
   dimensions
): FlowBin[];

Defined in: packages/core/src/geometry/flow.ts:39

Bins vectors by start location into a binsX x binsY grid over the pitch (same cell math as heatmap/bins.ts's computeHeatmapBins, kept independent rather than shared — that helper sums a scalar weight per bin, this one averages an end-point vector, which doesn't fit the same single-accumulator shape). Each occupied bin becomes one arrow: from the bin's center to the mean of every vector's end point that landed there. Empty bins are omitted rather than returned with count: 0, since there's no "zero-length arrow" to draw for a flow diagram the way a heatmap still colors an empty cell.

Binning happens in the extent frame (0..length, 0..width), so each start goes through toExtentFrame first and each bin centre comes back through fromExtentFrame (D5). Without that, a centre-origin pitch drops every vector starting at a negative x or y and draws the rest from the wrong place (#90). End points are averaged as given, in provider coordinates.

Parameters

ParameterType
vectorsreadonly FlowVector[]
binsXnumber
binsYnumber
dimensionsPitchDimensions

Returns

FlowBin[]

On this page