Function Repository Resource:

# LSystem

Generate an L-system

Contributed by: Renan Soares Germano
 ResourceFunction["LSystem"][rules,init,t,θ] returns an Association containing the word and the branches generated after executing the L-system represented by rules from initial word init for t steps, with movement specified by the angle θ.

## Details and Options

L-system is also known as a Lindenmayer system.
θ is taken to be in degrees.
The following special symbols, when present in rules, represent the following instructions:
 + increase the current angle by θ - decrease the current angle by θ [ start a new branch ] close the current branch
ResourceFunction["LSystem"] takes the following options:
 "InitialAngle" 90 initial angle in degrees from which the next points will be generated "InitialPoint" {0,0} intial point from which the next points will be generated "MoveLength" 1 distance of a new point from the previous one
Any other symbol will be interpreted as an instruction to move forward.
In an L-system with brackets, every left bracket "[" must be paired with a right bracket "]" in the rules and the initial word.

## Examples

### Basic Examples (4)

Run a simple L-system for one iteration:

 In[1]:=
 Out[1]=

Because this L-system doesn't use brackets, it contains only one branch:

 In[2]:=
 Out[2]=

Run a simple L-system with brackets for one iteration:

 In[3]:=
 Out[3]=

Because this L-system uses brackets, it contains multiple branches:

 In[4]:=
 Out[4]=

Show a fractal:

 In[5]:=
 Out[5]=

Show a tree:

 In[6]:=
 Out[6]=

### Scope (2)

Display a variety of fractals:

 In[7]:=
 Out[7]=

Plot different trees:

 In[8]:=
 Out[8]=

### Options (3)

#### InitialAngle (1)

Show the effect of changing the initial angle:

 In[9]:=
 Out[9]=
 In[10]:=
 Out[10]=

#### InitialPoint (1)

Show the effect of changing the initial point:

 In[11]:=
 Out[11]=
 In[12]:=
 Out[12]=

#### MoveLength (1)

Show the effect of using different values for "MoveLength":

 In[13]:=
 Out[13]=

### Applications (6)

Show the step-by-step creation of the dragon curve:

 In[14]:=
 In[15]:=
 Out[15]=

Show the step-by-step creation of the Peano curve:

 In[16]:=
 In[17]:=
 Out[17]=

Create a colorful tree:

 In[18]:=
 Out[18]=

Create a tree with green leaves:

 In[19]:=
 Out[19]=

Create a colorful plant with leaves:

 In[20]:=
 Out[20]=

Create a colorful tree with grapes:

 In[21]:=
 Out[21]=

### Possible Issues (1)

The execution time tends to grow very fast according to the number of iterations:

 In[22]:=
 Out[22]=
 In[23]:=
 Out[23]=

### Neat Examples (2)

An animated orange tree:

 In[24]:=
 In[25]:=
 In[26]:=
 Out[26]=

Generate a snowflake:

 In[27]:=
 Out[27]=

## Publisher

Wolfram Summer School

## Version History

• 1.0.0 – 21 June 2021