### 9` `3D L-system turtles

(require lindenmayer/3d-turtle) | package: lindenmayer |

lindenmayer/3d-turtle provides following symbols for L-system interpretation:

F : Move the turtle forward, and draw a line. If passed an argument it will move that distance, otherwise it will move 1 unit. If within a set of |{| |}|, record a point in the polygon.

f : Like F but does not draw a line.

G : Like F but does not record a point in a polygon.

|.| : Record a point in the polygon if within |{| |}|.

+ : Yaw the turtle clockwise (Rotate around its “up” axis). If a parameter is given it rotates by that many degrees, otherwise it uses the variable δ.

- : Like + but rotates counterclockwise

& : Pitch the turtle clockwise (Rotate around its “left” axis). If a parameter is given it rotates by that many degrees, otherwise it uses the variable δ.

^ and ∧ : Like & but counterclockwise.

|\| : Roll the turtle clockwise (Rotate around its “forward” axis). If a parameter is given it rotates by that many degrees, otherwise it uses the variable δ.

/ : Like |\|, but counterclockwise.

$ : Roll the turtle so that its “left” vector is in the X/Y plain.

! : Change the current line width. If a parameter is given it is set to that, otherwise, the line width is decreased by 40%.

|[| : Save the current turtle state.

|]| : Restore the turtle to the state of the most recent |[|.

|{| : Begin recording vertices for a polygon.

|}| : End recording a polygon. The points recorded between this and corresponding |{| are interpreted (and therefore draw), in order, as the boundary of a convex surface. The surface does not need to be planar. The color of the polygon is controlled by a linear interpolation of the color of each vertex.

|'| and ’ : Increment the position in the color vector, modulo its length. (See draw). The colors controls the line color and the colors of the vertices of polygons.

The library also provides the following functions for creating start and finish functions, or building new symbols for the L-system:

procedure

(turtle-state? it) → boolean?

it : any/c

procedure

(make-turtle start forward up [line-width]) → turtle-state?

start : dir? forward : dir? up : dir? line-width : positive? = 1/4

up and forward must be unit vectors that are orthogonal to each other.

value

procedure

turtle : turtle-state? color-vec : (vector/c rgba?) = (vector (rgba "white" 0))

procedure

(insert-pict turtle pict) → turtle-state?

turtle : turtle-state? pict : pict3d?

procedure

(set-rendering-config! width height [ #:ambiance? ambiance #:background background #:emit emit]) → void? width : positive? height : positive? ambiance : any/c = #f background : rgba? = (rgba "white" 0) emit : emitted? = default-emitted