How to locate 'neighbours' in 3d array?

How can I get pairs of 3d coordinates that correspond to the position of neighbouring objects in a 3d array?

Eg - in an array of boxes (positioned using linearspread > cross3d) the neighbours would be cubes whos faces ‘face’ each other.

Thanks

well it’s bit pain in the ass actually, basicly you need take index of your cube then spread it so for the grid 10x10x10 it will be:
{
X-1 for left,
X+1 for right,
X-10 (or 11) for top,
X+10 (or 11) for bottom,
X-100 for back,
X+100 for front,
}
might be not that right but concept is like this…

hehe

Right, yes that should work.

So far I tried looking for differences in position equal to the ‘step size’ in the linear spread. Should work also but my patch crashed so I thought I’d see if there was another way before rebuilding it.

Thanks

probably time to introduce a kd-tree to vvvv. or someone already done this?

don´t know if you meant this but…
see patch

Boxes.v4p (23.1 kB)

Elias: nooooop
what the f*** is that?
my english not good enought to understand the madness of n-dimensional logic

ufff… switzen…

loooks like it will mass-save time to patch the clip i’m hunting for a long time

switzen…switzen…

where to start?

@bjoern

Exactly like that. A couple of nice tricks in there, thanks :)