Set
heading block
We
have been moving the turtle around the screen by using the direction
commands: Forward, Backward, left and Right. There are two other ways
to move the turtle around and they are headings and coordinates
commands. These commands are found in the 'Turtle' palette
Set
heading Command:
Set
heading command is used to change the direction of the turtle's head
to the prescribed
angle. The angle can be determined as as given below:
Instead
of giving the command 'Right 45 - forward 100 - turn left 45, we can
also
say 'set heading 45 – forward 100 – set heading 0' as below. Both
the commands gives the same output
Though
'set heading' can be used to move the turtle in the similar way, it
doesn't behave as right and left. In the above command 'set heading
0' is used instead of 'left 45'. While using 'set heading' the
direction in which the head turns depends on the angle given, whereas
'right' and 'left' commands clearly define the direction to turn. The
angle can also be given in anticlockwise direction as below:
'set
heading
330' and 'set heading -30' will give the same output. This command is
more useful when polar coordinates are used.
No comments:
Post a Comment