import { probs, stateAngle, type State1 } from "../../lib/quantumToy"; /** * The learn track's honest Bloch slice — a FULL circle replacing the * step-0 semicircular Dial wherever the sign (phase) matters. The * needle is the current state's point on the X–Z great circle * (lib/quantumToy.ts stateAngle: |0⟩ top, |+⟩ right, |1⟩ bottom, * |−⟩ left — global sign already modded out, so the needle shows * physical states only). The side points carry plain-language labels * ("fifty-fifty, plus-way" / "fifty-fifty, minus-way"). * * THE KEY VISUAL is the shadow: a thin projection line drops the * needle tip onto the vertical (0–1) axis, and the % labels along * that axis are the measurement odds — p(1) = (1 − cos θ)/2. Two * different points (right and left) cast the SAME 50/50 shadow; * that near-collision is the phase step's whole argument, and the * reason the dial's semicircle was only a first approximation. * * Read-only by design (gates move it, fingers don't — the honest * contrast to the step-0 dial: you can PREPARE any lean, but the * hidden direction is only reachable through gates here). `snapped` * mirrors the Dial's measurement-collapse idiom: the needle briefly * points at the outcome pole (warn tip, ~200ms transition) while the * shadow keeps showing the state's odds underneath. */ export function CircleState({ state, snapped = null, size = 180, label, }: { state: State1; snapped?: 0 | 1 | null; /** Rendered width in px (height follows the 260:224 viewBox). */ size?: number; /** Optional caption under the circle (e.g. "end of the wire"). */ label?: string; }) { const theta = stateAngle(state); // 0 top → clockwise const deg = (theta * 180) / Math.PI; const p = probs(state); const p0 = Math.round(p[0] * 100); const p1 = Math.round(p[1] * 100); const cx = 130; const cy = 112; const r = 76; const rn = 62; // needle length const tipX = cx + rn * Math.sin(theta); const tipY = cy - rn * Math.cos(theta); const shadowY = cy - rn * Math.cos(theta); const shownDeg = snapped == null ? deg : snapped === 0 ? 0 : 180; const dir = p1 <= 2 ? "at 0 (top)" : p1 >= 98 ? "at 1 (bottom)" : theta < Math.PI ? p1 === 50 ? "at fifty-fifty, plus-way (right)" : "on the right half" : p1 === 50 ? "at fifty-fifty, minus-way (left)" : "on the left half"; return (