Random points with min Distance

So I’m trying to simulate a forest (each dot represents a tree).

The simulation is random, but dots / trees should never get too close to each other (hence the min distance dilemma).

Ideally it would be great to add a constraint to the “populate 2D” command, but seems impossible, so here’s the solution I went for:

So say each tree has a canopy of 9m radius, and the min allowed distance between trees is 18m.

By using some lists and inputting this info it is possible to add the 18m constraint and eliminate those who break the rule (see red dots / circles).

However this solution is far from perfect, as it only uses 1 vector to determine whether a point should be deleted or not… So it ends up deleting more points than it would be necessary (not a smart solution).

Maybe a smarter approach would be to use the “Proximity 2D” command (see above in script, highlighted in red rectangle) as a way to consider multiple vectors rather than just one.

This way less points could be deleted as the list would consider multiple distances and the mesh as a whole before determining constraints.

As an example I have chosen a small section of the frame. Highlighted in yellow are 2 points that would be deleted through the previous approach, by using the “proximity 2D” command only 1 would be deleted (see following image).

The problem? I currently do not know how to use the info gathered from “proximity 2D” as a way to eliminate the points that do not meet the criteria… Maybe you got some ideas.

Alternatively and to avoid this whole hustle, a found a guy that allegedly created a script in Kangaroo that solves this issue from a beginning, meaning: It generates random points with any given min distance between points as a constraint (like a repeal function).

However one key command doesn’t seem to work on my PC (the one in red) and I fail to understand why…

The thread to this guys solution is the following: https://www.grasshopper3d.com/forum/topics/random-point-with-distance?page=1&commentId=2985220%3AComment%3A819233&x=1#2985220Comment819233

I’ve attached both scripts + some further possible lists solutions (shout out @bdkt_), if you have any ideas do hit me up, it would be of great help.

Solution 1.gh (10.8 KB)
Solution 2.gh (21.1 KB)
Solution Kangaroo.gh (10.4 KB)

I can help with the Kangaroo version, but before that, I think there might be an even simpler way, using Cull Duplicates, with the option set to either “Leave One” or “Average”:


Hi Daniel,

Thanks for the early reply.

Indeed, “Cull duplicates” worked perfectly!

I’ve gotten rid of my other approaches.

Good one!