Square/rectangle packing - stick to closest

Hello everyone,

I’m trying to find a way to group/pack those squares, without overlapping.

I’ve seen a few possibilites (lot of square packing solution on the GH forum) but I want to keep the same organisation, so each curve need to stick to the next one.

Here are attached images of what I currently have, and what I want to achieve.

171202_SUPERMETHOD_DIAGRAM_6_FORUM.gh (7.5 KB)

Any help or suggestion appreciated,
Thanks a lot !

You need an itterative method, hoopsnake or code (Python, C# …). What is not clear is the algorithm. How do you choose the first, next … Sometimes you move straight sometimes diagonal. Is an element in a group glued authorized to move …
Try to give your algorithm. For example
First block is the nearest from center (which one ?) of the shape
Nex block is the nearest from center, and glued to the already glued group moving perpandicular to its edge …

Kangaroo may surely also be a solution.



There is a collide between circles and shapes, could be very useful for you.

Thanks for the answer.

Yes in fact I would need a step by step method, I’ve been looking at some “2D-Bin-Packing” solutions but the problem is it’s only Corner-based packing (because of x and y) while my code would require to take each square and stick to the closest.

So an iterative method could work just perfectly.

BUT I think you’re right with the kangaroo method, setting the centered square as an attractor. Plus I had in mind playing with a tolorance parameters, so a more “physical” approach is welcome.

Merci Laurent, I’ll give it a try and repost here.

Hello Laurent,

I found an interesting way to solve this problem thanks to your tips.

To anyone in the future with a similar problem, I solved it with this post :

Thanks

2 Likes