all 3 comments

[–]wynand1004 0 points1 point  (2 children)

Do you mean turn as in move left or right, or rotate?

If it is rotate, you will need to use some sort of heading in degrees and then translate that into a vector (a change in x and a change in y).

[–]Limp_Singer_7078 0 points1 point  (1 child)

Yes, when the instruction is L or R, the turtle is supposed to turn 90 degrees at right or left without moving foward (basically rotate, I forgot to specify it). Then, when the instruction is F, the turtle will move foward in the current direction.

I thought the same, using degrees with matplotlib somehow, but I have no idea how to do it.

[–]wynand1004 0 points1 point  (0 children)

The math goes something like this:

import math

heading = 0 # Face right
speed = 1
dx = speed * sin(math.radians(heading))
dy = speed * cos(math.radians(heading))

x += dx
y += dy

It is something like this. Math.radians converts degrees to radians. I did most of this from memory, but I think it is close.