Presentation is loading. Please wait.

Presentation is loading. Please wait.

Simulating Trees with Fractals and L-Systems Eric M. Upchurch CS 579.

Similar presentations


Presentation on theme: "Simulating Trees with Fractals and L-Systems Eric M. Upchurch CS 579."— Presentation transcript:

1 Simulating Trees with Fractals and L-Systems Eric M. Upchurch CS 579

2 Background - Fractals Fractals are recursive, self-similar structures Fractals are recursive, self-similar structures Infinitely detailed – zooming in reveals more detail Infinitely detailed – zooming in reveals more detail Similar, though not necessarily identical, at any level of magnification Similar, though not necessarily identical, at any level of magnification Generated using a variety of methods, such as IFS and L-Systems Generated using a variety of methods, such as IFS and L-Systems Many natural forms display fractal geometry (like trees!) Many natural forms display fractal geometry (like trees!)

3 Background – L-Systems Formal grammar developed by Aristid Lindenmayer as a theoretical framework for studying development of simple multicellular organisms Formal grammar developed by Aristid Lindenmayer as a theoretical framework for studying development of simple multicellular organisms Subsequently applied to investigate higher plants Subsequently applied to investigate higher plants Uses rewriting rules (productions) to grow a string or system Uses rewriting rules (productions) to grow a string or system Productions are applied in parallel (unlike Chomsky grammars) Productions are applied in parallel (unlike Chomsky grammars) This is motivated by biological considerations – this is how living organisms grow This is motivated by biological considerations – this is how living organisms grow

4 Simple L-System Strings built of letters a and b Each letter is associated with a rewriting/production rule: a  ab b  a Rewriting starts from an axiom, a starting string (b in this case) Each production is applied simultaneously in each step

5 L-Systems – Properties Can be context-free or context-sensitive Can be context-free or context-sensitive Different production rules for the same symbol based upon neighboring symbols Different production rules for the same symbol based upon neighboring symbols If run repeatedly and interpreted as images, can produce fractal geometry If run repeatedly and interpreted as images, can produce fractal geometry Can describe many “traditional” fractal patterns, such as Koch curves and constructions Can describe many “traditional” fractal patterns, such as Koch curves and constructions Can describe & produce very complex fractal patterns Can describe & produce very complex fractal patterns

6 Iterated Function Systems An IFS is any system which recursively iterates a function or a collection of arbitrary functions on some base object An IFS is any system which recursively iterates a function or a collection of arbitrary functions on some base object An IFS can be used to generate a fractal pattern An IFS can be used to generate a fractal pattern The IFS fractal is made up of the union of several copies of itself, each copy being transformed by a function The IFS fractal is made up of the union of several copies of itself, each copy being transformed by a function No restriction on transformations, though they are usually affine No restriction on transformations, though they are usually affine Can use deterministic or stochastic processes Can use deterministic or stochastic processes

7 Iterated Function Systems If the system is made up by k functions (or transformations) {f i (x) | 1 < i < k} and iterated n times on the base set b, then the IFS is defined as the set: If the system is made up by k functions (or transformations) {f i (x) | 1 < i < k} and iterated n times on the base set b, then the IFS is defined as the set: { f i1 (f i2 (.. f ik (b).. )) | for all i j, with 1 < i j < k, j = (1, 2,.., k) } { f i1 (f i2 (.. f ik (b).. )) | for all i j, with 1 < i j < k, j = (1, 2,.., k) } In the limit that n becomes infinite, an IFS becomes a fractal. In the limit that n becomes infinite, an IFS becomes a fractal.

8 Relationship of IFS to L-Systems Both are recursive in nature Both are recursive in nature Both can be used to produce fractals Both can be used to produce fractals L-Systems are, arguably, a specialized form of IFS, whose functions are specified by the production rules of the grammar L-Systems are, arguably, a specialized form of IFS, whose functions are specified by the production rules of the grammar Replace the formal grammar of an L-System with functions/transformations, and you have an IFS Replace the formal grammar of an L-System with functions/transformations, and you have an IFS

9 Describing Trees A rooted tree has edges that are directed and labeled A rooted tree has edges that are directed and labeled Edge sequences form paths from a distinguished node, called the root or base, to terminal nodes Edge sequences form paths from a distinguished node, called the root or base, to terminal nodes In biological sense, these edges are branch segments In biological sense, these edges are branch segments A segment followed by at least one more segment in some path is called an internode A terminal segment (with no succeeding edges) is called an apex

10 Axial Trees Special type of rooted tree Special type of rooted tree At each node, at most one outgoing straight segment is distinguished All remaining edges are called lateral or side segments. A sequence of segments is called an axis if: the first segment in the sequence originates at the root of the tree or as a lateral segment at some node each subsequent segment is a straight segment the last segment is not followed by any straight segment in the tree. Together with all its descendants, an axis constitutes a branch. A branch is itself an axial (sub)tree.

