-
Notifications
You must be signed in to change notification settings - Fork 1
Teaching Chapter III
Teacher-facing notes for running Chapter III in class.
| Sections | 9 (1 tutorial, 8 exercises) |
| Estimated time | 2 weeks for a mixed-ability Year 9 class (8 to 10 lessons) |
| Prerequisites | Chapters I and II. Students need comfort with variables and the 360 rule. |
| Live chapter | dbbudd.github.io/03.html |
Students leave able to: write for loops to repeat code a fixed number of times, derive the interior angle formula (n - 2) × 180° from first principles, recognise rotational symmetry in regular polygons, and reason about star polygons using the {n/k} notation and greatest common divisor rule.
The mathematics. Regular polygons as the family of shapes where every side and every angle is equal. The interior angle formula (n - 2) × 180° and its per-vertex version (n - 2) × 180° / n. The exterior angle formula 360° / n. Rotational symmetry and the order of symmetry (a square has order 4, an equilateral triangle has order 3). Star polygons: the {n/k} notation, why the gcd of n and k matters, and why {6/2} degenerates to a triangle traced twice.
The programming. The for loop: for i in 1...n { ... } as a way to repeat a block of code a fixed number of times. The distinction between closed ranges (1...5) and half-open ranges (0..<5). The loop counter as a variable you can use inside the loop body. Nested loops (a loop inside a loop), where the inner loop runs fully for each iteration of the outer. The integer division trap: 360 / 7 is 51 in Swift (Int division truncates) but 360.0 / 7.0 is 51.43 (Double division is exact).
Chapter III is short but dense. Nine sections, but the mathematics is heavier than any other chapter because it introduces the formula that unifies every polygon.
Section 1 (Our First Loop) is the only tutorial and it's the most important page in the chapter. Students see the same code they wrote in Chapter I, then see it rewritten with a loop, and then see the new version doing more with fewer lines. The a-ha moment is "the loop is just 'do this thing five times'."
Sections 2 to 4 (Triangle, Squares, Dashes) are gentle applications: draw shapes they already know, but using loops instead of repeated addLine calls. Dashes is a clever warm-up because it uses a loop to alternate addLine and move calls, reinforcing the pen-up / pen-down distinction from Chapter I.
Section 5 (Regular Polygons) is where the maths gets real. Students derive the exterior angle formula 360° / n from the 360 rule, then use a variable sides to draw any regular polygon with one loop. This section contains the integer division trap (which we fixed during curriculum development): students who write let angle = 360 / sides get an Int result, 51 instead of 51.43, and their heptagon doesn't close. The fix is let angle = 360.0 / Double(sides). Teach this fix as a first-class insight, not a footnote.
Section 6 (Stars) takes loops into star polygon territory. {5/2} works, {7/2} works, {7/3} works, but {6/2} traces a triangle twice. Introduce the gcd rule: a star polygon {n/k} is drawable if and only if gcd(n, k) = 1. This is one of the most satisfying pieces of maths in the whole curriculum.
Section 7 (Something Different) is a free-form exercise where students design their own shape using a loop. Use this as a formative assessment moment.
Sections 8 and 9 (Loop in a Loop, Spirals) introduce nested loops. Nested loops are conceptually hard but Spirals makes them visual: the outer loop runs 20 times, the inner loop grows the shape slightly each iteration, and the result is a square spiral. "Outer ticks slow, inner ticks fast" is the mental model.
The interior angle formula (n - 2) × 180° and its exterior counterpart 360° / n. These two formulas together are the most useful pair in elementary polygon geometry. A student who leaves Chapter III able to derive them from the 360 rule has the tools for almost any regular polygon question they will meet in Year 9, Year 10, and most of Year 11.
Swift's Int division discards the decimal part, so 360 / 7 is 51, not 51.43. A heptagon drawn with 51 degree turns is slightly wrong: the shape almost closes but leaves a tiny gap. Students will often not notice the gap because their turn angle is close enough, and they will assume the shape is correct.
Fix: make the integer division trap a named concept in your lesson on Regular Polygons. Say "this is the Integer Division Trap. Swift gives you a whole number when you divide two whole numbers. To get the decimal answer, you need to cast one to Double: 360.0 / Double(sides)." Write this on the board. Students will remember it because it has a name.
This is true but incomplete. The deeper point is that the loop lets the computer handle the "how many" dynamically, which is why the Regular Polygons exercise uses let sides = 7 and then loops 1...sides. Students sometimes miss this and treat loops purely as text compression.
Fix: in the Regular Polygons exercise, explicitly change sides from 5 to 7 to 12 to 50 while students watch. Each change produces a different shape from the same loop body. Ask: "could you have done that by writing the code out longhand?"
Students can draw {5/2} by looping five times with a 144 degree turn. They can draw {7/3} the same way. Then they try {6/2} and get confused when it draws a triangle traced twice.
Fix: the gcd rule is the explanation, and section 6 introduces it. Walk through the reasoning: a star polygon {n/k} visits every kth vertex until it returns to the start. If n and k share a common divisor, the path will revisit vertices early and you get a degenerate shape (or multiple overlapping simple shapes). {6/2} has gcd 2, so it visits only 3 distinct vertices and traces them twice. {5/2} has gcd 1, so it visits all 5 vertices in a single trip.
Spirals (section 9) is where this bites. A nested loop with outer 20 and inner 5 does 100 iterations total, not 25. The multiplication is obvious once you see it, but students sometimes assume addition.
Fix: use a table on the whiteboard. Column: outer iteration 1, 2, 3, ... Row: inner iteration 1, 2, 3, 4, 5. Shade one cell per iteration. Count the shaded cells. Students see the grid of cells and the multiplication becomes visible.
Before showing the code for Regular Polygons (section 5), have the whole class derive the formula on the whiteboard. Start with "sum of exterior angles equals 360". Ask: "if the polygon has n sides and is regular, how much is each exterior angle?" Wait for a student to say 360 / n. Write it on the board. Then ask: "and the interior angle?" Wait for 180 - 360/n and then simplify to (n - 2) × 180 / n. Only after the derivation do you show the code. The derivation is the point, not the code.
For Stars (section 6), have students draw {5/2}, {7/2}, {7/3}, {8/3}, and {6/2} in quick succession. Four of them work, one doesn't. Let the surprise land. Then introduce the gcd rule as the explanation. This is a moment where the curriculum gives the student a mystery and then gives them the tool to solve it. Don't spoil the mystery by explaining the rule first.
For nested loops, this phrase is the mental model. The outer loop is the minute hand, the inner loop is the second hand. Say it out loud the first time you show a nested loop. Students will repeat it to each other.
Section 5: Regular Polygons. Not because the code is hard, but because three things have to click at once: the derivation of the exterior angle formula, the use of a variable to drive the loop count, and the integer division trap. Any of these three can trip a student up, and if all three fail together, the student decides they don't understand loops.
How to teach it: split it across two lessons. Lesson 1 does the derivation and gets a pentagon drawing. Lesson 2 does the integer division fix and gets a heptagon drawing. Don't try to do both in one lesson if your class is mixed ability.
-
Polygon with a parameterised colour that changes with sides. Use
penColor = .hue(Double(sides) / 12)or similar to make the shape change colour as the number of sides changes. - A sunflower spiral. Use a loop to place dots at angles of the golden ratio. Requires some setup but produces a beautiful phyllotaxis spiral.
- A fractal tree. Technically this needs recursion, not just loops, so it's a preview of Chapter V territory. Some advanced students will love this.
-
A rose curve. Using nested loops and the parametric equations
x = cos(k × angle) × cos(angle),y = cos(k × angle) × sin(angle). Hard but beautiful.
When introducing loops (section 1):
"You're going to write the same line of code several times. That's inefficient. Loops let you say 'do this thing n times' in one instruction. Watch what happens when we rewrite the square from Chapter I using a loop."
When deriving the polygon formulas (section 5):
"Remember our rule from Chapter I? Sum of exterior angles equals 360. If the polygon is regular, every exterior angle is the same, so each one is 360 divided by n. What's the interior angle? It's the supplement. 180 minus 360 over n. Tidy that up and you get n minus 2, times 180, all over n. There's the formula you'll use for the next three years of geometry, and you just derived it yourself."
When teaching the integer division trap:
"Watch this. I'm going to divide 360 by 7 in Swift. What do you think the answer is? (Student: 51 point something.) OK, let's run it. (Shows 51.) Where did the decimal go? (Student: it got rounded off.) Not rounded. Truncated. Swift looks at the two numbers and says 'both are integers, so I'll give you an integer back'. To get the real answer, you have to tell Swift 'treat these as decimals': write 360.0 divided by Double of sides. Now you get 51.43. This is the Integer Division Trap. Remember its name."
When introducing star polygons (section 6):
"You've drawn a five-point star using a loop with five iterations and 144 degree turns. Can you draw a six-point star the same way? Try it. (Students try, get a triangle.) Why did that happen? Because of something called the gcd rule. Let me show you."
Fill this section in after your first classroom run.
- Chapter III on the live site
- Previous: Teaching Chapter II
- Next: Teaching Chapter IV
- Up: Home
Geometry Playground · a Swift Playgrounds curriculum for high school geometry · dbbudd.github.io · built by Daniel Budd