GithubHelp home page GithubHelp logo

praneetmehta / lindenmayer-systems Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 1.12 MB

A Lindenmayer system implementation written in C++ using opengl

Home Page: https://praneetmehta.github.io/Lindenmayer-Systems/

C++ 60.96% HTML 39.04%
computer-graphics opengl lindenmayer-systems fractal-geometry fractal-tree fractal-algorithms recursion

lindenmayer-systems's Introduction

Lindenmayer-Systems

A Lindenmayer system implementation written in C++ using opengl

Abstract

The recursive nature of the L-system rules leads to self-similarity and thereby, fractal-like forms are easy to describe with an L-system. Plant models and natural-looking organic forms are easy to define, as by increasing the recursion level the form slowly 'grows' and becomes more complex. Lindenmayer systems are also popular in the generation of artificial life. The rules of the L-system grammar are applied iteratively starting from the initial state. As many rules as possible are applied simultaneously, per iteration. The fact that each iteration employs as many rules as possible differentiates an L-system from a formal language generated by a formal grammar, which applies only one rule per iteration. If the production rules were to be applied only one at a time, one would quite simply generate a language, rather than an L-system. Thus, L-systems are strict subsets of languages.

variables : A B
constants : none
axiom  : A
rules  : (A → AB), (B → A)
which produces:

n = 0 : A
n = 1 : AB
n = 2 : ABA
n = 3 : ABAAB
n = 4 : ABAABABA
n = 5 : ABAABABAABAAB
n = 6 : ABAABABAABAABABAABABA
n = 7 : ABAABABAABAABABAABABAABAABABAABAAB

Approach and Implentation

We followed two different approaches for constructing L-system based graphics.

1. Growth at all characters in the rule

Similar to the above example, each vaariable is recursively grown in each generation as per the given rule.

variables : A
constants : B
axiom  : A
rules  : (A → A[BA]A), (B → B)

which produces:

n = 0 : A
n = 1 : A[BA]A
n = 2 : A[BA][BA[BA]]A[BA]A
n = 3 : A[BA][BA[BA]][BA[BA][BA[BA]]]A[BA]A[BA[BA]A]A[BA]A

2. Branch only Growth

Only the variables inside a subbranch are grown further. Variables in the main branch are not grown

variables : A
constants : B
axiom  : A
rules  : (A → A[BA]A), (B → B)

which produces:

n = 0 : A
n = 1 : A[BA]A
n = 2 : A[BA[BA]]A
n = 3 : A[BA[BA][BA[BA]]]A

lindenmayer-systems's People

Contributors

praneetmehta avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.