11 Axial Trees Axes and branches are ordered The root axis (trunk) has order zero. Axis originating as a lateral segment of an n-order parent axis has order n+1. The order of a branch is equal to the order of its lowest-order or main axis

12 Example Axial Tree

13 Honda’s Model Limited model with following assumptions: Limited model with following assumptions: Tree segments are straight and their girth is not considered A mother segment produces two daughter segments through one branching process Lengths of the two daughter segments are shortened by constant ratios, r 1 and r 2, with respect to the mother segment Mother and daughter segments are contained in the same branch plane. The daughter segments form constant branching angles, a 1 and a 2, with respect to the mother branch Branch plane is fixed with respect to the direction of gravity so as to be closest to a horizontal plane. An exception is made for branches attached to the main trunk, where a constant divergence angle α between consecutively issued lateral segments is maintained

14 Honda’s Geometry

15 Honda’s Trees

16 My Tree Simulator Written in C++, using the DirectDraw API Written in C++, using the DirectDraw API Draws 2D trees by writing to a bitmap Draws 2D trees by writing to a bitmap Does simple lighting and shading Does simple lighting and shading Produces a fair mix of completely ugly trees and good looking/accurate trees Produces a fair mix of completely ugly trees and good looking/accurate trees Uses stochastic IFS transformations, inspired from L-Systems and extends Honda’s work Uses stochastic IFS transformations, inspired from L-Systems and extends Honda’s work Drawing infrastructure borrowed from a Julia Set generator Drawing infrastructure borrowed from a Julia Set generator

17 My Tree Simulator A tree is specified by: A tree is specified by: Radius (thickness of trunk) Radius (thickness of trunk) Height Height Some number of branches, each having: Some number of branches, each having: Scaling factor (all branches are scaled according to order) Scaling factor (all branches are scaled according to order) Height/length of branch Height/length of branch Lean angle (from higher order branch) Lean angle (from higher order branch) Rotation angle (around higher order branch) Rotation angle (around higher order branch) Number of branches is used in recursively creating branches Number of branches is used in recursively creating branches

18 My Tree Simulator IFS is performed by transformations specified in each branch. IFS is performed by transformations specified in each branch. Transformations: scale, lean, rotation, are stochastically determined Transformations: scale, lean, rotation, are stochastically determined Foliage is done using the same method but using different colors to give the illusion of leaves Foliage is done using the same method but using different colors to give the illusion of leaves Z-buffer utilized for determining which pixels are drawn Z-buffer utilized for determining which pixels are drawn

19 My Tree Simulator A tree contains several flags that define which IFS transformations are applied: A tree contains several flags that define which IFS transformations are applied: Use Branch Heights  If true, places branches randomly up trunk. If false, places all branches coming out of trunk (and recursive branches) at same point. Use Branch Heights  If true, places branches randomly up trunk. If false, places all branches coming out of trunk (and recursive branches) at same point. False tends to make trees more irregular. False tends to make trees more irregular. Global Scaling  If true, scales branches and foliage based on a single scale (stored in the trunk branch). Otherwise, scales each branch separately based on a scale stored per branch. Global Scaling  If true, scales branches and foliage based on a single scale (stored in the trunk branch). Otherwise, scales each branch separately based on a scale stored per branch. True makes trees more regular, and “tighter”. True makes trees more regular, and “tighter”. False makes trees more irregular, but can cause “puffiness” False makes trees more irregular, but can cause “puffiness”

20 My Tree Simulator Scale By Height  If true, branches and foliage decrease (more dramatically) as their height increases. Scale By Height  If true, branches and foliage decrease (more dramatically) as their height increases. True keeps some trees from getting too “puffy”. True keeps some trees from getting too “puffy”. False makes trees more top-heavy, fuller, like elms. False makes trees more top-heavy, fuller, like elms. True makes trees slimmer and decreasing, like a willow bush. True makes trees slimmer and decreasing, like a willow bush. True will give a younger looking tree, false will give an older looking tree with the same structure. True will give a younger looking tree, false will give an older looking tree with the same structure.

21 Future Work Convert to 3D Convert to 3D 2D representation is easier, but very limiting 2D representation is easier, but very limiting Allow model exportation for placement into virtual worlds Allow model exportation for placement into virtual worlds Use foliage models in 3D Use foliage models in 3D More realistic effect, scales well, could provide physics-based modeling effects (wind, sway, etc) More realistic effect, scales well, could provide physics-based modeling effects (wind, sway, etc) Enhance parameterization of trees Enhance parameterization of trees Currently, everything is random! Currently, everything is random!


Download ppt "Simulating Trees with Fractals and L-Systems Eric M. Upchurch CS 579."

Similar presentations


Ads by Google