Download presentation
Presentation is loading. Please wait.
Published byLewis O’Connor’ Modified over 9 years ago
1
Dragon Curve Drawn in Project 4… How to generate the string of drawing commands? How does the dragon curve come about? 1
2
Startup: 1 fold 2 R
3
2 nd Fold 3 R R R L
4
3 rd Fold 4 R R R L R R L R R L L
5
4 th Fold 5 R R R L R R L R R L L RRL R RLL R RRL L RLL
6
Patterns 6 R R R L R R L R R L L RRL R RLL R RRL L RLL R R R L L R L L
7
Patterns 7 R R R L R R L R R L L RRL R RLL R RRL L RLL R R R L L R L L R R R L R R L R R L L RRL R RLL R RRL L RLL
8
Patterns 8 R R R L R R L R R L L RRL R RLL R RRL L RLL R R R L L R L L R R R L R R L R R L L RRL R RLL R RRL L RLL T(f+1,R) = T(f,R)+R+T(f,L) T(f+1,L) = T(f,R)+L+T(f,L) T(1,R) = R T(1,L) = L
9
Resulting Code def dragon(fold, root): if fold == 1: return root return dragon(fold-1,'R')+root+dragon(fold-1,'L') 9 T(f+1,'R') = T(f,'R')+'R'+T(f,'L') T(f+1,'L') = T(f,'R')+'L'+T(f,'L')
10
RL → NSEW Done to simplify project 4 Conversion: Head north by one length Then execute the turn instructions writing the resulting heading Example: RRL 1. N 2. E 3. S 4. E So the result is NESE 10
11
Lindenmayer Systems How to model biological tree growth and plant architecture? Our trees are constructed node-by-node, serially Nature’s trees grow in parallel Parallel rewrite systems 11
12
Lindenmayer Systems Textually – the dragon curve does this: R => RRL R => R L => RLL L => L This is a parallel rewriting system 12 RRLRRLL => RRLRRLLRRRLLRLL
13
Simple Rewriting Loop 1. Start with a string w 2. Replace each character c in w with a string s(c) according to the rules stipulated 3. Repeat 13 R => RRL L => RLL R => R L => L R => RRL RRL => RRLRRLL RRLRRLL => RRLRRLLRRRLLRLL
14
Q: String length for n Folds is: 14 R => RRL L => RLL R => R L => L
15
Drawing the string Interpret each character in the string as doing some drawing operation, exactly as in Project 4 For the L-R string of the dragon curve: Make turn, draw a single line (fixed length) 15 R L
16
2 Parts Part 1: string rewriting system defined Need start string w Need substitution rules Part 2: string mapped to a drawing Some characters used to draw simple shape, perhaps a line Some characters used to change direction etc Some characters used to save and restore state (recursively) 16
17
L-Systems Rewrite + drawing rules yield models of biological shapes and growth Some examples from the web that mention Prusinkievicz 17
18
Worked Example Characters: F + - [ ] Initial string: F Rewrite rule: F → F [ - F ] F [ + F ] [ F ] See http://www.biologie.uni-hamburg.de/b- online/e28_3/lsys.htmlhttp://www.biologie.uni-hamburg.de/b- online/e28_3/lsys.html 18
19
Generations 1 and 2 19 F [ - F ] F [ + F ] [ F ] F[-F]F[+F][F][-F[-F]F[+F][F]]F[-F]F[+F][F][+F[-F]F[+F][F]][F[-F]F[+F][F]]
20
How to draw 20
21
How to draw 21 1 2 3 4 5 6 F [ - F ] F [ + F ] [ F ]
22
How to draw 22 1 2 3 4 5 6 F [ - F ] F [ + F ] [ F ]
23
How to draw 23 1 2 3 4 5 6 F [ - F ] F [ + F ] [ F ]
24
How to draw 24 1 2 3 4 5 6 F [ - F ] F [ + F ] [ F ]
25
How to draw 25 1 2 3 4 5 6 F [ - F ] F [ + F ] [ F ]
26
How to draw 26 1 2 3 4 5 6 F [ - F ] F [ + F ] [ F ]
27
How to draw 27 1 2 3 4 5 6 F [ - F ] F [ + F ] [ F ]
28
How to draw 28 1 2 3 4 5 6 F [ - F ] F [ + F ] [ F ]
29
How to draw 29 1 2 3 4 5 6 F [ - F ] F [ + F ] [ F ]
30
How to draw 30 1 2 3 4 5 6 F [ - F ] F [ + F ] [ F ]
31
How to draw 31 1 2 3 4 5 6 F [ - F ] F [ + F ] [ F ]
32
How to draw 32 1 2 3 4 5 6 F [ - F ] F [ + F ] [ F ]
33
Running this System Generations 2 to 5 33
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.