algorithmic modeling for Rhino
Hi guys,
I'm currently working on a simple project in grasshopper in which one part of the algorithm creates a couple of squares (~5-10) and places them on a random x and y position in a given area.
The problem is that of course there are several intersecting squares. I already tried solving this with hoopsnake but somehow I can't get it right, so I was wondering if anyone could give me a hint how the gh code would have to look or tell me if this is even something that I can easily do using hoopsnake.
My approach would basically be to create the squares, check if they are intersecting (with a solid intersection object) and tell hoopsnake to move them around as long as they aren't intersecting anymore.
Thanks!
Peter
Tags:
Did something similar once. Check out this.
I believe all components you can´t read are just params. You can leave out the group on the lower left. It just changes the rotation direction every other cycle.
Your description of the algorithm is pretty general, so I guess you haven't found a logic how to move the squares in case there is an intersection...
But you don't need to. GH features a generic solver galled Galapagos. Since your initial positions are random, any result will be pretty random and Galapagos will create just that: a random set of slider values. It will test for "fitness" as a way to tell if the solution is "good" (no sqares overlapping in your case).
All you need to do is position your squares with a bunch of sliders (or better the GenomeList Component) and test of intersection. Region Intersection (RInt) will return all the overlapping areas. If there is no overlap, there will be no result. So you can just use number of returned overlaps as fitness (to be minimized obviously).
A little slower but better fitness would be to minimize the area of overlap. It's better because one large overlapping area is still worse than two very small overlaps.
thanks for the quick responses guys, @phillip: I'll try yours as soon as I get home where I can use my big screen to have a closer look at the picture:)
Hannes I tried your solution and it's basically exactly what I need, the only thing I would need additionally, is to get a gap between the rectangles. Because right now their "almost" not overlapping but I would like the rectangles to be distributed over the area in a way that there is some space between them (how much space isn't really important) So if I'm correct I would have to use some object or algorithm for "fitness" which measures distances between the squares and use galapagos to maximize this "fitness" (instead of minimizing intersections) to get the greates possible distance between two squares?
Thanks!
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by