Lévy C Curve¶
By the end of this lab you'll be able to:
- Implement the Lévy C Curve using the same recursive structure as the Koch curve but with 45° angles
- Compare how different replacement angles produce completely different fractal shapes
- Understand how a fractal can tile the plane — the Lévy curve packs into itself perfectly
Each line segment is replaced by two equal segments forming a right-angled peak. After 14 iterations, the curve packs into a shape resembling a dragon's wing or a crinkled leaf.
Welcome to the Lévy C Curve!
You already know the Koch curve uses 60° bumps. The Lévy C uses 45° bumps —
one small change that produces a completely different, tile-able fractal!
Let's code it together!
How It Works¶
levy(n, depth):
- If depth == 0: draw a line of length n
- Otherwise: turn left 45°, recurse with n / √2, turn right 90°, recurse with n / √2, turn left 45°
The key difference from Koch: both recursive calls go in the same direction, making an upward peak. The angle is 45° instead of 60°.
Sample Code¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | |
What Do You Think Will Happen?
The Koch curve bumps outward in a triangle. The Lévy uses 45° bumps.
Will the overall shape look more like a snowflake or a cloud?
Make your guess — then click Run to find out!
Try It Now¶
More like a cloud or wing — the asymmetric 45° packing creates an irregular silhouette rather than a symmetric snowflake. Were you right?
How It Works¶
Each segment becomes two segments of length n / √2. Since (n/√2)^2 + (n/√2)^2 = n^2, the two sub-segments form a right isoceles triangle with hypotenuse n — the original segment length is preserved geometrically.
The repeated peak replacements pack densely without crossing — the Lévy C curve tiles the plane when copies are placed correctly.
Explanation Table¶
| Line | What it does |
|---|---|
n / math.sqrt(2) |
Sub-segment length by Pythagorean theorem |
monty.left(45) |
First rotation — forms the left leg of the peak |
monty.right(90) |
Turn between the two sub-segments |
monty.left(45) |
Restore original heading after the peak |
depth == 0 |
Base case: draw a raw segment |
Learning Check¶
Your Turn — Try Depth 8
Change levy(320, 14) to levy(320, 8). The curve will be much less detailed.
Predict what it will look like at only 8 levels of substitution — then run it!
At depth 8 you can clearly see the individual V-shapes before they pack together. The full shape is recognizable but coarser.
Experiments¶
-
Change the color. Try
pencolor('darkviolet'). You'll know it worked when the curve turns purple. -
Use Koch comparison. Try the Koch rule (
left(60), noright, etc.) on the same starting length to compare. You'll know it worked when you see the Koch shape instead. -
Thicker pen. Add
monty.pensize(2)before the levy call. You'll know it worked when the curve lines are thicker and easier to see. -
Flip the curve. Start facing South (
monty.setheading(270)) and adjust the starting position. You'll know it worked when the curve hangs downward like a stalactite.
Fractal Wings!
You changed one angle (60° → 45°) and got a completely different fractal!
That's the power of parametric thinking — small changes, huge impact.
Up next: Gosper Curve — a fractal that tiles hexagonal space.