Builtin Library
README.md
points.relax (procNode)
Even out a point cloud's spacing by repulsion: each pass moves every point away from the points within radius of it. Only positions move; the count and every attribute stay. Use it after a random scatter to break up clumps without the cost of points.poisson.
Each pass asks core.neighbours (mode repel) for every point's push: the mean over the points within radius of the unit vector away from each, weighted (radius - d) / radius. The point then steps strength * radius along it. g:fold repeats the pass iterations times. With radius 0 and a single point, the radius is 1.
Built from: core.reduce, core.neighbours, g:fold, math.*.
Inputs
points(Geometry). The cloud to even out. Only positions move, so an index, colour or scale still belongs to the point it started on.iterations(Float, default 5, at least 0). How many repulsion passes to run. Each moves every point once by the push of the neighbours around it.radius(Float, default 0, at least 0). How far a point feels its neighbours, and the scale of the shove it gives them: only pairs closer than this push, and the push fades linearly to nothing at the edge. 0 derives one from the cloud: the longest side of its bounds divided by the cube root of the point count.strength(Float, default 0.5). The share ofradiusa point may travel in one pass: the pushes from every neighbour in range are averaged into one direction and the point steps strength * radius along it.
Outputs
points(Geometry). The same points, moved.
local even = g.points.relax({ points = g.points.disc({ count = 200, radius = 2 }), iterations = 4 })