Graphics Reference
In-Depth Information
the turtle. The state of the turtle at any given time is expressed as a triple ( x , y , a ), where x and y give its
coordinates in a two-dimensional space and a gives the direction it is pointing relative to some given
reference direction (here, a positive angle is measured counterclockwise from the reference direction).
The values d and d are user-specified system parameters and are the linear and rotational step sizes,
respectively.
Given the reference direction, the initial state of the turtle ( x 0 , y 0 , a 0 ), and the parameters d and d , the
user can generate the turtle interpretation of a string containing the symbols of Table 12.1
( Figure 12.12 ) .
Bracketed L-systems
The D0L-systems described previously are inherently linear, and the graphical interpretations reflect
this. To represent the branching structure of plants, one introduces a mechanism to represent multiple
segments attached at the end of a single segment. In bracketed L-systems , brackets are used to mark the
beginning and the end of additional offshoots from the main lineage. The turtle graphics interpretation
of the brackets is given in Table 12.2 . A stack of turtle graphic states is used, and the brackets push and
pop states onto and off this stack. The state is defined by the current position and orientation of the
turtle. This allows branching from a stem to be represented. Further, because a stack is used, it allows
an arbitrarily deep branching structure.
Figure 12.13 shows some production rules. The production rules are context free and nondetermi-
nistic . They are context free because the left-hand side of the production rule does not contain any
S −> ABA
A
S
ABA
FFTTFF
FFFFFFFF
axiom
FF
B −> TT
T −> FF
−>
Production rules
Sequence of strings produced from the axiom
d
δ
reference direction:
45
initial state: (10, 10, 0)
Initial conditions
y
x
Geometric interpretation
FIGURE 12.12
Turtle graphic interpretation of a string generated by an L-system.
 
Search WWH ::




Custom Search