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
|
%% $Id: pst-lsystem-doc.tex 820 2018-09-26 09:52:39Z herbert $
\documentclass[fontsize=11pt,english,BCOR=10mm,DIV=12,bibliography=totoc,parskip=false,
headings=small, headinclude=false,footinclude=false,oneside,abstract=on]{pst-doc}
\usepackage{pst-lsystem}
\let\pstFV\fileversion
\usepackage{dtk-logos}
\usepackage{xltabular}
\renewcommand\bgImage{%
\begin{pspicture}(-2,-0.5)(3,6)
\pslsystem[
Start=Y,
X={X[-FFF][+FFF]FX},
Y={YFX[+Y][-Y]},
Angle=25,
N=6,
Ftype=1,
BaseLength=2.5pt,
usecolor=2](0,0)
\psdot(0,0)
\end{pspicture}
}
\addbibresource{\jobname.bib}
\lstset{language=PSTricks,
morekeywords={pslsystem},basicstyle=\footnotesize\ttfamily,
literate=%
{Ö}{{\"O}}1
{Ä}{{\"A}}1
{Ü}{{\"U}}1
{ß}{{\ss}}1
{ü}{{\"u}}1
{ä}{{\"a}}1
{ö}{{\"o}}1
{~}{{\textasciitilde}}1
}
\begin{document}
\title{\texttt{pst-lsystem}}
\subtitle{Creating images, based on the Lindenmayer-system; v.\pstFV}
\author{Herbert Voß}
\docauthor{}
\date{\today}
\maketitle
\tableofcontents
\begin{abstract}
\noindent
\LPack{pst-lsystem} loads by default the following packages: \LPack{pst-xkey}, and, of course \LPack{pstricks}.
All should be already part of your local \TeX\ installation. If not, or in case
of having older versions, go to \url{http://www.CTAN.org/} and load the newest version.
\vfill\noindent
Thanks to \\
Michel Charpentier,
and last but not least
\url{http://mathworld.wolfram.com}.
\end{abstract}
\clearpage
\section{Introduction}
A L-system or Lindenmayer system is a parallel rewriting system and a type of
formal grammar. An L-system consists of an alphabet of symbols that can be used
to make strings, a collection of production rules that expand each symbol into
some larger string of symbols, an initial »axiom« string from which to begin construction,
and a mechanism for translating the generated strings into geometric structures.
L-systems were introduced and developed in 1968 by Aristid Lindenmayer,
a Hungarian theoretical biologist and botanist at the University of Utrecht.~\cite{wikipedia}
\section{Usage}
There are no optional arguments for the package:
\begin{verbatim}
\usepackage{pst-lsystem}
\end{verbatim}
There is only one command:
\begin{BDef}
\Lcs{pslsystem}\OptArgs\Largr{x,y}
\end{BDef}
If the coordinates for the origin are missing, then $(0,0)$ is assumed. The L-System ist
defined by the three functions $F$, $X$, and $Y$. At least one function must be given.
\subsection{Optional arguments}
The following optional arguments for the macro are possible:
\begin{xltabular}{\linewidth}{@{} l l X @{}}\toprule
\emph{name} & \emph{default} & \emph{menaing}\\\midrule
\Lkeyword{F} & & Rule $F\rightarrow(F)$\\
\Lkeyword{X} & & Rule $X\rightarrow(F,X,Y)$\\
\Lkeyword{Y} & & Rule $Y\rightarrow(F,X,Y)$\\
\Lkeyword{Start} & & Startrule $S\rightarrow(F,X,Y)$\\
\Lkeyword{Angle} & 45 & Angle for the drection change\\
\Lkeyword{N} & 5 & Number of the recursive calls\\
\Lkeyword{Ftype} & 4 & How the F-rule should be handled\\
\Lkeyword{BaseLength} & 1mm & The length of a base line, created by the ruke F (Forward)\\
\Lkeyword{usecolor} & 0 & Which color should be used for the lines.\\
%\define@key[psset]{pst-lsystem}{order}[5]{\pst@getint{#1}\psk@lsystem@order}
%\define@key[psset]{pst-lsystem}{factor}[2]{\pst@checknum{#1}\psk@lsystem@factor}
% Size (the smaller, the bigger), no need to be changed, normally
%\define@key[psset]{pst-lsystem}{size}[4]{\pst@getint{#1}\psk@lsystem@size}
%\define@key[psset]{pst-lsystem}{type}[0]{\pst@getint{#1}\psk@lsystem@type}
\bottomrule
\end{xltabular}
\bigskip
If the rules contain square brackets then it must be enclosed by braces:
\verb|X=F[-X]| is wrong and \verb|X={F[-X]}| is correct.
\subsection{Different types for the F-rule}
It depends to the given rule(s) what kind of the F-type must be used.
There are five possibilities:
\begin{xltabular}{\linewidth}{@{} >{\ttfamily}l X @{}}
0 & $F\rightarrow \textrm{draw line element}$ \\
& in PostScript: \verb|/F { D } def|\\
1 & $F\rightarrow \textrm{If loop variable }=0 \textrm{ then draw line element}$\\
& in PostScript: \verb|/F { 0 eq { D } if } def|\\
2 & $F\rightarrow \textrm{If loop variable }=0 \textrm{ then draw line element and keep variable}$\\
& in PostScript: \verb|/F { dup 0 eq { D } if } def|\\
3 & $F\rightarrow \textrm{draw line element and delete current loop variable}$\\
& in PostScript: \verb|/F { pop D } def|\\
4 & $F\rightarrow \textrm{If loop variable }=0 $ then draw line element! If not $=0$ decrease loop variable, duplicate it
$n-1$ times (n is the number of functions in $F$) and put F-rule on stack\\
& in PostScript: \verb|/F { dup 0 eq { D }{ 1 sub N 1 sub {dup} repeat F-rule } ifelse pop } def|
\end{xltabular}
\iffalse
\begin{verbatim}
\ifcase\psk@lsystem@Ftype
/F { D } def % type 0
\or % 1
/F { 0 eq { D } if } def
\or % 2
/F { dup 0 eq { D } if } def
\or % 3
/F { pop D } def
\else % 4
/F { dup 0 eq { D }{ 1 sub \psk@lsystem@Fnumber {dup} repeat \psk@lsystem@F } ifelse pop } def
\fi
\end{verbatim}
\fi
The function D does nothing else than drawing a line in the current direction.
Its length is given by the optional parameter BaseLength.
\subsection{Color}
There are four predefined color modes, where mode=0 is no color.
\psset{linewidth=0.1pt}
\section{Examples}
\subsection{Dragon}
\begin{LTXexample}[pos=r]
\begin{pspicture}[showgrid=true](-2,-1.5)(4,6)
\pslsystem[
X=-FX++FY-,
Y=+FX--FY+,
Ftype=1,
Start=X,
Angle=45,
N=9,
BaseLength=2mm](0,0)
\psdot(0,0)
\end{pspicture}
\end{LTXexample}
\subsection{Hilbert}
\begin{LTXexample}[pos=r]
\begin{pspicture}[showgrid=true](-1,-0.5)(4,4)
\pslsystem[
X=-YF+XFX+FY-,
Y=+XF-YFY-FX+,
Ftype=3,
Start=X,
Angle=90](0,0)
\psdot(0,0)
\end{pspicture}
\end{LTXexample}
\clearpage
\subsection{Kochflake}
If the rule for \Lkeyword{Start} has more than one function name, one has to repeat
the number of iterations, which is \Lkeyword{N}, before every following function, but not
for the first one. That is done already internally:
\begin{LTXexample}[pos=r]
\begin{pspicture}[showgrid=true](-2,-.5)(5,6)
\pslsystem[
Start=F--NF--NF,% repeat number of iterations N
F=F+F--F+F,
Angle=60,
N=4,
BaseLength=2pt,
linecolor=red](0,0)
\psdot(0,0)
\end{pspicture}
\end{LTXexample}
\subsection{Plant 1}
\begin{LTXexample}[pos=r]
\begin{pspicture}[showgrid=true](-2,-2.3)(4,6)
\pslsystem[
Start=F,
F={FF-[-F+F+F]+[+F-F-F]},
Angle=22.5,
BaseLength=2pt,
usecolor=4](0,-2)
\psdot(0,-2)
\end{pspicture}
\end{LTXexample}
\clearpage
\subsection{Plant 2}
\begin{LTXexample}[pos=r]
\begin{pspicture}[showgrid=true](-3,-2.3)(2,6)
\pslsystem[
Start=X,
X={F-[[X]+X]+F[+FX]-X},
F=FF,
Angle=22.5,
N=6,
BaseLength=1.25pt,
usecolor=3](0,-2)
\psdot(0,-2)
\end{pspicture}
\end{LTXexample}
\subsection{Plant 3}
\begin{LTXexample}[pos=r]
\begin{pspicture}[showgrid=true](-2,-2.5)(2,5)
\psset{xunit=3}
\pslsystem[
Start=F,
F={F[+F]F[-F][F]},
Angle=20,
usecolor=3](0,-2)
\psdot(0,-2)
\end{pspicture}
\end{LTXexample}
\clearpage
\clearpage
\subsection{Plant 4}
\begin{LTXexample}[pos=r]
\begin{pspicture}[showgrid=true](-2,-0.5)(3,6)
\pslsystem[
Start=Y,
X={X[-FFF][+FFF]FX},
Y={YFX[+Y][-Y]},
Angle=25,
N=6,
Ftype=1,
BaseLength=2.5pt,
usecolor=2](0,0)
\psdot(0,0)
\end{pspicture}
\end{LTXexample}
\subsection{Plant 5}
\begin{LTXexample}[pos=r]
\begin{pspicture}[showgrid=true](-3,-.5)(3,9)
\pslsystem[
Start=X,
X={F[+X][-X]FX},
F={FF},
Angle=25,
N=7,
BaseLength=1pt,
usecolor=2](0,0)
\psdot(0,0)
\end{pspicture}
\end{LTXexample}
\clearpage
\clearpage
\subsection{Plant 6}
\begin{LTXexample}[pos=r]
\begin{pspicture}[showgrid=true](-3,-.5)(3,9)
\pslsystem[
Start=X,
X={F[+X]F[-X]+X},
F={FF},
Angle=20,
N=7,
BaseLength=1pt,
usecolor=2](0,0)
\psdot(0,0)
\end{pspicture}
\end{LTXexample}
\subsection{Plant 7}
\begin{LTXexample}[pos=r]
\begin{pspicture}[showgrid=true](-3,-.5)(3,9)
\pslsystem[
Start=F,
F={F[+F]F[-F]F},
Angle=25,
BaseLength=1pt,
usecolor=2](0,0)
\psdot(0,0)
\end{pspicture}
\end{LTXexample}
\clearpage
\subsection{Plant 8}
\begin{LTXexample}[pos=r]
\begin{pspicture}[showgrid=true](-4,-.5)(5,9)
\pslsystem[
Start=F,
F={F[+F[+F][-F]F][-F[+F][-F]F]F[+F][-F]F},
Angle=30,
BaseLength=1pt,
usecolor=4](0,0)
\psdot(0,0)
\end{pspicture}
\end{LTXexample}
\subsection{Special case}
\begin{LTXexample}[pos=r]
\begin{pspicture}[showgrid=true](-2,-0.5)(1,4)
\pslsystem[
Start=X,
F=FF,
X=F+X-F-X+F,
Angle=90,
N=6,
BaseLength=1pt](0,0)
\psdot(0,0)
\end{pspicture}
\end{LTXexample}
\clearpage
\section{List of all optional arguments for \nxLPack{pst-lsystem}}
\xkvview{family=pst-lsystem,columns={key,type,default}}
\bgroup
\raggedright
\nocite{*}
\printbibliography
\egroup
\printindex
\end{document}
% F=F+FF-FF-F-F+F+FF-F-F+F+FF+FF-F,
|