# Generative Design Variations M.5.1 Recursion

This is the start of a new chapter. Chapter M.5 Tree diagrams. Tree structures are graphic representations of hierarchically structured data. The first assignment is about recursion. I quote here the Generative Design book: ‘The principle of iteration – the repetition of parts of a program – is a popular way to tackle complex tasks. The use of for-loops in almost all of this book’s programs reflects this approach. Sometimes, however, this simple method of repetition does not suffice. When processing information or generating structures that are hierarchically nested – such as tree structures – recursion is often the only practical method. Recursion makes use of a function’s ability to be called (again) from within itself. Of course, it is necessary to ensure that at some point the function is no longer called, to avoid an endless loop. In the following program, a ‘branch’ is drawn by a function repeatedly calling itself.’ Here you can find the original program.
M_5_1_01

I did not find it necessary to put my modified code online. I changed not very much. Anyone who is interested in programming can find it out themself (which is –by the way–more instructive). I did prepared a Flickr Album which contains all still images I have made during this assignment. You can find that album clicking this link:
GDV_M_5_1

Recursion is something new for me. I never like to use it much because I thought that the images it delivers are too symmetrical. And generally I do not like symmetrical images. Symmetry makes everything very balanced. And most of the time that is not where I am looking for. But let me give it a try. I flipped the first image which sketch M_5_1_01.pde creates. It is almost a symmetrical image. Well almost because to make it totally symmetrical it should be vertically mirrored. So that is what I did. And because I thought well if it can be vertically mirrored than it can also  horizontally mirrored.
M_5_1_01_GDV_01

In fact this image does look different from the previous sketch but it is not. Instead of mirroring the recursion four times (which is in fact a rotation of 90 degrees) this image is rotated 128 times with a rotation angle of 2.8125 degrees. It is an interesting image but you do not need recursion for that. Using the 1-9 keys you can increase or decrease the amount of the recursion level.
M_5_1_01_GDV_02

So I decided to take a step back. How does recursion actually work? And how can I modify it? I replaced the arcs with straight lines. Visually this makes a great difference.
M_5_1_01_ GDV_03

Just by coincidence I found out that you can also adjust the branches without changing the T-shape. I am now trying to make more complex images. Just keeping the recursion in the back of my mind. I have left out the dot because I don’t know what it is good for. Just repeated the drawT line a few times with some divisions. It gives a more chaotic image in the end. But there are all kinds of interesting things going on. And that is what I prefer.
M_5_1_01_ GDV_04

This sketch is basically using a triangle on it’s point. The recursion pattern is just the same as in every previous sketch. Again I rotated the recursion 128 times with an angle of 2.8125 degrees.
M_5_1_01_ GDV_05

Tried to make a cross (or plus-sign). That worked out fine. But I found another way to modify that cross (or plus) which on it’s turn lead to very different images. Not that I like them. But it is interesting to see what kind of images you can find.
M_5_1_01_ GDV_06

This is the same plus-sign as in the previous sketch. But I just switched off the minimize  function. So every recursion cycle draws of a plus-sign without changing it’s size. And because I used an alpha channel the layering makes the signs darker and brighter.
M_5_1_01_ GDV_07

Another range of variations with the plus-sign used as a street-pavement pattern. Just modifying things a bit can have great consequences for the final image.
M_5_1_01_GDV_08

This is another way of using recursion. A circle. And within that circle are two other circles. And within those two circles are… and so on. But when you rotate the recursion you get very interesting patterns. They look a bit too classic to me.
M_5_1_01_ GDV_09

In fact this is again the same shape as in the previous sketch. I moved the circles out of the large circle. That gives all kind of different possibilities with complex patterns. Interesting. But I don’t know if I would use them in any design. We will see.
M_5_1_01_ GDV_10