plot::Lsys -- graphical primitive
for a Lindenmayer system
Introductionplot::Lsys(deg, start, rule...) represents
a Lindenmayer system with turning degree deg, starting
word start and rule set rule....
Creating
Elementsplot::Lsys(deg, start, rule...)
Parametersdeg |
- | the degree by which the turtle turns left or right, an arithmetical expression |
start |
- | the starting word of the system, a string |
rule |
- | a rule of the system, an equation |
Related
Domains
Related
Functions
Detailsplot::Lsys represent Lindenmayer
systems. Lindenmayer systems are a means to describe the growth of
plants and may be used to create beautiful recursive drawings.A Lindenmayer system describes a language L, a subset of A*. The language is defined as follows:
A turtle has a position in the plane, a direction and a colour. It understands only few commands: Move forward and draw a line, move without drawing, turn left, turn right, change your colour. Further a turtle may remember its current state (position, direction and colour) by pushing it onto a stack and change its state to a former one by popping it off from the stack. For each character of the alphabet A one of these turtle commands may be defined. A character may also have no command, causing the turtle to do nothing.
plot::Lsys allows the definition of Lindenmayer
systems and the plotting of words defined by the system. The domain
plot::Turtle creates
turtles, it may be useful for other purposes than plotting words of
Lindenmayer systems.start is interpreted as the starting
word of the Lindenmayer system, each character in the string represents
a character of the system.lhs = rhs where the left
hand side lhs must be a string of lenght 1. The right hand
side rhs must be a string, a turtle command or a colour
value.
A left hand side is interpreted as single character of the Lindenmayer system. A right hand side which is a string is interpreted as the word which replaces the left hand character. Each character in the string represents a character of the system.
A right hand side which is a turtle command or a colour value desribe how a word generated by the Lindenmayer system is to be interpreted by the turtle. A turtle command or a colour value changes the actual state of the turtle and moves it around.
A turtle command may be one of the identifiers Move,
Line, Left, Right,
Push or Pop. These commands cause the turtle
to move without drawing, to draw a line, to turn left or right and to
push or pop its current state. A colour value must be a list of three
numbers [r,g,b] defining new red-, green- and blue colour
values of the turtle. The colour values must be in the range between 0
and 1 like the colour values in the other plot commands.
"F" = Line"f" = Move"+" = Left"-" = Right"[" = Push"]" = Pop"generations" attribute to change the
generation, see below.l can be
displayed via the call plot(l), or used with other
graphical primitives of the plot library.plot::Lsys has type
"graphprim", i.e., if o is such an object,
then the result of type(o) is the string
"graphprim".::.
Each attribute has the property ``read'', i.e., the value of an
attribute attr of a graphical primitive o can
be read with o::attr. If the attribute also has the
``write'' property, then the value of the attribute can be changed with
o::attr := new_value.
The following attributes are available for a Lindenmayer system:
| attribute | meaning | properties |
generations |
The generation of the system which is to be plotted, a positive integer. | read/write |
plot::Curve2d for examples for working
with attributes of graphical primitives.Evaluating an object of type plot::Lsys returns
itself.
getPlotdata(dom l)l in a plot2d and plot3d conforming syntax,
respectively, i.e., it has the form [Mode = List, [polygon(...)],
...].plot::Scene to build the plot data of
the graphical scene.slot(dom l, string
slotname)slotname of
l. slotname may be the name of an attribute.
See the tables of available plot attributes above.slotname is an invalid attribute, then an error
message is issued.slot, i.e., one may use it in the form
l::slotname_id (here, slotname_id must be the
identifier corresponding to the string slotname), or in
functional notation slot(l, slotname).slot(dom l, string
slotname, any val)slotname to the value val.slotname, or if
val is not an admissible value for slotname,
then a warning message is issued. In this case, the value of
slotname remains unchanged.slot, i.e., one may use it in the form
l::slotname_id := val (here, slotname_id must
be the identifier corresponding to the string slotname),
or in functional notation slot(l, slotname, val).print(dom l)plot::Lsys(deg, start, rule...). It is used to print
objects of plot::Lsys to the screen.print for details.
Example
1We simply list some examples without any interpretation:
>> L := plot::Lsys(90, "F-F-F-F", "F"="F-F+F+FF-F-F+F"): L::generations := 4: plot(L, Axes = None)
>> L := plot::Lsys(90, "F-F-F-F", "F"="FF-F--F-F"): L::generations := 4: plot(L, Axes = None)
>> L := plot::Lsys(90, "F-F-F-F", "F"="FF-F+F-F-FF"): L::generations := 4: plot(L, Axes = None)
>> L := plot::Lsys(90, "L", "L"="L+R+", "R"="-L-R", "L"=Line, "R"=Line): L::generations := 10: plot(L, Axes = None)
>> L := plot::Lsys(60, "R", "L"="R+L+R", "R"="L-R-L", "L"=Line, "R"=Line): L::generations := 7: plot(L, Axes = None)
>> L := plot::Lsys(20, "L", "L"="R[+L]R[-L]+L", "R"="RR", "L"=Line, "R"=Line): L::generations := 6: plot(L, Axes = None)
>> L := plot::Lsys(20, "L", "L"="BR[+HL]BR[-GL]+HL", "R"="RR",
"L"=Line, "R"=Line,
"B"=RGB::Brown, "H"=RGB::ForestGreen,
"G"=RGB::SpringGreen):
L::generations := 6:
plot(L, Axes = None)
>> L := plot::Lsys(60, "F++F++F", "F"="F-F++F-F"): L::generations := 5: plot(L, Axes = None)
Lsysplot library.