# Three-Dimensional Commands

The commands operated so far on a two-dimensional plane. However, they can easily be extended to a three-dimensional space. Aside from the third coordi-

nate, the only difference is the more complex definition of angles and rotation Section 5.4 axes for the movement of the turtle. Three-Dimensional Commands

During the course of the movement, the coordinate system is so to speak posi­tioned at the head of the turtle, i. e., the turning just like the shifting affects the turtle locally. Here the coordinate system can be turned relative to three axes. if the coordinate system is positioned to the head of the turtle so that in fact it always moves in the 2 direction, then the rotations represented in Fig. 5.4 can be executed. Figure 5.4

Local coordinate system for controlling the turtle in three dimensions

Accordingly the divergence angle 6 is used either corresponding to the x-, y- or to the z-axis. The rotations about theses axes are defined by rotation matrices

Rx, Ry, and Rz:  sin 6 0

cos 6 0

0 1

The machine is now described by the state vector (x, y, z, M), where M is a rotation matrix. In aviation jargon the z-axis is called the course axis, the y – axis, the vertical axis, and the x-axis, the lateral axis. The rotations are called rolling, heading, and pitching. The appropriate commands are now:

F Move turtle at d in current direction, draw line:

(x, y,z, M) ^ (x + (Md)i, y + (M4,z + (М^з, M)

f Move turtle at d in current direction, without drawing line:

(x, y,z, M) ^ (x + (Md)i, y + (Md)2,z + (M^, M)

+ increase the angle in terms of vertical axis at 6:

(x, У, z, M) ^ (x, У, z, M • Ry(6))

– Decrease the angle in terms of vertical axis at 6:

(x, y, z, M) ^ (x, y, z, M • Ry(-6))

& Increase the angle in terms of lateral axis at 5:

(x, y, z, M) ^ (x, y, z, M • Rx(5))

Л Decrease the angle in terms of lateral axis at 5:

(x, y, z, M) ^ (x, y, z, M • Rx(—5))

Inrease the angle in terms of roll axis at 5:

(x, y, z, M) ^ (x, y, z, M • Rz(5))

/ Decrease the angle in terms of roll axis at 5:

(x, y, z, M) ^ (x, y, z, M • Rz(—5))

| Turn around, here use matrix Ry (180°):

(x, y, z, M) ^ (x, y, z, M • Ry (180°))

A small shrub shall serve as an example for the modeling with three-dimension­al commands. The L-system consists of the above-mentioned alphabet and four productions (n = 7,5 = 22.5°,w = A):

A ::= [&FL! A]/////'[&FLA]///////'[&FLA]

F ::= S/////F S ::= FL

L ■■= [‘"л Л {—f + f + f — l—f + f + f}]

The curved brackets serve here for marking a path in the form of a point se­quence. These points are triangulated during the geometry production to trian­gles; the triangles then defines the surface. The symbols! and ‘ serve for the reduction of the branch diameter and for the control of the colors. The result is displayed in Fig. 5.5. It shows a small three-dimensional shrub with a surface consisting of several hundred polygons.

Figure 5.5 Three-dimensional shrub modeled using L-systems (Courtesy of P. Prusinkiewicz)