Skip to content

Latest commit

 

History

History
121 lines (77 loc) · 3.42 KB

README.md

File metadata and controls

121 lines (77 loc) · 3.42 KB

L-Systems

L-System or Lindenmayer System is a type of formal grammar. Each L-System consists of a set of alphabets that can be used to make string. L-System provides a production rule for a set of symbols that can be used to make the current string an even larger string. To start the string, it provides an axiom or an initial string which can be later expanded using the production rules. Each step of the string can be treated as a generation where the axiom is part of generation 1. L-Systems can also be used to generate fractals. They were first developed in 1968 by Aristid Lindenmayer.

L-Systems can be used to generate many different patterns. By using the string and the alphabets as rules, a huge possibility of doors open. As the generations go on increasing, L-System allows to have more detail in each generation.

We can define each alphabet with a given rule, let’s see the different rules:

  • F or G := Draw forward.
  • A or B := Move forward.
  • + := Turn left by angle.
  • - := Turn right by angle.
  • [ := Push position.
  • ] := Pop position.

Try it out here!

Examples Of L-System

Arrow Weed

  • Angle: 22.5°
  • Axiom: X
  • Rules: (F→FF),(X→F[+X][-X]FX)

Arrow Weed

Binary Tree

  • Angle: 45°
  • Axiom: X
  • Rules: (F→FF),(X→F[-X]+X)

Binary Tree

Fuzzy Weed

  • Angle: 25°
  • Axiom: X
  • Rules: (F→FF),(X→F+[[X]-X]-F[-FX]+X)

Fuzzy Weed

Twiggy Weed

  • Angle: 25°
  • Axiom: X
  • Rules: (F→FF),(X→F[-X]F[-X]+X)

Twiggy Weed

Tall Seaweed

  • Angle: 25°
  • Axiom: F
  • Rules: (F→F[+F]F[-F]F)

Tall Seaweed

Sierpinski Triangle

  • Angle: -120°
  • Axiom: F-G-G
  • Rules: (F→F-G+F+G-F),(G→GG)

Sierpinski Triangle

Dragon Curve

  • Angle: 90°
  • Axiom: FX
  • Rules: (X→X+YF+),(Y→-FX-Y)

Dragon Curve

Koch Curve

  • Angle: 90°
  • Axiom: F
  • Rules: (F→F+F-F-F+F)

Koch Curve

Koch Snowflake

  • Angle: 60°
  • Axiom: F++F++F
  • Rules: (F→F-F++F-F)

Koch Snowflake

Gosper Curve

  • Angle: 60°
  • Axiom: F
  • Rules: (F→F-G--G+F++FF+G-),(G→+F-GG--G-F++F+G)

Gosper Curve

Hilbert Curve

  • Angle: -90°
  • Axiom: X
  • Rules: (X→-YF+XFX+FY-),(Y→+XF-YFY-FX+)

Hilbert Curve

Moore Curve

  • Angle: 90°
  • Axiom: LFL+F+LFL
  • Rules: (L→-RF+LFL+FR-),(R→+LF-RFR-FL+)

Moore Curve

Lévy C Curve

  • Angle: 45°
  • Axiom: F
  • Rules: (F→+F--F+)

Lévy C Curve