Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

points.poisson (procNode)

Even (blue-noise) points in a disc on the XZ plane, no two closer than minDist, found in rounds of random candidates: a candidate stands when no other point or candidate lies within minDist. Use it for trees, stones and anything that must not overlap.

All the candidates of all maxTries rounds are drawn at once, floor((radius / minDist)^2) + 1 for each round, uniformly over the disc. Each round of a fold lets the candidates of that round stand where no point already standing and no other candidate of the round lies within minDist. Every point carries a tag, 1 when it stands and 1000 when it is a candidate of the round, and the tags of the points within minDist of each one are summed (core.pairs lists them, core.scatter adds), so a single sum answers both counts. The points that stand are kept at the end by core.select, in round order. Later rounds fill the gaps earlier ones left, because a candidate near a standing point is dropped.

What holds: no two points closer than minDist, every point inside the disc at height y, and the disc covered: a probe anywhere in it finds a point within twice minDist. The points carry P only.

Built from: rand.unit, core.points, core.pairs, field.gather, core.scatter, core.select, g:fold.

Inputs

  • radius (Float, default 2, at least 0). Radius of the disc the points are thrown into. Area grows with the square of it.
  • minDist (Float, default 0.3, at least 0.0001). Closest two points may end up. A candidate within this of a point already standing, or of another candidate of its round, is rejected.
  • maxTries (Float, default 30, at least 1). How many rounds of candidates are thrown. Raising it packs the disc tighter.
  • y (Float, default 0). The height the disc sits at: every point takes this as its y.
  • seed (Float, default 1). Picks which candidates are drawn: one seed produces the same points on every run, machine and platform.

Outputs

  • points (Points). The points that stand, carrying P.
local trees = g.points.poisson({ radius = 3, minDist = 0.5 })