# The Beauty of Fractals – L-system in Houdini

## The Beauty of Fractals - L-system in Houdini

#### What are fractals?

The term fractal is derived from the Latin words fractus, frangere and means broken/break up/shatter/crush. Fractals are described as a mathematical set which holds the following characteristics, defined originally by Benoît Mandelbrot in 1975:
self-similarity
“When each piece of a shape is geometrically similar to the whole, both the shape and the cascade that generate it are called self-similar.” (Mandelbrot, in Prusinkiewicz and Lindenmayer 2004, p. v)
underivabiliy at any point; no gradient allocatable
and/or
fractal dimension; an object possesses fractal dimension if its Hausdorff-Besicovitch dimension is greater than its topological dimension. Fractals do therefore usually neither belong to 0 (points), 1 (lines), 2 (surfaces) nor 3 (volumes) dimensional objects. The dimension of a point set in finite space, defined by a simplified explanation of the Hausdorff-Besicovitch Dimension, can be described with the help of the amount of N boxes with linear size p (for lim p → 0) necessary to cover the point set. D (for dimension) holds the following relation: and for R tending to 0: Therefore the Koch snowflake would have a dimension of 1.261859… while “space-filling” fractal curves such as the Hilbert (Fig. 01c) curve possess a dimension of 2 but still meet the characteristic of self-similarity and underivability. Since fractals are underivable at any point and/or feature fractal dimension they can be infinitely magnified and would never consist of straight lines (like e.g. a circle) but due to recursion of always a self-similar pattern.

#### Types

Different kinds of fractals (generated or represented by different means) such as

fractional Brownian motion (random movement of particles in liquid or gas, due as interaction to fast-moving atoms/molecules); can be used to create fractal surfaces (such as mountains), Fig. 02a)

recursive mathematical families of equations (Mandelbrot set, Julia set; Mandelbrot: sampling complex numbers), Fig. 02b).

recursive transformations (generator) applied to an initial shape (initiator) e.g. Koch snowflake, Sierpinski carpet, Sierpinski triangle, dragon curve, etc. (Fig. 01)

#### What are L-Systems?

Aristid Lindenmayer introduced the so called Lindenmayer-systems (or L-systems) in 1968, conceptualised as a mathematical algorithm to simulate plant development/biological growth. The central concept of L-system is rewriting which means to “recursively replacing an initial state (the initiator/premise) with rewritten geometry (the generator/rule)” (Side Effects Documentation 2012). The rules are applied simultaneously (parallel-derivation grammar) in contrast to the well known Chomsky grammar, which applies sequential, one rule per step. Left: initiator/premise (0), generator/rule (1), generations 2-4 of the Koch curve (angle 60°)

#### Types • context-free L-systems:

• • d0L systems (deterministic context-free (0-context) L-system; simplest form of L-system; appropriate to describe fractals) (see right)
• • bracketed systems (extension of d0l-system for creating branches)
• • stochastic systems (to add divergence using probabilities; for modeling more realistic and randomised and less uniform structures)
• • parametric systems (using conditions which determines whether or not a rule will be applied to the consisting string/premise)

• context sensitive systems (the context affects the applicability and outcome of a the application of a rule; useful to simulate interactions between different parts of a plant).

#### Basic Formalism

Basic commands of the turtle graphics routine which is used to interpret the strings created with Houdini’s l-system.

Turtle: moving and drawing:

F(l) Move forward a step of length l, draw a line between the original and new position H(l) Move forward half a step of length l, draw a line between the original and new position f(l) Move forward a step of length l withouth drawing a line h(l) Move forward half a step of length l without drawing a line

Orientation of the turtle in space:

+(α) Turn right by angle α

– (α) Turn left by angle α

& (α) Pitch up by angle α

^(α) Pitch down by angle α

\ (α) Roll clockwise by angle α

/ (α) Roll counter-clockwise by angle α

| Turn by 180 degrees * Roll by 180 degrees

#### Implementation

