# Demo — AoA Accuracy Explorer

A phase interferometer turns the wavefront's tilt into a bearing. Stretch the baseline and the bearing sharpens — but past a half-wavelength the phase wraps, and the naive estimate snaps to a confidently wrong angle. This demo lets you walk that accuracy–ambiguity trade directly.

## The relation

$$
\Delta\phi = \frac{2\pi d}{\lambda}\,\sin\theta
\qquad\Longrightarrow\qquad
\theta = \arcsin\!\left(\frac{\lambda\,\Delta\phi}{2\pi d}\right).
$$

A phase meter only reads $\Delta\phi$ modulo $2\pi$, so unambiguous coverage across $\pm 90^\circ$ requires $d \le \lambda/2$ — a short, coarse baseline.

## Interactive demo

<a class="demo-fullscreen" href="../_static/demos/AoAAccuracyExplorer.html" target="_blank" rel="noopener">Open in full screen</a>

<div class="demo-wrap">
<iframe src="../_static/demos/AoAAccuracyExplorer.html"
        title="Interactive interferometric AoA accuracy explorer"
        width="100%"
        loading="lazy">
</iframe>
</div>

## Walkthrough

1. **Start short.** With $d \le \lambda/2$ the ambiguity flag is green and the estimate tracks the true bearing — but coarsely; raise the noise (lower SNR) and the error swings widely.
2. **Stretch the baseline.** Increase $d$ and watch the estimate tighten against the same noise — a fixed phase error maps to a smaller angle error as $d/\lambda$ grows.
3. **Cross the half-wavelength.** When $d > \lambda/2$ the flag turns red. On the phase plot you can see several bearings now share one wrapped reading, and the naive estimate jumps to the wrong one.
4. **Read the polar plot.** The navy ray (truth) and red ray (estimate) agree at short baselines and diverge dramatically once the long baseline wraps.

## Key observations

- **Accuracy wants a long baseline; unambiguity wants a short one.** No single pair gives both.
- **Multi-baseline buys both** — the short pair picks the $2\pi$ cycle, the long pair sets the precision. That is the resolution the type-along implements.
- **Amplitude comparison never wraps** because it reads a monotone power ratio, not a periodic phase — it trades that safety for poor accuracy.

## Source

<a class="matlab-link" href="../_static/downloads/ECE%20495%20EW%20%E2%80%93%20Code.zip#code/L13_InterferometricAoA.m" download><svg viewBox="0 0 22 22" width="14" height="14" aria-hidden="true" style="vertical-align:-2px;margin-right:6px;"><rect width="22" height="22" rx="3" fill="#e87722"/><text x="11" y="15.5" text-anchor="middle" font-family="'Inter',sans-serif" font-size="9" font-weight="800" fill="#fff" letter-spacing="-0.04em">MAT</text></svg><span class="ml-text">MATLAB · code/L13_InterferometricAoA.m</span><span class="ml-arrow">↓</span></a>

The in-class script turns a true AoA into the phase across a short and a long baseline, shows the long baseline wrapping, and uses the short baseline to unwrap it into a fine, correct bearing.
