Graphics Reference
In-Depth Information
occurrences of any left-hand side of a production in the string. Symbols of the string that are not on
the left-hand side of any production rule are assumed to be operated on by the identity production rule,
a i !b i . The parallel application of the production rules produces a new string. The production rules are
then applied again to the new string. This happens iteratively until no occurrences of a left-hand side of
a production rule occur in the string. Sample production rules and the string they generate are shown in
Figure 12.10 .
Geometric interpretation of L-systems
The strings produced by L-systems are just that—strings. To produce images from such strings, one
must interpret them geometrically. Two common ways of doing this are geometric replacement and
turtle graphics . In geometric replacement, each symbol of a string is replaced by a geometric element.
For example, the string XXTTXX can be interpreted by replacing each occurrence of X with a straight
line segment and each occurrence of T with a V shape so that the top of the V aligns with the endpoints
of the geometric elements on either side of it (see Figure 12.11 ) .
In turtle graphics, a geometry is produced from the string by interpreting the symbols of the string as
drawing commands given to a simple cursor called a turtle. The basic idea of turtle graphics interpre-
tation, taken from Prusinkiewicz and Lindenmayer [ 16 ], uses the symbols from Table 12.1 to control
XXTTXX
String
:
:
X
T
Geometric replacement rules
Geometric interpretation
FIGURE 12.11
Geometric interpretation of a simple string.
Table 12.1 Turtle Graphics Commands
Symbol
Turtle Graphic Interpretation
F
Move forward a distance d while drawing a line. Its state will change from (x, y, a)to(x þ d cos a,
y þ d sin a, a).
f
Move forward a distance d without drawing a line. Its state will change as above.
þ
Turn left by an angle d. Its state will change from (x, y, a)to(x, y, aþd).
Turn right by an angle d. Its state will change from (x, y, a) to (x, y, ad).
 
Search WWH ::




Custom Search