Builtin Library
README.md
core.spatial (procNode)
A spatial index over a set of points: the bucket order and spans every neighbour query reads.
Built from the hash kernel (the bucket of each point's cell), sort of those buckets and the hash_starts kernel (where each bucket's points lie in the sorted order). The point count is read back once; the bucket count is the least power of two at least the count and at least 16, worked out with math.log and math.ceil. Outputs order, range, buckets and invCell, which hash_count, hash_gather, hash_nearest and hash_hook read.
Inputs
points(Geometry). The points indexed, by theirP.cell(Number). Default1.0. Above 0. The side of a grid cell: queries reach about this far in one step, so a radius near it answers fastest.
Outputs
order: the points ordered by bucket.range: each bucket's span inorder.buckets: the bucket count.invCell: one over the cell side.
Example
local points = g.points.grid({ countX = 4, countZ = 1, spacing = 1 })
local index = g.core.spatial({ points = points, cell = 1.0 })
Four points indexed into 16 buckets.