-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlindenmayer.html
475 lines (409 loc) · 14.2 KB
/
lindenmayer.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Lindenmayer Systems</title>
<meta name="author" content="(Alasdair McAndrew (export-snippet (:back-end html :value <br><br> :begin 18 :end 35 :post-blank 0 :parent #0)) College of Engineering and Science (export-snippet (:back-end html :value <br> :begin 69 :end 82 :post-blank 0 :parent #0)) Victoria University, (export-snippet (:back-end html :value <br> :begin 102 :end 115 :post-blank 0 :parent #0)) Melbourne, Australia)"/>
<style type="text/css">
.underline { text-decoration: underline; }
</style>
<link rel="stylesheet" href="./css/reveal.css"/>
<link rel="stylesheet" href="./css/theme/melbourne.css" id="theme"/>
<link rel="stylesheet" href="file:///home/amca/Nextcloud/reveal.js/lib/styles/gruvbox-dark.css"/>
<!-- If the query includes 'print-pdf', include the PDF print sheet -->
<script>
if( window.location.search.match( /print-pdf/gi ) ) {
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = './css/print/pdf.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
}
</script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<meta name="description" content="Org-Reveal Introduction.">
</head>
<body>
<div class="reveal">
<div class="slides">
<section id="sec-title-slide"><h1 class="title">Lindenmayer Systems</h1><h2 class="author">Alasdair McAndrew<br><br>College of Engineering and Science<br>Victoria University,<br>Melbourne, Australia</h2><h2 class="date">December, 2017</h2>
</section>
<section>
<section id="slide-orge893e58">
<h2 id="orge893e58">What is a Lindenmayer system?</h2>
<ul>
<li class="fragment highlight-current-blue">Designed to explore organic growth</li>
<li class="fragment highlight-current-blue">Creates complex shapes from simple rules</li>
<li class="fragment highlight-current-blue">For example, with the rules:
\[
\Rule{0em}{3ex}{1.3ex}\color{blue}{0\rightarrow 1},\qquad\color{red}{1\rightarrow 01}
\]
we have this string transformation:
\[
\Rule{0em}{2.7ex}{1ex}01101=\color{blue}{0}\;\color{red}{1\;1}\;\color{blue}{0}\;\color{red}{1}
\longrightarrow\color{blue}{1}\;\color{red}{01\;01}\;\color{blue}{1}\;\color{red}{01}=10101101
\]</li>
<li class="fragment highlight-current-blue">All operations take place <i>simultaneously</i></li>
<li class="fragment highlight-current-blue">L-systems are <i>term-rewriting systems</i></li>
</ul>
<div class="slide-footer">Lindenmayer Systems: Alasdair McAndrew, ATCM2017</div>
</section>
</section>
<section>
<section id="slide-org83ec95b">
<h2 id="org83ec95b">Fractals: real…</h2>
<div class="figure">
<p><img src="./Images/trees2.jpg" alt="trees2.jpg" width="1200" />
</p>
</div>
<p>
All these lovely fractal trees in the city of Melbourne, Australia, in the winter.
</p>
<div class="slide-footer">Lindenmayer Systems: Alasdair McAndrew, ATCM2017</div>
</section>
</section>
<section>
<section id="slide-org1bd3bd1">
<h2 id="org1bd3bd1">Fractals are everywhere</h2>
<p>
Once you start looking, you can't stop seeing them
</p>
<div class="figure">
<p><img src="./Images/out1.jpg" alt="out1.jpg" />
</p>
</div>
</section>
<section >
<div class="figure">
<p><img src="./Images/out2.jpg" alt="out2.jpg" />
</p>
</div>
<div class="slide-footer">Lindenmayer Systems: Alasdair McAndrew, ATCM2017</div>
</section>
</section>
<section>
<section id="slide-orgaaa6cb8">
<h2 id="orgaaa6cb8">Fractals: manufactured…</h2>
<div class="figure">
<p><img src="./Images/agop.jpg" alt="agop.jpg" width="1200" />
</p>
</div>
<p>
These are all examples from <i>The Algorithmic Beauty of Plants</i> by
Aristid Lindenmayer and Przemysław Prusinkiewicz, available at
<a href="http://algorithmicbotany.org/papers/abop/abop.pdf">http://algorithmicbotany.org/papers/abop/abop.pdf</a>
</p>
<div class="slide-footer">Lindenmayer Systems: Alasdair McAndrew, ATCM2017</div>
</section>
</section>
<section>
<section id="slide-org1123b57">
<h2 id="org1123b57">Turning strings of symbols into pictures</h2>
<ul>
<li>Sets of rules describe how one string of symbols will be expanded to a new string</li>
<li>Each symbol corresponds to a <i>turtle graphics</i> instruction:
<ul>
<li><code>F</code>: Move forward</li>
<li><code>-</code>: Turn left</li>
<li><code>+</code>: Turn right</li>
<li><code>[</code>: Memorize current position and heading</li>
<li><code>]</code>: Move to most recently memorized position and heading</li>
</ul></li>
</ul>
<div class="slide-footer">Lindenmayer Systems: Alasdair McAndrew, ATCM2017</div>
</section>
</section>
<section>
<section id="slide-org928360d">
<h2 id="org928360d">An example</h2>
<div class="column" style="float:left; width:50%">
<p>
For example, this sequence of symbols:
<br><br>
</p>
<p>
<code>F[+F]F[-F]F</code>
</p>
<p>
<br>
has this output:
<br><br>
</p>
<p>
We can clearly alter the output by changing the angle of the turns,
and the length of the move forward.
</p>
<p>
In this example, the angle is 26°
</p>
</div>
<div class="column" style="float:right; width:50%">
<div class="figure">
<p><img src="./Images/l_tree1.jpg" alt="l_tree1.jpg" height="500px" />
</p>
</div>
</div>
<div class="slide-footer">Lindenmayer Systems: Alasdair McAndrew, ATCM2017</div>
</section>
</section>
<section>
<section id="slide-org9655f4b">
<h2 id="org9655f4b">How turtle graphics works</h2>
<p>
This shows how the turtle draws a path with branches:
</p>
<div class="figure">
<p><img src="./Images/growth.jpg" alt="growth.jpg" width="1000px" />
</p>
</div>
<div class="slide-footer">Lindenmayer Systems: Alasdair McAndrew, ATCM2017</div>
</section>
</section>
<section>
<section id="slide-org97b770e">
<h2 id="org97b770e">More on turtle graphics</h2>
<p>
It's all done from the point of view of the turtle. A side of <i>Koch's
snowflake</i> can be computed by the rules:
</p>
<ul>
<li>Start: <code>F</code></li>
<li>Modify: <code>F</code> → <code>F+F--F+F</code> (with turns of 60°)</li>
<li>At every further step, each <code>F</code> is replaced by the string <code>F+F--F+F</code></li>
<li><p>
The second iteration produces
</p>
<p>
<span style="background-color: lightgray;">F+F--F+F</span>+<span style="background-color: lightgray;">F+F--F+F</span> <code>--</code>
<span style="background-color: lightgray;">F+F--F+F</span>+<span style="background-color: lightgray;">F+F--F+F</span>
</p></li>
<li><p>
The third iteration produces:
</p>
<p>
<span style="background-color: lightgray;">F+F--F+F</span> + <span style="background-color: lightgray;">F+F--F+F</span> <code>--</code>
<span style="background-color: lightgray;">F+F--F+F</span> + <span style="background-color: lightgray;">F+F--F+F</span>+
<span style="background-color: lightgray;">F+F--F+F</span> + <span style="background-color: lightgray;">F+F--F+F</span> <code>--</code>
<span style="background-color: lightgray;">F+F--F+F</span> + <span style="background-color: lightgray;">F+F--F+F</span> <code>--</code>
<span style="background-color: lightgray;">F+F--F+F</span> + <span style="background-color: lightgray;">F+F--F+F</span> <code>--</code>
<span style="background-color: lightgray;">F+F--F+F</span> + <span style="background-color: lightgray;">F+F--F+F</span>+
<span style="background-color: lightgray;">F+F--F+F</span> + <span style="background-color: lightgray;">F+F--F+F</span> <code>--</code>
<span style="background-color: lightgray;">F+F--F+F</span> + <span style="background-color: lightgray;">F+F--F+F</span>
</p></li>
</ul>
<ul>
<li>and so on…</li>
</ul>
<div class="slide-footer">Lindenmayer Systems: Alasdair McAndrew, ATCM2017</div>
</section>
</section>
<section>
<section id="slide-org0a143c5">
<h2 id="org0a143c5">Turtle graphics <i>with pictures!</i></h2>
<div class="column" style="float:left; text-align:right; width:50%">
<p>
<br><br>
First iteration:
<br><br><br>
Second iteration:
<br><br><br>
Third iteration:
<br><br><br>
Fourth iteration:
</p>
</div>
<div class="column" style="float:right; width:50%">
<div class="figure">
<p><img src="./Images/koch_snowflake.jpg" alt="koch_snowflake.jpg" height="500px" />
</p>
</div>
</div>
<div class="slide-footer">Lindenmayer Systems: Alasdair McAndrew, ATCM2017</div>
</section>
</section>
<section>
<section id="slide-orgcbec3f5">
<h2 id="orgcbec3f5">Some mathematics</h2>
<p>
Remember the <code>F</code> \(\rightarrow\) <code>F+F--F+F</code> iteration? How many symbols
are in the \(n\)<sup>th</sup> string?
</p>
<p>
Let \(f_n\) be the number of <code>F</code>'s, and \(k_n\) be the number of other
symbols in the \(n\)<sup>th</sup> string. We have:
</p>
<div>
\begin{eqnarray*}
f_{n+1}&=&4f_n,\quad f_1=4\\
k_{n+1}&=&4f_n+k_{n-1},\quad k_1=4
\end{eqnarray*}
</div>
<p>
It follows immediately that
\[
f_n=4^n\mbox{ and }k_n=4+4^2+4^3+\cdots+4^n=\frac{4}{3}(4^n-1).
\]
The total length is thus
\[
f_n+k_n=4^n+\frac{4}{3}(4^n-1)=\frac{1}{3}(7(4^n)-4).
\]
</p>
<div class="slide-footer">Lindenmayer Systems: Alasdair McAndrew, ATCM2017</div>
</section>
</section>
<section>
<section id="slide-org020efa0">
<h2 id="org020efa0">The fractal plant in modern languages: Racket</h2>
<p>
Racket is a modern lisp; descended from Scheme.
</p>
<div class="org-src-container">
<pre><code class="Scheme" >;; F -> F[+F]F[-F]F
(require furtle) ;; furtle is a simple but fast turtle graphics library
(: ltree_b (-> Real Real Real TurtleF)) ;; typed Racket so must declare types
(define (ltree level size angle)
(if (= level 0)
(turtles (forward size))
(turtles (ltree (- level 1) (/ size 3) angle) ; F
(save) ; [
(left angle) (ltree (- level 1) (/ size 3) angle) ; +F
(restore) ; ]
(ltree (- level 1) (/ size 3) angle) ; F
(save) ; [
(right angle) (ltree (- level 1) (/ size 3) angle) ; -F
(restore) ; ]
(ltree (- level 1) (/ size 3) angle)))) ; F
</code></pre>
</div>
<div class="slide-footer">Lindenmayer Systems: Alasdair McAndrew, ATCM2017</div>
</section>
</section>
<section>
<section id="slide-org61035f4">
<h2 id="org61035f4">The fractal plant in modern languages: Python</h2>
<div class="org-src-container">
<pre><code class="Python" >import turtle as t # "turtle" is a turtle graphics module
# Lindenmayer system (a) from ABOP figure 1.24(a), p 25
def edgetree(level, size, angle):
if (level==0):
t.fd(size)
else:
edgetree(level-1, size/3, angle)
t.lt(angle)
edgetree(level-1, size/3, angle)
t.bk(size/3)
t.rt(angle)
edgetree(level-1, size/3, angle)
t.rt(angle)
edgetree(level-1, size/3, angle)
t.bk(size/3)
t.lt(angle)
edgetree(level-1, size/3, angle)
</code></pre>
</div>
<div class="slide-footer">Lindenmayer Systems: Alasdair McAndrew, ATCM2017</div>
</section>
</section>
<section>
<section id="slide-orgd7f78ae">
<h2 id="orgd7f78ae">A couple of pictures:</h2>
<div class="column" style="float:left; width:50%">
<p>
<code>F</code> \(\rightarrow\) <code>FF-[-F+F+F]+[+F-F-F]</code>
</p>
<div class="figure">
<p><img src="./Images/lindenmayer_plant1.jpg" alt="lindenmayer_plant1.jpg" height="450px" />
</p>
</div>
</div>
<div class="column" style="float:right; width:50%">
<p>
<code>F</code> \(\rightarrow\) <code>FF[+F][--FF][-F+F]</code>
</p>
<div class="figure">
<p><img src="./Images/lindenmayer_plant2.jpg" alt="lindenmayer_plant2.jpg" height="450px" />
</p>
</div>
</div>
<div class="slide-footer">Lindenmayer Systems: Alasdair McAndrew, ATCM2017</div>
</section>
</section>
<section>
<section id="slide-org6605deb">
<h2 id="org6605deb">Some more mathematics</h2>
<p>
<i>Fractal dimension</i> can be defined by the "box-counting measure":
</p>
<p>
Suppose our picture is subdivided into boxes of size \(b\), and \(N(b)\) boxes
are needed to cover the shape. Its dimension can be defined as
\[
\lim_{b\to 0}\frac{\log(N(b))}{\log(1/b)}.
\]
For example, take a curve of length \(k\). As \(b\to 0\), we would find that
\[
N(b)\to \frac{k}{b}.
\]
Thus
\[
\lim_{b\to 0}\frac{\log(N(b))}{\log(1/b)}=\lim_{b\to 0}\frac{\log(k/b)}{\log(1/b)}
=\lim_{b\to 0}1-\frac{\log(k)}{\log(b)}=1.
\]
In general a fractal will have a non-integer dimension between 1 and 2.
</p>
<div class="slide-footer">Lindenmayer Systems: Alasdair McAndrew, ATCM2017</div>
</section>
</section>
<section>
<section id="slide-org7a1fdab">
<h2 id="org7a1fdab">Some concluding remarks</h2>
<ul>
<li>Lindenmayer systems provide a neat, elegant and simple way to explore
fractal geometry…</li>
<li>… and to explore natural shapes such as plants</li>
<li>Fractals are <i>everywhere</i> in the world</li>
<li>Their mathematics is subtle, interesting, and beautiful</li>
<li>A wonderful mixture of mathematics, computing, algebra, and graphics</li>
<li>Thank you all!</li>
</ul>
<div class="slide-footer">Lindenmayer Systems: Alasdair McAndrew, ATCM2017</div>
</section>
</section>
</div>
</div>
<p> Created by Alasdair </p>
<script src="./lib/js/head.min.js"></script>
<script src="./js/reveal.js"></script>
<script>
// Full list of configuration options available here:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: false,
center: true,
slideNumber: 'c',
rollingLinks: true,
keyboard: true,
overview: true,
width: 1200,
minScale: 0.50,
theme: Reveal.getQueryHash().theme, // available themes are in /css/theme
transition: Reveal.getQueryHash().transition || 'None', // default/cube/page/concave/zoom/linear/fade/none
transitionSpeed: 'default',
multiplex: {
secret: '', // null if client
id: '', // id, obtained from socket.io server
url: '' // Location of socket.io server
},
// Optional libraries used to extend on reveal.js
dependencies: [
{ src: './plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: './plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: './plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: './plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } },
]
});
</script>
</body>
</html>