Distribute different geometries randomly on points on a line

Hi Guys,

I tried searching the forum, but I guess the problem might be too easy…
As you probably can tell, I’m a beginner trying to find my way into GH. Maybe you can give me some hints on what I’m actually missing. I’ve been trying for some time now.
I’m tying to generate a grid of lines (managed that) and allocate random points on each line (partially managed, every line has the same random points. I’m aware that this is a data structure issue but I cant tell where it is going wrong.)
Then I need to analyze the points for a minimum distance (kind of managed).
On these points I would like to- again in a random manner- allocate 3 different sizes of spheres (far away from that goal atm).
As a bonus the grid should be trimmed if colliding with another geometry (such as a tilted roof or floor for example.)
I would be so grateful if you could give me some advice on that issue.

Many thanks

b

pretty difficult to understand what you want to achieve and how to do that by looking at a screenshot of a gh definition :upside_down_face:

please post your gh file with internalized geometries, and eventually it might be very helpful an additional screenshot of the actual geometrical situation the script produces, on which you might want to sketch (even poorly, still very helpful) the results you are after :+1:

you can read this, expecially point 3) to get some insights on how to include internalised geometries: Help Us Help You

Dear Inno,

thanks for your feedback. You are absolutely right! Sorry for that.
Attached an image of the grid of lines and the spheres. As you can see they are randomly allocated on one line, but the same random points for every line.
I didnt get as far as allocating 3 different sizes of spheres unfortunately.


gh_test.gh (13.9 KB)

1 Like

pretty clear explanation :+1:
the following will build a grid, create lines on each grid vertex that point to +Z, and build spheres on 3 random points for each line

gh_test_Re.gh (16.0 KB)

in order to change the simulated randomness, you can play with this slider:

the 3 points along each line are found as % of line length, where 0% is at their base, while 100% is at their top:

this also means that -for instance- let’s say you want the first and last 15% of each Line to be empty, you can just type 0.15 to 0.85 as random Domain, and you’ll get something like this:

[in the attached gh file I have replaced the Sphere with MeshSphere because it’s faster to build geometries)

if for each line you want to allocate spheres of different diameters, data is now organized as lists of 3 points for each Line, you can just determine the 3 different radii and jitter them by the number of branches you have, for instance:



speaking of collisions -which is not a thing in the above definition-
there might be many ways to avoid two colliding spheres, the easiest one (but it also much limits the number of possible configurations) would be to give to each of the 3 points its own Domain of existence, where these Domains are spaced between each other and non overlapping

This means that the first point will be for instance always in the first third starting from the bottom, the second point on the middle third of the Line, and the last on the top third like this:

but this also means that scenarios like the following could never occour, as all the points appear to be in the first third of the curve :upside_down_face:

if you are happy to explore, I would suggest a Loop approach
each line is randomly populated by a point at a time, and a check is executed to verify that the new point we are going to place is distant enough from
a) the last one inserted
b) all the other points in any line
c) all the other points in that very same line
if you populate a list of center points and a list of radii, you can indeed always check if a new sphere (Point with Radius) will collide with the other ones using Distance, which will make things pretty fast… if it’s distant enough then proceed, otherwise just generate a new random point and check again, rinse and repeat until all Lines are populated by the desired number of spheres

that would require some -basic- coding, or -if you are open to using plugins- probably you’ll need Anemone

but to do that it’s important to know some more details about sphere-radii distribution: you mentioned 3 different radii, I guess you mean each line will receive 3 spheres in total, one for each radius?

Inno! You are amazing!! thanks you so much!
I’ll take a closer look later on, I hope I understand it.
have a great day, thank you again!

pete

1 Like

Hello again,
I finally found time to look at it in more detail. Thanks again, it’s not only really great help but also really pushed me to try to understand and reengineer the script!
This way, I managed to solve the trimming of the lines myself (yay).
I’m still trying to find a way to be able to integrate a counter for the individual spheres. Basically counting how many objects of diameter 1,2,3 there are corresponding to the geometry.
I know, the data is in the EvalCrv element, but is there a way to display it other than connecting a panel and doing the math for every new configuration? Could you maybe give me an hint?
Thank you very much!!
pete
gh_test_Re2.gh (17.1 KB)

Sorry to bother again, could anyone give me a hint how to solve this?
many thanks!