Is there a way to avoid overlapping or intersection for randomly distributed objects with Animation Nodes?

I distrubuted objects with instancer and the loop function see below:

As we can see the problem is they are overlapping occasionally. Of course, the more object I distribute the more likely they overlap. My first idea was to use the Intersect Plane Plane node but I didn't know how to incorporate it into the graph. To avoid overlapping we should also measure distance between objects to limit the calculations (only adjacent objects matters) because otherwise the node graph could be very slow. So the soulution might be very comlex.

The current graph can be seen below:

• Feb 22, 2018 at 21:13

I don't have a solution that is not computationally expensive. But if performance is not a big factor in your node tree, here is method you can use.

Append Condition

You create an empty vector list, at each iteration, you construct a KD tree from this list, generate a a random vector, check if there are any vectors in the vicinity of radius equal to circles diameter, if there are, don't append it, otherwise, append the random vector:

Blend File:

• Can you share the blender scene file? I tried to reproduce your solution but something not right for me.
– Prag
Mar 4, 2018 at 17:44
• @Prag Sure, I added the blend file. Mar 4, 2018 at 18:24
• I tried to utilize your soultion but I failed with real cylinder objects. As you can see the graph here (ANGraph) this results overlapping cylinders (3D View). Furthermore a bit confusing that your input attriubte is named to diameter but it is connected to the radius attr of the Find Points in Radius node.
– Prag
Mar 13, 2018 at 19:25
• @Prag Your multiply node that goes into the diameter is set to 1, set it to 2. The radius input in the Find Points in Radius is the radius of the search circle, and since we are testing collision between two circles, that is, two radii, that is, a diameter. Then the radius is the diameter. Don't worry yourself with naming. Mar 13, 2018 at 19:35