Skip to content

carlosramos1/L-System-p5js

Repository files navigation

L-systems

In 1968, Hungarian botanist Aristid Lindenmayer developed a grammar-based system to model the growth patterns of plants.

This technique can be used to generate the recursive fractal patterns.

Components

An L-system has three main components:

  • Alphabet: An L-system’s alphabet comprises the valid characters that can be included.
  • Axiom: The axiom is a sentence (created with characters from the alphabet) that describes the initial state of the system.
  • Rules: The production rules of an L-system describe ways of transforming the sentence. Consta de un predecesor y sucesor.

Generations

El proceso de aplicar las reglas sucesivamente se denomina Generación.

  • La Generación-0 es el mismo axioma.
  • Las subsiguientes Generaciones resultan de aplicar las reglas a la generación anterior.

Por ejemplo, consideremos:

Alphabet    A, B
Axiom       A
Rules       A → AB
            B → A

Generation	Sentence
G-0     	A
G-1     	AB
G-2     	ABA
G-3     	ABAAB
...

Turtle graphics

How Lindenmayer was able to translate strings of characters into the organic structures of plants.

Consideremos el alfabeto: F, G, +, –, [ and ] donde,

  • F Draw a line and move forward.
  • G Move forward (without drawing a line).
  • + Turn right.
  • Turn left.
  • [ Save current state.
  • ] Restore current state.

Nota: El ángulo de giro es arbitrario.

This type of drawing framework is often referred to as turtle graphics.

Generating a branched structure

Ejemplo:

Alphabet    F, G, +, –, [, ]
Axiom       F
Rules       F → FF+[+F–F–F]–[–F+F+F]

Aplicando 4 generaciones y angulo 22.5º, resulta:

example-lsystem

Mas figuras:

more example

more example

Reemplazar los datos en el código fuente para reproducir las figuras:

  • $n$ indica el número de generaciones a iterar.
  • $\delta$ indica el angulo en grados.

References

Developer

About

Implementación de L-System, una técnica usada para generar fractales basado en generación de gramática. Referencia: https://natureofcode.com/fractals/#l-systems.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published