L-systems are highly appropriate to create fractals, as they are recursively replacing the existing ge-ometry with the production rules from generation to generation. However with respect to Mandel-brot’s definition of fractals (including fractal dimension), L-systems can not implement fractals, since the output of L-systems always consist of a finite number of primitives (lines or polygons), Fig. 06. If the term fractal is used in a broader sense it could be said that an advanced Koch snowflake “as being closer to a curve of dimension log 4/log 3 than to a curve of dimension 1. Thus, a finite curve can be considered an approximate rendering of an infinite fractal as long as the interesting properties of both are closely related” (Lindenmayer 2004, p.176). Finiteness of Houdini l-system, Koch-snowflakes (zoom from left to right), 7 generations;

#### Scaling

L-systems do not adjust their step size as the production rules are applied. Each single part of the geometry possesses therefore scale 1 what let the whole object grow with each generation. Without limiting, the scaling in Houdini fractals would grow exponentially; e.g. the Koch snowflake would grow 3 each generation (n):

Generation n = 0: Scale s = 1 | n = 1: s = 3 | n = 2: s = 9 | n = 3: s = 27 | n = 4: s = 81

In order to preserve the scale of a fractal, no matter which generation it is in, the following command is to add:

premise: F(1)

rule: F(i)=F(i • scaling factor)

#### Application

• using d0L-systems (deterministic context-free L-systems) to create fractals

• simple, symmetric fractals; starting with a closed form (axiom), e.g. triangle, quad, pentagon and rewrite the segments with a single rule, two rules, and/or different angles in axiom and rules

• in order to keep the closed form of the fractal it is important that the rule is angle-invariant: that the direction of the “turtle” at the beginning and the end of a production rule has to be the same.

AID0L (angle-invariant deterministic context-free L-system)

##### Conclusion

The main achievement of this research is the successful implementation of closed fractals, using different rules and angles, into Houdini L-systems. Fractals are by definition infinitely self-similar what makes them differ from the fractals implemented in L-systems. However, they are classified as being closer to a fractal as to a straight line or plane.
The most important aspect to successfully create closed fractals is a closed form as premise and an angle-invariant rule.

##### Examples

Zoom into curve detail | Finiteness of Houdini L-System Initiator/premise (F-F-F-F-F-F-F-F), generator/rule (F=F- – -F+F+F+F+F+F+F- – -F), generation 2; Angle:45

Zoom into curve detail | Finiteness of Houdini L-System Initiator/premise (F++F++F), generator/rule (F=F+F- -F+F), generation 2; Angle: 60

1)

 Generation: 7 Angle: 60 Premise: F++F++F Rule 1: F=F+F- -F+F

2)

 Generation: 5 Angle: 40 Premise: F+F+F+F+F+F+F+F+F Rule 1: F=F- – -F+F+F+F+F+F+F- – -F

3)

 Generation: 5 Angle: 45 Premise: F+F+F+F+F+F+F+F Rule 1: F=F- – -F+F+F+F+F+F+F- – -F

4)

 Generation: 6 Angle: 60 Premise: F+F+F+F+F+F Rule 1: F=F++F-F-F-F-F++F

5)

 Generation: 6 Angle: 60 Premise: F+F+F+F+F+F Rule 1: F=F-F+F+F+F-F

6)

 Generation: 6 Angle: 72 Premise: F+F+F+F+F Rule 1: F=F-F+F+F+F- -F

7)

 Generation: 6 Angle: 60 Premise: F++F++F Rule 1: F=F-(90)F+(90)F+(90)F-(90)F

8)

 Generation: 6 Angle: 90 Premise: F+F+F+F Rule 1: F=A-(60)A+(120)A-(60)A Rule 2: A=F-F+F+F-F

9)

 Generation: 6 Angle: 60 Premise: F- -F- -F Rule 1: F=A+(-80)A+(45)A+A-(68)A+(45)A+(50)A+(45)A-(97)A Rule 2: A=F-F++F-F Hi, I'm Anni. I'm a VFX Artist. 3D lover. Multimedia Producer. Travel enthusiast. Nature lover. DIY fan. Music devotee. And much more.

Find out more