voronoi
Builtin index · Statistics & ML
result = voronoi(points)
Input: points · Output: result
What it is
Computes the Voronoi diagram of an (N, 2) point matrix points, built on a real Delaunay triangulation.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = voronoi(points) | points matrixnot documented yet | points matrixthe input (N, 2) matrix, unchangedcells —a length-N list, one entry per input point, each a list of (x, y) vertex coordinates outlining that point's Voronoi cellbounded vectora length-N vector of 0/1 flags, one per point | Returns a Record with fields points (the input (N, 2) matrix, unchanged), cells (a length-N list, one entry per input point, each a list of (x, y) vertex coordinates outlining that point's Voronoi cell), and bounded (a length-N vector of 0/1 flags, one per point). |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
pts = [0, 2, 0, 2, 0, 0, 2, 2] as matrix(4, 2) # the corners of a square
v = voronoi(pts)
print("bounded: {v.bounded}") # every corner cell is unbounded
print("cell 0: {v.cells[0]}") # the one finite vertex: the centre
bounded: [0, 0, 0, 0] cell 0: [1, 1]
from statistics-ml
How it works
voronoi(points) — the Voronoi diagram of an (n,2) point set, built on spade's Delaunay triangulation (see this crate's Cargo.toml for why spade, not a hand-rolled Fortune's sweep). See voronoi_diagram's own doc comment for the exact return shape and how unbounded cells are handled.
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.