Voronoi - Random Points for Each Sub-domain

Hi everyone,

I’m using Rhino 8 and trying to learn Grasshopper, so I’m still quite a beginner.

My starting idea is to represent a sample of rock composed of crystals. Since I was already somewhat familiar with Voronoi, it seemed like a reasonable way to represent this structure (although if there are better methods for this kind of problem, please let me know).

What I would like to achieve is a cube filled with 3D Voronoi cells, where I can somehow ‘control’ the distribution of the cell sizes. I’ve read about this, but the typical point attractor approach used to vary point density doesn’t seem to do exactly what I need ( Weighted Voronoi ("Solved"?!) - Grasshopper , differentiated voronoi - Grasshopper , Voronoi customization with attraction points - Grasshopper , Variable Voronoi mesh size , Sphere Packing - Radius change Dynamically - #3 by DanielPiker )

My idea was instead to divide the cube domain into many subdomains, and then assign a certain number of points to each subdomain. This way some regions would be denser than others, and in principle I could have some control over the overall distribution of the Voronoi cells.

More specifically, I want to assign a minimum of 1 and a maximum of 5 points per subdomain. I control this through percentages (for example, a certain percentage of subdomains get 1 point, another percentage get 2 points, etc.), and then I manually check that the totals match the expected counts.

However, I’m running into something I don’t understand. Once I generate n subdomains and create a list of n values indicating how many points should be generated in each cube, the points inside each subdomain are not random, they are always distributed in exactly the same way every time.

I was expecting a random distribution of points inside each subdomain, but that doesn’t seem to be happening.

Does anyone know why the point distribution remains identical, and what I might be doing wrong?Also, if anyone can think of a better approach than Voronoi for representing a crystalline rock structure like this, I’d be very interested to hear about it.

Finally, if anyone has already worked on a similar problem or encountered something like this before and found a good solution, I’d be very interested to hear how you approached it.

Thanks in advance guys!

(I’ve attached screenshots and the .gh file showing the setup)

test.gh (28.7 KB)

Change the “Seed”.

Given two boxes, different sizes and position, if the Seed is the same, the generated point will be at the same “parameter” inside each box.

This is wanted , because once you find a design you like by changing inputs in a grasshopper definition, you save, close, open again your project, you expect to be exactly as you saw it last time!
So any “Random” or “Populate” in grasshopper is actually a pseudo-random.
Same seed equal to same “parameter”.


Feed a simple growing series of integers into your “Populate 3D” component.
If you have 100 boxes, feed it with also a series of integers going 1 to 100 (or 0 to 99).


Hello @maje90,

Thank you for the explanation and for the illustrative example. Thanks to your reply, I think I understand things a bit better.

I tried to replicate your example and play around with the seed to see how it changes depending on the input. Then I followed your advice: “if you have n boxes, give it a list from 1 to n as input.”

However, even though when comparing the coordinate values in the three directions the numbers never repeat (so the seed seems to work as you explained, I guess), it is still possible to identify a clear repeating pattern:

Intuitively, I would expect something much closer to what you would get with a “normal” Populate 3D using the same number of points:

Does anyone know what might be causing this, or what I might be misunderstanding?

Thanks!

test.gh (21.6 KB)

That’s probably because your seeds are simply a series of ascending numbers, which is also kind of a pattern. Try to provide a randomized seeds instead.

Another approach using Random c# class and avoiding Populate (i’m using evaluate box instead):


test (1).gh (16.3 KB)

@arvelox Welcome to the forum!

Multiple seeds? C# scripting? :face_with_raised_eyebrow: .This can, and probably should, be all done with a single seed:

Voronoi - Random points for each subdomain VR 01.gh (30.7 KB)

Hi everyone,

Sorry for the late reply, but I only had the chance to check your responses today.

First of all, I’d like to thank you all!

@diff-arch, thanks for the reasonable and likely explanation.

@maje90, thanks for the clear explanation and for the example, which is very much in line with what I had done.

@Volker_Rakow, thank you for the welcome! And thanks as well for showing me and providing an alternative approach to what I had proposed. I have to say, your example will be really useful as a reference for me to try and understand many other things, so thank you very much!!

Also, if anyone happens to have a better idea on how to achieve the original goal I was aiming for, I’d be more than happy to hear any suggestions.

Hi, here you can find an interesting video about randomness in Grasshopper and the plugin Heteroptera.

One thing to take home from the webinar is: to get better pseudo-randomness when using multiple seeds, you must use seeds value with high numbers (6 or 7 digits or even more, I don’t remember exactly, just try)

Random is as random does.