I just finally got my copy of Mandelbrot's book on fractals. In his discussion of curve fractals (that is, fractals formed from an unbroken line, isomorphic to the interval (0,1)), he describes them in terms of shorelines rather than borders. I've got to admit
that his metaphor is better than mine, and I'll adopt it for this post.
In my last post, I discussed the idea of how a border (or, better, a shoreline) has
a kind of fractal structure. It's jagged, and the jags themselves have jagged edges, and *those* jags have jagged edges, and so on. Today, I'm going to show a bit of how to
generate curve fractals with that kind of structure.
The canonical example of a fractal curve is the Koch curve. To generate the canonical Koch curve,
you take a line segment, divide it into three sections, and replace the middle with
the upper two edges of an equilateral triangle. Then you repeat that process for each of
the straight edges in the resulting figure. Over to the side are illustrations of the Koch
curve after 1, 2, 3, and 4 iterations.
This kind of curve obviously isn't ideal as a model of something like a coastline. It's perfectly regular, which natural structures like coastlines aren't. But it's a starting point; we can eventually work irregularity and randomness into these kinds of curves. But
for now, we'll stick with the simple ones.
The Koch curve can be described in terms of a simple grammar, which guides
a recursive rewrite system. (In fact, that's how I implemented the code to generate
the diagrams for this post: I've got a simple rewrite system, and I'm feeding the
results into a turtle drawing program which traces out the curve.)
In a rewrite system for fractal curves, you start with a grammar symbol called
the initiator, and then specify a rule system called the generator. The generator is a set of replacement rules. Each iteration of the algorithm, you scan through the current state of the curve (starting with the initiator on step 0), and
each time that you encounter a symbol which is the left hand side of a rule in the generator, you replace that symbol with the right hand side of the corresponding rule.
For example, the Koch curve is specified by:
- Initiator: line
- Generator: line → line,left(60),line,right(120),line,left(60),line
You can also draw the generator graphically, as the following:
Playing with the rewrite method, you can get some really interesting curves, which
often seem as if they defy the simplicity of their definition. For example,
take the same initiator as the koch curve, but instead of using a triangle, generate
a square: line → line,left(90),line,right(90),line,right(90),line,left(90),line;
visually, the replacement for a line is the segment on the right. Now look at what
you get after 4 and 5 iterations:
Now, did anyone out there actually expect that trivial generator to produce
an intricate cross-lace pattern?
That last one is cheating a bit, because the curve crosses itself; proper curve fractals don't do that. But it's cool anyway, so I wanted to show it to you. Even staying
within the non-crossing curves, there are numerous variations on the Koch curve that
For example, look at this generator: "line→line,left(30),line,right(90),line,left(90),line,right(30),line", shown graphically to the left. Run it for 4 iterations, and you get a curve like below. Now, that's starting to look rather a lot like a coastline, isn't it? It's still
completely regular, but it's really starting to look quite different, and interestingly
Throw in a little bit of randomness, and the regularity starts to fade out, even though the generation process remains regular. You get bays and inlets, promontories, etc., all of
the features of a real shoreline. The following two graphs are samples from the same generator as above, but randomly varying the length of the straight lines when a segment
is replaced. The segments that replace the straight are always shorter than the segment they replace, but the ratio of segment length to replacement length is randomized.