Skip to content

Implementation of the L-systems in The Algorithmic Beauty of Plants

License

Notifications You must be signed in to change notification settings

ranrandy/L-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

L-system

The plants images/geometry (no mesh) are generated using L-systems from [1]. For simplicity, we do not consider the stochastic and context sensitive L-systems. We do not generate high-resolution flowers, leaves, and so on, but only generate trees.

1. Definition

  • $V$, alphabet

  • $w\in V^+$, axiom

  • ${p_1, p_2, ...}$, where $p_i=(a, \chi)\in(V, V^*)$, A set of production rules

  • $n$, #iterations

    From my understanding, the L-system is very similar to the Context Free Grammar (CFG), where we have

    • $V$, alphabet -> all non-terminals
    • $w\in V$, a start symbol -> non-terminal
    • ${p_1, p_2, ...}$, where $p_i=(a, \chi)\in(V, V^*)$, A set of production rules
      • To align with the definition of L-system, I finetuned the definition by removing the terminals, but make the right side of the production rule to be $V^*$ instead of $V^+$

    except that, in the L-system

    • The axiom can have multiple symbols
    • In each iteration, we must replace all the symbols using all the productions at the same time.
      • The L-system is parallel, thus representing the growth.
      • The Context Free Grammar is linear, which makes it more flexible

2. Turtle Symbol and Configuration Interpretations:

  • General

    • $l$, step size
    • $F$ (and $F_l, F_r$), move towards $H$ for a distance of $l$
    • $f$, move towards $H$ for a distance of $l$ without drawing a line
    • $[$, start branching, push current node to stack
    • $]$, end branching, pop last node from stack
    • {, start outlining a leaf
    • }, end outlining a leaf
    • $'$, increase the current index of color
    • $A, B, C, ...$, do nothing
  • 2-Dimension

    • $H=(H_x, H_y)$, turtle heading direction
    • $P=(P_x, P_y)$, turtle 2D position
    • $\delta=\alpha$:
      • $+$, turn $H$ towards left for $\alpha$ degree
      • $-$, ... right ...
    • Sample 2D non-parametric trees outputs

      Parameters refer to Figure 1.24 in Sec 1.6.3 Bracketed OL-systems (p.25) in [1].
l_system_tree_2d_Figure_1_24_a

(a)

l_system_tree_2d_Figure_1_24_b

(b)

l_system_tree_2d_Figure_1_24_c

(c)

l_system_tree_2d_Figure_1_24_d

(d)

l_system_tree_2d_Figure_1_24_e

(e)

l_system_tree_2d_Figure_1_24_f

(f)

  • 3-Dimension

    • $H=(H_x, H_y, H_z)$, turtle heading direction
    • $L=(L_x, L_y, L_z)$, turtle left direction
    • $U=(U_x, U_y, U_z)$, turtle up direction
    • $P=(P_x, P_y, P_z)$, turtle 3D position
    • $\delta=\alpha$: (right-hand rule)
      • $+$, rotate around $U$ towards left for $\alpha$ degree
      • $-$, ... right ...
      • &