]> gitweb.factorcode.org Git - factor.git/blob - unmaintained/turtle/turtle.factor
Remove 'unmaintained/lsys'
[factor.git] / unmaintained / turtle / turtle.factor
1
2 USING: kernel math arrays math.vectors math.matrices generic.lib pos ori ;
3
4 IN: turtle
5
6 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7
8 TUPLE: turtle ;
9
10 : <turtle> ( -- turtle )
11 turtle new
12 { 0 0 0 } clone <pos>
13 3 identity-matrix <ori>
14 rot
15 3array chain ;
16
17 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
18
19 : reset-turtle ( -- ) { 0 0 0 } >pos 3 identity-matrix >ori ;
20
21 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
22
23 : step-vector ( length -- array ) { 0 0 1 } n*v ;
24
25 : step-turtle ( length -- ) step-vector ori> swap m.v pos> v+ >pos ;
26
27 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
28
29 : strafe-up ( length -- )
30 90 pitch-up
31 step-turtle
32 90 pitch-down ;
33
34 : strafe-down ( length -- )
35 90 pitch-down
36 step-turtle
37 90 pitch-up ;
38
39 : strafe-left ( length -- )
40 90 turn-left
41 step-turtle
42 90 turn-right ;
43
44 : strafe-right ( length -- )
45 90 turn-right
46 step-turtle
47 90 turn-left ;