Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

core.neighbours (procNode)

What stands near each point: how many points lie within a radius (optionally inside a cone), the nearest one, their centroid, the mean of an attribute over them, or the push away from them.

Built from core.pairs (the points within the radius of each point), the hash_nearest kernel over core.spatial, gather, math operators for the cone and the push, and scatter folds back to the points. mode "measure" writes neighbors (count), nearest (distance to the nearest), centroid, and neighbor_<name> for mean; "nearest" writes nearest_index (the source point nearest each point, -1 where none lies within radius when it is above 0) and nearest; "repel" writes push, the average direction away from the neighbours within radius, each weighted by how close it stands. direction, cone and mean are plain values chosen when the graph is built. Without sources a point's neighbours are the other points of points.

Inputs

  • points (Geometry). The points that look around.
  • sources (Geometry, optional). The points looked at. Left empty, each point looks at the others of points.
  • radius (Number). Default 1.0. How far a point looks. 0 looks without limit in "nearest" mode.
  • mode (one of measure, nearest, repel). Default "measure". What is answered: counts and centroids, the nearest source, or the push away.
  • direction (String). Default "". A Vec3 point attribute each point looks along; given, only neighbours inside the cone count.
  • cone (Number). Default 360.0. The full angle in degrees of the cone around direction; 360 counts every side.
  • mean (String). Default "". A numeric point attribute whose neighbours' average each point takes as neighbor_<name>.

Outputs

  • points: the points with the answers as attributes.

Example

local points = g.points.grid({ countX = 4, countZ = 1, spacing = 1 })
local measured = g.core.neighbours({ points = points, radius = 1.5 })

Within 1.5 of each other, the end points have one neighbour and the inner two have two: neighbors holds 1, 2, 2, 1.