GoalUse a repeat block with a move and a turn to draw triangles and hexagons.
New words
regular shape · a shape with all sides the same length and all corners the sameturn angle · how far the sprite turns at each cornerfull turn · a turn all the way round, which is 360 degrees
Explanation
To draw a regular shape, a sprite does the same two things again and again: it moves one side and then it turns. This is a job for a repeat block. The number in the repeat block is the number of sides. The turn angle depends on the number of sides. All the turns at the corners add up to one full turn, 360 degrees, so the turn angle is 360 divided by the number of sides. A triangle has 3 sides and turns 120 degrees. A hexagon has 6 sides and turns 60 degrees. When the loop is finished, the sprite is back at its start place and faces the way it started.
Sides
Shape
Turn angle
3
triangle
360 ÷ 3 = 120
4
square
360 ÷ 4 = 90
5
pentagon
360 ÷ 5 = 72
6
hexagon
360 ÷ 6 = 60
8
octagon
360 ÷ 8 = 45
Worked examples
This script draws a triangle with sides of 80 steps. The repeat number is 3 and each turn is 120 degrees. The sprite sets its direction to 90 first, so it always begins facing right.
A hexagon with sides of 60 steps: repeat (6), move (60) steps and turn ↻ (60) degrees. The pen line has six equal sides, and the end of the sixth side meets the start.
This is the triangle the script above draws. The sprite moves right first, then turns 120 degrees at each corner. Three turns of 120 degrees make 3 × 120 = 360 degrees, one full turn, so the sprite ends at its start, facing right again.
Class activity
Quarter-turn walk (with family): put a piece of tape on the floor and stand on it, facing a wall. Walk the algorithm “repeat 4 times: take 3 steps, turn right a quarter turn”. Where do you finish, and which way do you face? Now do only 3 trips instead of 4. Are you back at the tape? Why not? If you have a computer or tablet, build the triangle script and then change repeat (3) to repeat (4). Does the shape close?
Practice
1
What turn angle draws a regular shape with 10 sides?
36 degrees (360 ÷ 10).
2
Write the loop that draws an octagon with sides of 30 steps.