Moiré Pattern¶
By the end of this lab you'll be able to:
- Draw two overlapping sets of lines at slightly different angles
- Understand how interference between two grids creates Moiré patterns
- Control the Moiré pattern size by changing the angle difference
When two sets of nearly parallel lines overlap at a slight angle, they produce dramatic interference patterns — large-scale "beating" waves that seem to pulse across the canvas. This is the Moiré effect.
Welcome to Moiré Patterns!
Moiré patterns appear on TV screens when someone wears a checkered shirt —
the screen's pixel grid interferes with the fabric's pattern!
Let's code one ourselves!
How It Works¶
Draw two sets of evenly spaced parallel lines. Set one is horizontal; set two is rotated by a small angle (3°). Where lines from both sets cross, they reinforce; where they diverge, gaps form. The result is a large-scale wave pattern.
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 | |
What Do You Think Will Happen?
Two sets of lines, one rotated only 3° from the other.
Will the slight angle difference be visible as separate lines, or as a beating pattern?
Make your guess — then click Run to find out!
Try It Now¶
A large-scale beating pattern appears — bands of dense and sparse lines alternating across the canvas. Were you right?
How It Works¶
The Moiré period (the distance between "beats") is approximately spacing / sin(angle_difference). With spacing=8 and angle=3°, the beat period ≈ 8 / sin(3°) ≈ 153 pixels. That's why you see about 2 complete "fringes" across the canvas.
Explanation Table¶
| Line | What it does |
|---|---|
spacing = 8 |
Distance between parallel lines |
draw_lines(0) |
First set — horizontal lines |
draw_lines(3) |
Second set — 3° rotation |
math.cos(perpendicular) |
Position of line perpendicular to its direction |
Learning Check¶
Your Turn — Change the Angle
Change draw_lines(3) to draw_lines(10).
A larger angle means a smaller Moiré period — more beats per screen.
Predict: how many bands will appear at 10°?
At 10°, the bands are narrower and more numerous — the Moiré period shrinks as the angle grows.
Experiments¶
-
Use concentric circles. Replace the line sets with two sets of concentric circles with slightly different radii spacings. You'll know it worked when Moiré rings appear.
-
Try 1° difference. Use
draw_lines(0)anddraw_lines(1). You'll know it worked when just 1–2 very wide bands appear (large period). -
Add a third set. Add
draw_lines(6). You'll know it worked when a more complex interference pattern appears. -
Use dot grids instead of lines. Draw dots at a regular grid, then draw a second grid at 3° rotation. You'll know it worked when a hexagonal Moiré pattern appears.
Interference Patterns!
You created a Moiré pattern — the same physics describes light interference,
sound beats, and radio wave mixing. Geometry, optics, and physics in one picture!
Up next: Bridget Riley Waves — undulating parallel curves.