algorithmic modeling for Rhino
Dear community,
I am new to grasshopper and as I learned in the introduction video one should work into grasshopper by trying to solve a specific project. My problem is, I don't know how to approach the solution and I'm hoping for hints which way to go...
The goal
...is to have grasshopper randomly distribute a certain amount of sticks in a certain angle (or range of angles) in a certain area without them colliding with each other.
In this example I did it manually, but I'd like to do it in parametrically in the future (altering amount, angle, area, diameter, length...).
My (pseudo) logic:
set counter //amount of sticks
loop counter {
make instance of stick on random point in area // cf. populate
rotate stick within parameters // tilt and rotate
try to intersect all sticks
if (intersection = TRUE) {
delete current instance of stick
exitcounter++ // don't want to get stuck in the loop
}else{
counter++
}
if exitcounter > max {
exit
}
}
My thoughts:
Cheers,
d@2T
Tags:
You could also just create a bunch of sticks that are randomly placed/angled, and just cull all the ones that happen to have intersections.
This is actually one approach I thougth of, but I wasn't able to put it into practice properly. The downside here in my opinion is the difficulty to control the resulting amount of sticks - which is crucial to me.
But this sounds like a case for galapagos, where the the gene would be the seed to randomize points and the fitness would be the resulting amount of pipes that don't intersect?
My thanks, anyway!
Anemone - This was fun. You could use 'Fast Loop' but it's fun to watch.
I see that Brian Harms has done a version without looping. Interesting approach but different model so different results.
This is a better version of the Anemone loop approach to this challenge. More robust, more fun to play with and watch. The green "X' points are the ones that remain unoccupied, the blue pipe is the one being tested. The basic idea is simple. What is quite challenging in Grasshopper, compared to conventional programming languages, is the lack of "if ___ then" to avoid possible error conditions. Instead, both possibilities must be generated and then the correct one selected with 'Stream Filters'.
This is what it looks like when that loop finishes - none of the pipes collide.
This is freakin amazing, just what I was looking for! Though it will take some time to comprehend this gem, I will try to implement the option to place external 'colliders' to leave out certain spaces (imagine placing a sphere somwhere in this tangle and omit sticks that intersect with it).
Thank you so much!
Great work!
Starting from your example I would like to try a similar exercise: positioning circles going farther from a specific point and not shuffling the list every iteration.
Any suggestion on how to achieve this?
Thanks in advance!
Thank you Joseph Oster, this does right what I was looking for and the time will come that I also understand how it does it.
To reproduce the initial design I changed some slight details for my purposes, like mirroring the tubes, rotating them against z-axis with step-wise angles, using rhino geometry for the area and using meshes as external colliders.
© 2022 Created by Scott Davidson. Powered by