# turtle

### Description

The turtle polybuilder is an experimental way of building polygonal objects using a logo style turtle in 3D space. As you drive the turtle around you can place vertices and build shapes procedurally. The turtle can also be used to deform existing polygonal primitives, by attaching it to objects you have already created.

### Example

``` (define (build n)
(turtle-reset)
(turtle-prim 'polygon)
(build-loop n n)
(turtle-build))

(define (build-loop n t)
(turtle-turn (vector 0 (/ 360 t) 0))
(turtle-move 1)
(turtle-vert)
(if (< n 1)
0
(build-loop (- n 1) t)))
```

## (turtle-prim type-symbol)

Returns void

Starts building a new polygon primitive with the turtle. The type specifies the polygon face type and is one of the following: 'triangle-strip, 'quad-list, 'triangle-list, 'triangle-fan, 'polygon.

Example

``` (turtle-prim 'triangle-strip)
```

## (turtle-vert)

Returns void

Creates a new vertex in the current position, or sets the current vertex if the turtle builder is attached.

Example

``` (turtle-vert)
```

## (turtle-build)

Returns primitiveid-number

Builds the object with the vertex list defined and gives it to the renderer. Has no effect if the turtle builder is attached to a primitive.

Example

``` (define mynewshape (turtle-build))
```

## (turtle-move distance-number)

Returns void

Moves the turtle forward in it's current orientation.

Example

``` (turtle-move 1)
```

## (turtle-push)

Returns void

The turtle build has it's own transform stack. Push remembers the current position and orientation.

Example

``` (turtle-push)
```

## (turtle-pop)

Returns void

The turtle build has it's own transform stack. Pop forgets the current position and orientation, and goes back to the state at the last push.

Example

``` (turtle-pop)
```

## (turtle-turn rotation-vector)

Returns void

Rotates the turtle's orientation with the supplied euler angles (rotations in x, y and z).

Example

``` (turtle-turn (vector 45 0 0))
```

## (turtle-reset)

Returns void

Resets the current position and rotation of the turtle to the origin.

Example

``` (turtle-reset)
```

## (turtle-attach primitiveid-number)

Returns void

Attaches the turtle to an existing poly primitive. This means you are able to deform an existing objects points using the turtle builder.

Example

``` (define myshape (build-sphere 10 10))
(turtle-attach myshape)
```

## (turtle-skip count-number)

Returns void

When attached, causes the turtle to skip vertices. This value may be negative, which will set the turtle to write to previous vertices.

Example

``` (turtle-skip -1)
```

## (turtle-position)

Returns count-number

When attached, returns the current pdata index the turtle is writing to.

Example

``` (display (turtle-position))(newline)
```

## (turtle-seek position-number)

Returns void

When attached, sets the absolute pdata index the turtle is writing to.

Example

``` (turtle-seek 0)
```

## (get-turtle-transform)

Returns matrix-vector

Returns a matrix representing the current turtle transform.

Example

``` (clear)
(hint-none)
(hint-wire)
(turtle-reset)
(turtle-prim 4)
(for ([i (in-range 9)])
(turtle-turn (vector 0 0 36))
(turtle-move 1)
(turtle-vert))
(turtle-build)
(with-primitive (build-locator)
(hint-origin)
(concat (get-turtle-transform)))
```
{"ft_lang_label":"__label__en","ft_lang_prob":0.76729685,"math_prob":0.5228927,"size":2767,"snap":"2019-13-2019-22","text_gpt3_token_len":661,"char_repetition_ratio":0.21245024,"word_repetition_ratio":0.055,"special_character_ratio":0.22949043,"punctuation_ratio":0.072765075,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9896117,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-03-19T19:52:32Z\",\"WARC-Record-ID\":\"<urn:uuid:a6999fd4-85aa-4e2f-a7d6-cd8ea5ac30aa>\",\"Content-Length\":\"5775\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:e9c37187-d8f3-4aa5-94c3-678b74d6a327>\",\"WARC-Concurrent-To\":\"<urn:uuid:c501d137-7ac0-45d6-8ff4-f18ea43ddea2>\",\"WARC-IP-Address\":\"64.90.34.113\",\"WARC-Target-URI\":\"http://www.pawfal.org/fluxus/docs/0.17/en/turtle.html\",\"WARC-Payload-Digest\":\"sha1:W6SV4KDALICF5I3YUXUZYSHVGSFORKDG\",\"WARC-Block-Digest\":\"sha1:R3E5XZHCD25VVDWFBQN5GVYUWXDADPFJ\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-13/CC-MAIN-2019-13_segments_1552912202125.41_warc_CC-MAIN-20190319183735-20190319205735-00448.warc.gz\"}"}