Now the robot is turned to 90° (pi/2). What coordinates are in front of the robot? To the right of the robot? See the following and make sure it makes sense.
Front (1,2)
Right (2,1)
Behind (1,0)
Left (0,1)
Do you notice any patterns in the above results. How do the results change after we rotated the robot? We would like to write an algorthm for the coordinates to the front, right, back, left – for any angle.
Now let’s think about the angle of the robot. See the above image for a reminder about how sin and cos work.
For θ = 0°, what are dirx and diry? (1,0)
For θ = 90°, what are dirx and diry? (0,1)
For θ = 180°, what are dirx and diry? (-1,0)
For θ = 270°, what are dirx and diry? (0,-1)