# Recursive fractal pattern generation

Hello! In an old book, I found this graphic:

The logic got explained this way:

Does anyone know how to do something like that with Grasshopper components? And maybe also how to use other shapes instead of just circles?

That’s very easy with code (but is also achievable via components). Notify if you want a C# entry level demo (any shape).

Hey, thank you! I think I would prefer components. Do you know how to do it with that?

Components are not my game - at all. You sould wait until a good Samaritan does that for you (propably using a Loop thingy the likes of Anemone).

In any case in real-life we ALWAYS use public Trees for the results (branch on a per Recursion Loop basis) for obvious reasons: say you want thicker/thinner Pipes on the Curves (or Colors or whatever) … blah, blah.

BTW: If you after rnd Circle games … well … some ultra freaky Apollonian (max 8 Circles) or a mild Tangent Circles “along” Circle MAY yield more interesting results. See demos without Recursion.

1 Like

Hmm. I think I just would need a simple components file for it. I already tried to cut lines and put shapes on them, but it didn’t work the way like in my example.

It’s strictly a matter of other good Samaritan(s) I guess.

Well, take a good look at what Peter has kindly provided for you in his video example. What are the circles doing? Analyze the interaction between the shapes. Are they bi sected by radial lines through centroids? probably not. Are they positioned tangent to each other? Hmm. Perhaps. Anyway, once you have thought through what the shapes are doing, and can get it to work for one example circle, then modify that for one of the other circles in Peter’s kind example. In this way you will start learning to think geometrically, and find the logic in both Peter’s example, and your own, or any other tiling sequence for that matter. Good luck. Hint, for Peter’s example, use Tan-tan-tan component

BTW: NASA is against Recursion (stack and heap safety … blah, blah).

1 Like

Did not know that about Nasa, but makes sense

Yes - NASA style of problems - and (mostly) no: pragmatic life problems:

Enter tail recursion: i.e. a recursion of a function where it does not consumes stack space and hence prevents stack overflow. If the recursive function is made tail-recursive then it is rather far far more efficient than a non-tail-recursive function because every function call does not need to go on stack and pop when the call is done. This prevents the ugly stack overflow (for big data and big N of Loops).

In plain English: assume that you do something where a hierarchy of the results is a must (for a zillion reasons). So … a public DataTree is not a bad idea: in each public Loop you just access the last branch meaning that for “reasonable” amount of data (like the ones we encounter in AEC in 99.99% of cases) you can cut the mustrad with no issues.

Note: always have Plan B if despite all that … blah, blah,

Well, for my last computer ‘smash’ I found that dumping a cup of tea over the keyboard of my laptop did the trick. Decaf even. Call it ‘accidental research results’
The discussion of Nasa does bring up the idea of using your model to calculate orbital mechanics of 3 bodies. Would need to add elliptical orbits. Keeping it simple, ignoring acceleration and deceleration due to gravitation attraction, atmospheric drag, rocket propulsion, solar wind, electrostatic propulsion; also mass loss due to propellant consumption and vehicle separation, unless you happen to work for Mr. Musk.
But, back to ‘Cucumber’ 's original question. Maybe we could break it down for him/her, one loop of your demo, in pseudo code steps, so he/she can try assigning components as an exercise. Once they understand your demo, then they can try applying that to their original photo and design