Page:
patterns-animation-Sine-Wave-Interference
Pages
Home
nodes-scriptable-conditioning
nodes-scriptable-empty-latent
nodes-scriptable-image
nodes-scriptable-latent
nodes-scriptable-mask
nodes-scriptable-noise
patterns-Overview
patterns-animation-Mandelbrot-Zoom
patterns-animation-Overview
patterns-animation-Perlin-Noise-Fractal
patterns-animation-Plasma-Effect
patterns-animation-Recursive-Pattern
patterns-animation-Sine-Wave-Interference
patterns-earthbound-Color-Cycling-Gradient
patterns-earthbound-Earthbound-Warping-Distortion
patterns-earthbound-Fractal-Brownian-Motion
patterns-earthbound-HDMA-Scanline-Loop
patterns-earthbound-HDMA-Scanline-Shift
patterns-earthbound-Kaleidoscope-Loop
patterns-earthbound-Moire-Interference-Loop
patterns-earthbound-Moire-Interference
patterns-earthbound-Multi-Layer-Plasma
patterns-earthbound-Overview
patterns-earthbound-Radial-Breathing-Loop
patterns-earthbound-Rotating-Fractal-Loop
patterns-earthbound-Seamless-Plasma-Loop
patterns-mathematical-foundations
patterns-psychedelic-Fractal-Noise-Gradient
patterns-psychedelic-Overview
patterns-psychedelic-Plasma-Color-Cycling
patterns-psychedelic-Scanline-Shift
scriptable-conditioning
scriptable-empty-latent
scriptable-image
scriptable-latent
scriptable-mask
scriptable-noise
No results
2
patterns-animation-Sine-Wave-Interference
Balazs Horvath edited this page 2026-04-18 11:13:07 +02:00
Sine Wave Interference
Torch-based wave interference pattern demonstrating constructive and destructive interference.
Mathematical Formula
I = \sin(k_1 x + \omega_1 t) + \sin(k_2 y + \omega_2 t) + \sin(k_3(x+y)/2 + \omega_3 t)
Where:
k_1, k_2, k_3are spatial frequencies\omega_1, \omega_2, \omega_3are temporal frequencies- Addition creates constructive/destructive interference sine waves with different orientations
- Interference creates complex patterns
- Trigonometric color mapping
How It Works
Wave interference demonstrates how waves interact. When waves overlap, they can reinforce (constructive interference) or cancel (destructive interference), creating complex geometric patterns.
Implementation
import torch
width, height = 512, 512
frames = []
for t in range(30):
x = torch.linspace(0, 4*torch.pi, width)
y = torch.linspace(0, 4*torch.pi, height)
X, Y = torch.meshgrid(x, y, indexing='ij')
# Multiple sine waves with different frequencies
wave1 = torch.sin(X + t/5)
wave2 = torch.sin(Y + t/5)
wave3 = torch.sin((X + Y)/2 + t/5)
# Interference pattern
interference = wave1 + wave2 + wave3
interference = (interference + 3) / 6 # Normalize
# Convert to RGB
rgb = torch.stack([
interference,
torch.sin(interference * torch.pi),
torch.cos(interference * torch.pi)
], dim=-1)
rgb = (rgb + 1) / 2 # Normalize to 0-1
frames.append(rgb)
output_image = torch.stack(frames, dim=0) # Shape: [30, H, W, 3]
Line-by-Line Explanation
interference = wave1 + wave2 + wave3
Additive superposition of three waves.
interference = (interference + 3) / 6
Normalizes from [-3, 3] to [0, 1].
rgb = torch.stack([interference, torch.sin(interference * torch.pi), torch.cos(interference * torch.pi)], dim=-1)
Maps interference to RGB using sine and cosine for color variation.
Customization
More Waves
wave4 = torch.sin((X - Y)/2 + t/5)
interference = wave1 + wave2 + wave3 + wave4
Different Frequencies
wave1 = torch.sin(2*X + t/5) # Tighter
Multiplicative Interference
interference = wave1 * wave2 * wave3 # Moiré effect
References
- See also: Moiré Interference