Spider Web¶
By the end of this lab you'll be able to:
- Draw radial spokes from the center using angles spaced 30° apart
- Connect the spokes with concentric polygonal rings using
goto() - Combine two loop types (radial and ring) to build a complete web
A realistic-looking spider web with 12 radial threads and 6 concentric rings — all drawn with goto() using polar coordinates converted to x, y.
Welcome to the Spider Web!
A spider web uses two geometric ideas: radial lines and concentric rings.
This lab draws both using goto() and the math of circles!
Let's code it together!
How It Works¶
Spokes: for each of 12 angles (0°, 30°, 60°, … 330°), draw a line from the center to radius 120. Rings: for each ring radius (20, 40, 60, 80, 100, 120), visit all 12 spoke intersection points and connect them.
Sample Code¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | |
What Do You Think Will Happen?
We draw 12 spokes and 6 rings. How many polygon sides will each ring have?
Make your guess — then click Run to find out!
Try It Now¶
Each ring is a 12-sided polygon — one side per spoke. With 12 spokes equally spaced, each side spans 30°. Were you right?
How It Works¶
angles[1:] + [angles[0]] visits all 12 spokes then returns to the first — closing each ring polygon. r * math.cos(rad), r * math.sin(rad) converts polar (r, angle) to Cartesian (x, y).
Explanation Table¶
| Line | What it does |
|---|---|
angles = [i * 360 / n_spokes for i in range(n_spokes)] |
12 equally spaced spoke angles |
r = ring * max_r / n_rings |
Ring radius increases evenly outward |
angles[1:] + [angles[0]] |
Visit all spokes, then close the ring |
math.cos(rad), math.sin(rad) |
Convert angle to x, y offset |
Learning Check¶
Your Turn — Add More Spokes
Change n_spokes = 12 to n_spokes = 8. How many polygon sides will each ring have?
Predict, then run it to check!
8 spokes → 8-sided octagonal rings — each ring is now an octagon instead of a 12-sided polygon.
Experiments¶
-
Add a spider. After drawing, place a filled circle at
(30, 30)usingmonty.dot(20, 'black'). You'll know it worked when a spider appears on the web. -
Use concentric circles instead of polygons. Replace the ring-drawing code with
monty.circle(r)at each ring radius. You'll know it worked when the rings look round. -
Color the rings. Create a list of ring colors and use
monty.pencolor(ring_colors[ring]). You'll know it worked when each ring is a different color. -
Make the web asymmetric. Instead of equal spacing, use non-uniform angles. You'll know it worked when the web looks irregular like a real spider web.
Eight-Legged Geometry!
You drew a spider web using only polar coordinates and goto()!
The combination of radial and ring structures appears everywhere in nature and engineering.
Up next: Lightning Bolt — recursive jagged zigzag.