## Multiply and Scale Geometry – Example 9.2

This second script also demonstrates fractal behavior with self-similarity through scales and recursion. The premise is fairly simple. It takes a piece of geometry, a circle, rectangle, blob, etc. and in each recursion makes a certain number of copies of the geometry, sends it off in random directions, and then scales it down.

The first three results of the script shown above start with a large circle, which is copied 3 times, and scaled by around 50% and sent into 3 random directions. This goes through 5 recursions to create the above patterns. The three variations are created by changing the random number seed, which has the effect of only changing the directions of the random circle movement.

The above three variations have very different results. The only variable that is changed is the number of copies made in each recursion. The image on the left shows a process with 2 copies per recursion, the image in the center shows 4 copies per round, and the image on the right shows six per round. Obviously here the circles multiply very rapidly.

Any closed piece of geometry can go through this process. Here the settings are back to three copies per round, but the initial or “seed” geometry is changed. Triangles, blobs, rectangles.

And finally, the results can be changed quite a bit by changing the scale factor per round. In the image on the left, the rectangles scale slowly, with a 30% reduction each round. In the image on the center the reduction is 45% per round, and in the image on the right the reduction is 55%.  Scaling much more than this and the pattern starts to get lost in the later recursions.

Below is an image of the script. There aren’t many new tools show here, so I’ll let the image speak for itself. You do, however, have to pay attention to the flattening and grafting, and especially how the random angles are generated. In short, you need to generate random angles based on the total number of objects from the previous recursion, and then this list is partitioned and grafted into the list of shapes. A bit tricky with the data structure at first but hopefully it makes sense.