Set turtle's heading vector

setheaddir vector

Sets the new heading to the vector specified as a 2-element array or list. This direction is used by the forward and back instructions. Turtle's heading direction is always a unit vector, however vector in the argument can be of any length.
Note: setheading instruction can be used to set heading in degrees.

Example:

repeat 8 [
  setheaddir array sin 45 * repcount cos 45 * repcount
  (print heading headdir)
  fd 30
]

Output:
(also a drawing)

45 {0.707106781186547 0.707106781186548}
90 {1 6.12303176911189E-17}
135 {0.707106781186548 -0.707106781186547}
180 {1.22460635382238E-16 -1}
-135 {-0.707106781186547 -0.707106781186548}
-90 {-1 -1.83690953073357E-16}
-45 {-0.707106781186548 0.707106781186547}
0 {-2.44921270764475E-16 1}

See also:

Table of Content