Handout 5A

The purpose of this exercise is to further explore the question of how many times you should REPEAT the command [FORWARD :SIDE RIGHT :ANGLE] to ensure that the turtle returns to its starting position.

We know that a total turtle turn of 360 is necessary for the turtle to return to its starting place after drawing a figure. By experimenting with commands like REPEAT 5 [FORWARD 50 RIGHT 144] we have seen that we sometimes need a total turn of more than 360 degrees -- in this case the total turtle turn needed to return the turtle to its starting position is 720=2*360.

Consider the following LOGO procedure:

TO PQGON :P :Q :SIDE
 REPEAT :Q [FORWARD :SIDE RIGHT (360 * (:P/:Q))]
END
What does the command PQGON 2 5 50 do? What is the total turtle turn for this command?

Run each of the commands:

PQGON 1 5 50
PQGON 2 5 50
PQGON 3 5 50
PQGON 4 5 50
PQGON 5 5 50
PQGON 0 5 50
Can you predict what pattern will be drawn by each command? What is the total turtle turn in each case?


Clear the screen and try:

PQGON 1 7 50
PQGON 2 7 50
PQGON 3 7 50
PQGON 4 7 50
Do each of the commands do what you expected them to do? How would you describe the difference between the patterns generated by each of these commands?


By now, you have some ideas about what to expect from the PQGON procedure. What do you expect to see when you run the command PQGON 2 6 50? Try it; does it meet your expectations? What is the total turtle turn here? How would you describe this figure when comparing it to the figures drawn by the following commands:

PQGON 1 6 50
PQGON 3 6 50
PQGON 4 6 50
Experiment with the PQGON procedure. Try running it with different inputs. Try adding a WAIT command to the commands repeated by PQGON. When does the turtle retrace its steps? In those cases, how many times does the turtle retrace its path?

What is the smallest value of :N needed to ensure that the following command is state transparent?

REPEAT :N [FORWARD :SIDE RIGHT (360 * (:P/:Q))]

Mtht420