PitchKit
API Reference@pitchkit/coreFunctions

computeConvexHull()

function computeConvexHull(points): Point[];

Defined in: packages/core/src/geometry/convex-hull.ts:18

Convex hull via the monotone chain (Andrew's) algorithm: sort points lexicographically, then build the lower and upper hull chains in one pass each, popping any point that would make a clockwise (non-left) turn. O(n log n), no dependency — the same "hand-rolled over a library" choice as heatmap/colormap.ts's createColorScale.

Fewer than 3 distinct points have no well-defined hull interior; returns the deduplicated points as-is (a point or a segment) rather than throwing, so a caller can still render something for a sparse dataset.

Parameters

ParameterType
pointsreadonly Point[]

Returns

Point[]

On this page