Help! How can I create a Quadtree that fits into a predetermined grid?

Hi all,

I could really use some help. I’m new to Grasshopper and there ist just nothing on the internet on this topic. I want to generate a Quadtree for a curve with a grid that is determined. I tried to do that but every pattern that’s generated isn’t fitting into the determined grid. I would really appreciate help <3

And is there anyway I can extract the resulting curve?

quadtree.gh (20.2 KB)

Hello

giving that as an example is really not helpful !!!

FroGH is perhaps the tool you need

Define a surface (square) that contains your grid then choose the number of iterations.

https://www.food4rhino.com/en/app/frogh

You can also “cheat” with native component by adding corners.

quadtree LD.gh (11.1 KB)

4 Likes

Hi,

thank you very much for replying! I did as you suggested, but it didn’t quite solve my problem. I wanted the quadtree leaves to match my my grid, but it’s stil not overlaying. Is there a possibility to adjust the position and scale of the leaves? thank you in advance!!

consider that if you are not looking for its lightspeed calculation time, but are more interested in reproducing the cell-division behavior, a quadtree is just an iterative process of dividing a given 2D-domain into 4x 2D-domains with some checks

here is a dirty fast sketch forcing it on a predefined grid, using Anemone to loop cell subdivision:

manual_slow_quadtree.gh (18.9 KB)

1 Like

You MUST do some mathematics. The quadtree will divide the square you provide by 2 each time, so you MUST provide a square with 2^N cells in X and Y. In your example your provided 17.xx cells in each direction.

With @inno solution you’ll have surely more control. And FroGH will be the most simple if you provide a surface that fits you grid with 2^N cells in each direction …

Here is my try based on the second solution by @laurent_delrieu.

curve-quadtree.gh (19.5 KB)

Thank you all for your input! @flokart your attempt is exactly what I wanted to do, but when I try to change the grid size, the quad leaves don’t stay in the grid but crosses it. Do you maybe know how to solve it?

Hi @Vanessa_Nikolic

if i change the grid size it fits inside the grid.

Please explain it more presize , show images , upload files.

only if the grid is square then the quadtree input S needs to be a boolean = true otherwise it is rectangle and the S input boolean = false.

Hi, I already tried that, but in my case even the rectangels don’t fit and ar overcrossing each other. The grid should be 1.7m x 1.7 m, but everthing is just chaos, if I do that. This is the rhino and grasshopper file…

v1.3dm (631.1 KB)

quadtree_try.gh (19.0 KB)

Try this one @Vanessa_Nikolic

quadtree_try.gh (19.5 KB)

Thank you sooo much!!! Now it’s fitting in the grid! YOu helped me so much ><

:+1: your welcome

1 Like