340 likes | 365 Views
How to Draw a Tree. L-Systems in Computer Graphics. Steven Janke. Natural Trees. Tree Shapes. Euclidean Geometry Approach. Self-Similarity of Organic Forms. Computation = Processing Strings. Input:. Output:. aababccacabb. adfeeefg. Computer. Interpretation:.
E N D
How to Draw a Tree L-Systems in Computer Graphics Steven Janke
Computation = Processing Strings Input: Output: aababccacabb adfeeefg Computer Interpretation: 00110010 00101011 00110011 00110101 2 + 3 5
L-System (Named after biologist Astrid Lindemayer in 1970’s) • Alphabet of characters. • First string called the axiom. • Set of productions showing how to replace characters. • All appropriate productions applied at once. Example: Alphabet: {a, b} Axiom: ab Productions: a bab , b a Derivation: ab baba abababab
Languages: L(G) = set of strings that can be derived from the system G. Example 1: Axiom: ab Productions: a a b ab ab aab aaab aaaab L(G) = { anb | n > 0 } Example 2: Axiom: a Productions: a b b ab a b ab bab abbab bababbab L(G) = ?
Languages: L(G) = set of strings that can be derived from the system G. Example 1: Axiom: ab Productions: a a b ab ab aab aaab aaaab L(G) = { anb | n > 0 } Example 2: Axiom: a Productions: a b b ab a b ab bab abbab bababbab L(G) = { s | s0 = a, s1 = b, sn = sn-2 sn-1 }
Simple L-System: Alphabet: { F, +, - } Axiom: F-F-F-F Production: F FF Turtle Interpretation: F means draw a line segment in current direction. + means turn left. - means turn right. Start Initial direction F-F-F-F means: Delta = 90 degrees
Branching L-Systems: Add two characters to alphabet: [ and ] Interpret [ to mean “start branch”. Interpret ] to mean “end branch”. F[+F][-F] means: Initial Direction Start Delta = 45 degrees
Turtles in 3D: Left Head Up + = left turn - = right turn & = pitch down ^ = pitch up / = roll right \ = roll left
Growth Functions: F(k) = length of the kth word in the derivation sequence. Example: a aa Axiom: a F(k) = 2k a abcc b bcc c c Axiom: a a abcc abccbcccc abccbccccbcccccc 1 4 9 16 F(k) = k2 F(
Growth Functions: G: a b b ab Axiom: b ak = number of a’s at iteration k. bk = number of b’s at iteration k. 0 1 1 1 ak bk ak+1 bk+1 = Theorem: Every growth function for an L-system is a linear combination of terms that are polynomials times exponential functions. Problem: Plants usually grow according to a logistic (or sigmoidal) function.
Parametric L-Systems: Axiom: A(3) A(x) : x<5 B(x+1)A(x*r) B(y) : * F(y)[+F(y/2)][-F(y/2)] Interpretation: F(x) means draw a segment of length x. +(x) means turn left x degrees.
Context Sensitive L-Systems Axiom: SFFFFA Production: SF FS SA B SFFFFA FSFFFA FFSFFA FFFSFA FFFFSA FFFFB Axiom: S[FA][FFA] S[FA][FFA] [FSA][FSFA] [FB][FFSA] [FB][FFB]
L-System Extensions: • Gravity - pull on branches. • Phyllotaxis - angle and position of branches. • Phototropism - towards the light. • Self-Organizing - branch into free spaces. Implementation: At each iteration, interpret the string and then decide based on the geometry and environment how to apply productions for the next iteration.
Colonization Algorithm: (Runions, Lane, and Prusinkiewicz 2007)
Equivalence: G1: a bb b a Axiom: b b a bb aa bbbb G2: a b b aa Axiom: a a b aa bb aaaa L(G1) = L(G2) Is there an algorithm for determining if two L-Systems are equivalent?
Connection between Languages and Machines Recursively Enumerable Context Sensitive Context Free Regular L-Systems