## Basic Fractal Generator – Example 9.1

Before getting into some more complicated and more interesting fractal patterns, I wanted to show this fairly simple example to demonstrate what a fractal pattern is in theory. This script also might be helpful for “softening up” a drawing and making ugly lines warm and fuzzy like plants. The reason this works is because plants, like many things, exhibit “fractal behavior.”  To what degree natural geometries are true fractal forms or not is debatable. Fractals were super popular in the 80’s and people were finding fractals everywhere…now they have become pretty much accepted as part of the mainstream, and “Fractal Art” for its own sake is kind of boring. Still, they can serve useful utility functions and are the basis for a lot of contemporary form generation (and arguably a lot of traditional art as well, such as the ice-ray lattice shown previously). So what is a fractal. Well, even people who work with them a lot can’t tell for sure what definitely IS a fractal or what is LIKE a fractal. But there are a few key words that will tip you off that what you are looking at IS a fractal form or could be described, and hence modeled, with fractal principles. Recursive Process – Recursion is the basis of fractal patterning Self-Similarity – The recursive processes develop processes that are self-similar at multiple scales. What does this mean? Below are two images that demonstrate self-similarity. The first is the introductory image to this section. Notice the geometry in each of the rectangles is “similar” to the geometry in the smaller rectangle. The second is a somewhat humorous take on self-similarity. Most everyone is familiar with the Russian Nesting dolls. The creator of this set used the dolls perhaps to make a political statement about the self-similarity of Russian politicians (or maybe just politicians in general).

Image: Wikimedia – Brandt Luke Zorn, 2006

What are some other patterns that are self-similar. Well many natural forms are, for example rivers. Narrow rivers and wide rivers both have meanders, but the meanders are proportional to their width. So a wide river like the Mississipi would have very large meanders, while a smaller river could have meanders of only a few meters. Also, the branching of a river network is self-similar. To what extent it is a “fractal” is debatable, but fractal principles can be used to some degree to model them. Anyways, onto the example. Basic Steps What this script does is it takes a polyline, drawn in Rhino, and deconstructs it into its individual segments in Grasshopper. To each segment, it applies a process described in the image below, which will generate similar results. The results for segments of varying length will differ, however, since the “offset” of the square is proportional to the initial length of the segment. So in each Recursion, one segment gives rise to five segments in total. The original segment is discarded in this example. This process is then repeated on the results of the first round, so this is recursive. So now that the basic process is described and setup, we can apply this to any poly-line. Here is an example of the script applied to a simple square, with the resulting shape after each recursion. Note that if you try this in Rhino, you may get different results depending on the direction in which you draw the curve. In other words, the process may happen on a side of the curve you don’t want it to as below. To solve this problem, you can either redraw it, or better yet, click on the curve you drew in Rhino, and type “Flip”  (there is probably a button for this too). The main purpose of this script is to demonstrate simple fractal behavior and to get a process setup, but this does have a potentially useful application. If you are drawing plants in a plan, or the edge of a forest, etc, this could be useful for softening up the edges. Anyways, below are some example of before and after for various shapes. Note that the way this script is setup, you can apply it to many polylines at once. So I explained the logic of the script. For the actual setup, If you haven’t done a loop yet, you should look refer to Example 8.1 where i briefly explain how this is setup, and you will also need to add the Anemone component to Grasshopper. The steps are fairly simple. I use evaluate curve at .33 and .67 to find the 1/3 and 2/3 points, as well as the tangent vector here. This vector is then rotated 90 degrees to offset the points. The amplitude of the offset is taken by measuring the distance between the 1/3 points and the endpoints. I used closest point here to get this distance…I’m not sure why, but it works. You could also use Distance but be sure you select the right points to measure. This distance is multiplied by a factor to determine the amount of offset, how big the “bumps” are. Once this is done, the tricky part is reassembling your points into a polyline. You will need to carefully keep track of your points to do this. I choose to do this by putting the points in the correct sequence using the “Merge” component, and then using the polyline component to join them. You could also draw individual lines, but then you would need to use five line components, line from points 1-2, 2-3, 3-4, 4-5, 5-6, and then join the segments.  If your shape is “closed” you can create a boundary suface at the end and color this if you want green plants, etc.  Anyways that’s about it!

Grasshopper Script – Example 8.1

Slight Variations

You can make some minor adjustments to the script to get different families of forms. The images below show the initial subdivision rule, and then the results after 4 recursions. If you understand the script, it should be no problem making modifications to generate the various forms described. Sometimes a small change in the initial condition can have a big effect on the final outcome!