This is a genuine 2D wave simulation, not a flattened version of the 3D ray picture. Each of the N meta-atoms is treated as an independent Huygens point source: it re-radiates a cylindrical wavelet carrying the local phase Φᵢ = k·xᵢ·sinθᵢ + i·Δφ (incident phase at that element, plus the metasurface's own imprinted phase step). The near-field canvas sums every wavelet, amplitude ~1/√r, at each pixel — the steered beam you see is genuine constructive interference, not a drawn arrow.
The far-field strip computes the exact array-factor closed form for a uniform linear phased array of pitch a:
Ψ(θ) = k·a·(sinθᵢ − sinθ) + Δφ
|F(θ)| = |sin(NΨ/2) / sin(Ψ/2)|
Main lobes at Ψ = 2πm:
sinθ_m = sinθᵢ + (λ/2πa)·Δφ − m·(λ/a), m = 0, ±1, ±2, …
The m = 0 lobe is exactly the generalized Snell's law beam from the ray-optics 3D version — same formula, derived here from wave interference instead of Fermat's principle. But a real phased array only samples the ideal continuous phase gradient at discrete points spaced by the pitch a; whenever a isn't much smaller than λ, that undersampling throws power into m ≠ 0 grating lobes spaced by λ/a in sinθ — spurious extra beams no idealized ray tracing shows, and a real design constraint for metasurface engineers (finer pitch → cleaner single-beam steering).
- θᵢ, λ — same incident-beam parameters as the 3D model.
- Δφ per element — phase jump between neighbouring meta-atoms.
- Pitch a/λ — element spacing relative to wavelength; push it toward 1 to watch grating lobes appear in the far-field strip and as a second faint beam in the near field.
- The measured peak angle is a live numerical argmax over the far-field array factor — compared against the m = 0 formula as a running self-check.