Disclaimer

This post will assume you already know the basics of L-Systems. If you don’t I invit you to read my first post on that subject.

Introduction

Some weeks ago for school project I had to do some researches on the subject of my choice and I finished to examinate more in detail L-Systems. This is a presentation of this work. There were two distinct parts in this work, the research and the developement. The research part was learning and exploring how L-Systems works and how we can use them for various tasks. And the developement part was implement an Unity plugin that can generate meshes thanks to L-Systems.

Making a simple L-System

When I started this project I already known a little about L-Systems so, in this project the first step was implementing a basic L-System in unity (I already worked on a prototype before that using Dlang and SDL but since I was using unity I had to reimplement it in C#).

So I started with the initial system, a list of productions rules and an interpreter that draw gizmos with the path generated by the system.

So my first instructions were:

F : forward n following the current direction
f : forward n following the current direction without drawing lines
[ : save current state
] : restore last saved state
+ : rotate k degree aroud y axis
- : rotate -k degree aroud y axis
^ : rotate k degree aroud x axis
& : rotate -k degree aroud x axis
/ : rotate k degree aroud z axis
\ : rotate -k degree aroud z axis
| : rotate 180 degree aroud y axis

so after implementing that I was able to draw some things like this :

3D LSystem

Stochastic L-Systems

In The algorithmic beauty of plants Aristid Lindenmayer and Przemslaw Prusinkiewicz described a way to create non deterministic L-Systems by adding multiples possibles productions to an Axiom with each production a percentage of chance to occur. With this technique we can easly add some randomness to our generated figures and remove determinism.

Context Sensitive L-Systems

In The algorithmic beauty of plants context sensitive are described as a production rule that occur only if a context condition is met. For exmaple consider the following system:

ω = AFF
p1: A < F -> FX
n = 0 : AFF
n = 1 : AFXF

Here only the production rule p1 precise that F must be replaced only if an A is on the left of F in the last production so in this case only the first F meet this condition so only the first F will be replaced by it’s production.
On top of that rules can also describe a list of axiom that are ignored when checking for the context conditions.

Parametric L-Systems

Here is the hard (to implement) part, a parametric L-System associate parameters with axioms. So a production rule in a parametric L-System looks like that:

A(t) -> B(t+1)CD(t, t-2)

Where t is the parameter of the axiom A. Then parameters can be used by the interpreter in order to have more freedom when writing a L-System. So let’s describe the new parameters of the interpreters:

F(x) : forward x following the current direction
^(x) : rotate x degree aroud x axis
… and so on with other instructions axioms.
So the big difference here is that all rotation and forward instructions may not all have the same length / angle, this allow us to generate new things impossible (or very hard) to do with the older system.

Going further

In this small project I only implemented / studied a small part of L-Systems, there is a lot more to discover and to do. Yet we didn’t see nodes and edges rewritting, environment influence, inflorescence, …
If you want to learn more about L-Systems, I highly recommend The algorithmic beauty of plants by Aristid Lindenmayer and Przemslaw Prusinkiewicz, this is the best and most complete reference about L-Systems. I also recommend the research paper Evolving Lindenmayer systems in a competitive environment by Job J.V. Talle, which is an intersting work on top of The algorithmic beauty of plants.