Interactive 2D wave optics simulator. Turn any image into a refractive scene, add sources, watch waves refract, diffract and interfere. Probes, intensity maps, video export.
C#
Merge Jeroen's optical logic gates and zone plate into master
Alexander Graefe96ce83d59e9
diff --cc CLAUDE.mdindex 0c3a13a,72f186a..3bac2cb--- a/CLAUDE.md+++ b/CLAUDE.md@@@ -202,15 -189,40 +202,48 @@@ FrameStore: native memory up to the budwhole pixels). A part edit is a simulation edit. Tree folder "Parts", "+ Part" opens a menu of kinds (Space, arrows,Enter), a handle plus a rotation lever on the pictures; while selected, the outline as painted in the accent colour,a size grip on a corner or vertex (rectangle, lens, polygon, triangle, GRIN, Bragg) and a handle per point of an outline- or fibre (2026-10-19); the shape shows through the glowing outline otherwise.+ (2026-10-19); the shape shows through the glowing outline otherwise. **A fibre's path** (2026-10-22, the user's request,+ replacing the polyline with its sharp bends) is a chain of cubic Bézier segments through `FiberNode`s, each with an in and an+ out handle as offsets (ints, `<Node X Y InX InY OutX OutY Smooth>`): on the pictures a node handle plus its two handles on+ dotted lines, a smooth node (default) lined up when switched on (`FiberPart.AlignNode`, zero handles seeded from the+ neighbours) and turning the other handle with the one moved or typed, keeping its length (captured at the drag's start, so+ rounding does not creep in; a node added or loaded is taken as it is), a corner node free; the pane lists each node with both handles; "Add node"+ continues the path. The ends are `Ends` Flat (default: cut across the curve's tangent at the endpoint, the coating+ following the face) or Round. The painter flattens the curve into chords (0.05 px) bucketed on a 32 px cell grid, and the+ core edge is supersampled (`HasInnerEdges`).+ - **Optical logic** (2026-10-21/22, "+ Part" > Optical logic): `LogicGatePart` with `XorGatePart`, `AndGatePart`,+ `OrGatePart` (elements `XorGate`, `AndGate`, `OrGate`), one 2 × 2 directional coupler whose phase shift of B over A+ alone makes the kind: +90° upper a − b (XOR), −90° upper a + b (AND, 4 : 1 at best, a passive linear gate has no truer+ AND), +30° upper at 120° (OR: ½, ½, ½); the phase section sits in a quarter-period stretch in all three, so they share+ dimensions and ports (measured 120 × 544 px: XOR 0.01, AND 1.88 against 0.50, OR 0.49 against 0.55). Laid out by+ `LogicGateDesign` from the design frequency with `WaveguideModes`, a mode solver on the+ engine's own discrete equations (4th-order stencil, its β matches a simulated guide to 1e-5); smooth S-bends whose radius+ follows the mode's confinement, a measured coupling excess of 0.07 rad taken off, the cladding's rim and the input ends+ absorb (`PartShape.AbsorptionShareAt`). The user's choices of 2026-10-22: the design is entered as a source frequency+ (`DesignFrequency`, default 50; the wavelength is shown, from `Simulation.SourceFrequencyScale`, which the follower hands+ each gate as `FrequencyScale`); both ends carry an AR band like a lens's (`Coating`, √n of core and cladding, default 6 px,+ the measured least reflection, 3.4 % against 24 % bare), which replaced an output taper, switchable per end+ (`InputCoated`, `OutputCoated`, default on; 2026-10-22, the user found a band in a junction keeps the wave from passing+ from one unit into the next); each output can be switched off- (`XorOutputActive`, `SumOutputActive`), an absorber rising over 2 λ in its arm's last stretch (0.03 % reflected, nothing++ (`UpperOutputActive`, `LowerOutputActive`), an absorber rising over 2 λ in its arm's last stretch (0.03 % reflected, nothing+ out). The unit is twice the port spacing wide, ports at ¼ and ¾ (the user's request, 2026-10-22, for staggered tiling):+ the side absorber fills out to there, at least λ/2 (none let 7.6 % through to the XOR output). Defaults core 2.55 in+ 1.45, the phase section then lowered on arm A: spacing 60, 120 × 544 px, both inputs leave about 1 % at the XOR output,+ sum 1.9× (the user found 1600 px unacceptable). Both ends are open (2026-10-22, the user's choice: the input termination+ is gone, sources are to be coupled in from outside by a fibre later), so staggered gates cascade; a source placed in the+ unit sits half a wavelength in, and its backward wave leaves through the coated input end. The port spacing is raised to the design's minimum; the form's box edits+ `PortSpacingUsed`, so it shows the spacing used and every step moves the ports. Inputs are ordinary sources on the ports+ the form lists; `GatePortFollower` (the window keeps one per project) moves a source within 1 px of an input onto the+ input's new position after any gate edit, and `Movable.MoveAll` moves parts last so a group move does not move it twice.+ - **Zone plate** (2026-10-22, a main part beside the lens, element `ZonePlate`): `ZonePlatePart`, Fresnel zones at+ rₙ = √(nλf + (nλ/2)²) from a target frequency (`IFrequencyDesigned`, the follower hands it the frequency scale) and focal+ length, every second zone an absorbing block (the user's choice over mirror or phase blocks; blue only, `PaintsIndex`+ false), `Inverse` exchanging them; blocks 96 rising over the AR depth from the faces, sharp at the sides (measured: 0.4 %+ through, 1.0 % back at 64 px thick with a 32 px rise). In 2D a zone plate is cylindrical: the central zone dominates+ (Cornu spiral), so the inverse plate focuses weakly (about 1 × the free wave); the default plate (800, f 600, 8 zones)+ 4.6 ×. Light passing outside the diameter pushes the focus on (5 zones +30 %, 8 zones +3 %); the optional absorbing+ `Mount` (`MountWidth` either side, default off and 200 px, the user's request) stops it (5 zones: +12 % in the check's+ small canvas, +6 % in a wide one).- File types `.wdproj` / `.wdscheme` are registered per user at start-up; unsaved edits ask on close.## Numbers (workstation: 10-core Xeon without AVX2, RTX 2080, 64 GB)@@@ -226,7 -238,7 +259,7 @@@ numbers: no GPU JPEG, no OpenCL colouri## Harnesses- `library_check` (100+ checks: engines, store, renderer, schemes, probes, scratch, reduced preview, importer, export, parts, group move, open edges, ranges).-`library_check` (100+ checks: engines, store, renderer, schemes, probes, scratch, reduced preview, importer, export, parts, group move, open edges, XOR gate).++`library_check` (100+ checks: engines, store, renderer, schemes, probes, scratch, reduced preview, importer, export, parts, group move, open edges, ranges, XOR gate).UI, all on `Common.ps1`, with their check counts: `PreviewCheck` 43, `RunCheck` 71, `LanguageCheck` 11,`ProbeGraphCheck` 39, `ImportCheck` 10, `ExportCheck` 38, `PreviewQualityCheck` 35, `SceneImageCheck` 8,`ColorPickerCheck` 13, `KeyboardCheck` 13, `AboutCheck` 18, `SelectionCheck` 10. Test projects `tiny*.wdproj` sit beside them. A harnessdiff --cc WaveDudeNext.WPF/Controls/SceneOverlay.csindex 0814448,542d38b..dbcd872--- a/WaveDudeNext.WPF/Controls/SceneOverlay.cs+++ b/WaveDudeNext.WPF/Controls/SceneOverlay.cs@@@ -565,30 -529,10 +565,30 @@@ public sealed class SceneOverlay : Pane_ => null,};+ /// <summary>The fibre node a node or Bézier handle stands on, or null for another handle or an index past the list.</summary>+ private static FiberNode? NodeOf(MarkerThumb thumb) =>+ thumb.Item is FiberPart fiber && thumb.Index >= 0 && thumb.Index < fiber.Nodes.Count ? fiber.Nodes[thumb.Index] : null;++ /// <summary>The length of the other Bézier handle of the node a handle thumb stands on, which a smooth node keeps while that handle turns; null for another thumb.</summary>+ private static double? MirrorLengthOf(MarkerThumb thumb)+ {+ if (thumb.Role is not (MarkerRole.FiberIn or MarkerRole.FiberOut) || NodeOf(thumb) is not { } node)+ {+ return null;+ }+ (int dx, int dy) = thumb.Role == MarkerRole.FiberOut ? (node.InX, node.InY) : (node.OutX, node.OutY);+ return Math.Sqrt((double)dx * dx + (double)dy * dy);+ }++ /// <summary>Whether a handle is shown for the current item alone: a rotation handle, a grip, a point, node or Bézier handle.</summary>+ private static bool IsDetail(MarkerRole role) => role is MarkerRole.SourceAngle or MarkerRole.PartAngle || HasCanvasPosition(role);++ /// <summary>Whether a handle sits on a continuous canvas position of its own (<see cref="CanvasOf"/>): a grip, a point, node or Bézier handle.</summary>+ private static bool HasCanvasPosition(MarkerRole role) => role is MarkerRole.PartGrip or MarkerRole.PartPoint or MarkerRole.FiberIn or MarkerRole.FiberOut;+/// <summary>- /// Where a part's size grip sits in the part frame: the corner of a rectangle or an ellipse's box, lens (thickness, diameter), GRIN lens- /// or Bragg stack, the first vertex of a polygon, the second end of a triangle's base; null for a kind without one.+ /// Where a part's size grip sits in the part frame: the corner of a rectangle or an ellipse's box, lens (thickness, diameter), GRIN lens,+ /// Bragg stack or zone plate, the first vertex of a polygon, the second end of a triangle's base; null for a kind without one./// </summary>private static (double X, double Y)? GripOf(OpticalPart part) => part switch{diff --cc WaveDudeNext.WPF/Strings/Strings.DE.xamlindex 7774d2d,f42e6ed..4163982--- a/WaveDudeNext.WPF/Strings/Strings.DE.xaml+++ b/WaveDudeNext.WPF/Strings/Strings.DE.xaml@@@ -269,10 -271,28 +274,29 @@@ version. It is distributed WITHOUT ANY<s:String x:Key="SectionCore">Kern</s:String><s:String x:Key="SectionCladding">Mantel</s:String><s:String x:Key="SectionLayers">Schichten</s:String>+ <s:String x:Key="SectionDesign">Entwurf</s:String>+ <s:String x:Key="SectionLayout">Aufbau</s:String>+ <s:String x:Key="SectionPorts">Anschlüsse</s:String>+ <s:String x:Key="SectionOutputs">Aktive Ausgänge</s:String>+ <s:String x:Key="TipGateWavelength">Die Wellenlänge, die die Entwurfsfrequenz in einem Medium mit Index 1 ergibt, bei der Quellfrequenzskala der Simulation</s:String>+ <s:String x:Key="LabelQuarterWave">Viertelwellen-Schicht</s:String>+ <s:String x:Key="TipQuarterWave">Die Dicke der am wenigsten reflektierenden Schicht auf dem Kern, λ / (4 √n)</s:String>+ <s:String x:Key="LabelCoreWidth">Kernbreite</s:String>+ <s:String x:Key="LabelCouplerGap">Koppelspalt</s:String>+ <s:String x:Key="LabelCouplerLength">Koppellänge</s:String>+ <s:String x:Key="LabelGateLength">Gesamtlänge</s:String>+ <s:String x:Key="TipGateLayout">Aus der Entwurfswellenlänge und den Indizes mit der eigenen Wellengleichung des Simulators berechnet (dem Laplace-Operator 4. Ordnung)</s:String>+ <s:String x:Key="LabelInputA">Eingang A</s:String>+ <s:String x:Key="LabelInputB">Eingang B</s:String>+ <s:String x:Key="TipGatePorts">Canvas-Pixel. Die Eingänge mit gleichen Wellen speisen (gleiche Frequenz, Amplitude und Phase); eine fehlende Welle ist eine logische 0. Die Ausgänge liegen auf den Eingängen von Gattern, die einen Anschlussabstand höher und tiefer eine Länge weiter stehen</s:String>+ <s:String x:Key="SectionZones">Zonen</s:String>+ <s:String x:Key="LabelZoneCount">Anzahl der Zonen</s:String>+ <s:String x:Key="LabelOuterZone">Äußerste Zone</s:String>+ <s:String x:Key="TipZones">Die Zonen, die die Platte innerhalb ihres Durchmessers bekommt, und die Breite der äußersten ganzen Zone, die das Gitter auflösen muss (mindestens einige Pixel)</s:String><s:String x:Key="SectionPoints">Punkte</s:String>+ <s:String x:Key="SectionNodes">Knoten</s:String><s:String x:Key="HintPolygonPoints">Eckpunkte des Umrisses relativ zum Mittelpunkt, vor der Drehung. Leer: das regelmäßige Polygon oben wird verwendet.</s:String>- <s:String x:Key="HintFiberPoints">Stützpunkte des Pfads relativ zum Mittelpunkt, vor der Drehung.</s:String>+ <s:String x:Key="HintFiberNodes">Knoten des Pfads relativ zum Mittelpunkt, vor der Drehung, jeder mit dem Eingangs- und Ausgangsgriff der dort zusammentreffenden Segmente als Versatz vom Knoten. Weniger als zwei Knoten zeichnen nichts.</s:String><s:String x:Key="ButtonAddPoint">Punkt hinzufügen</s:String><s:String x:Key="TipAddPoint">Punkt nach dem letzten anfügen</s:String><s:String x:Key="TipRemovePoint">Diesen Punkt entfernen</s:String>@@@ -664,8 -698,10 +726,12 @@@<s:String x:Key="Enum.PartKind.Fiber">Faser</s:String><s:String x:Key="Enum.PartKind.BraggReflector">Bragg-Reflektor</s:String><s:String x:Key="Enum.PartKind.GrinLens">GRIN-Linse</s:String>+ <s:String x:Key="Enum.FiberEnds.Flat">Flach</s:String>+ <s:String x:Key="Enum.FiberEnds.Round">Rund</s:String>+ <s:String x:Key="Enum.PartKind.XorGate">XOR-Gatter</s:String>+ <s:String x:Key="Enum.PartKind.AndGate">AND-Gatter</s:String>+ <s:String x:Key="Enum.PartKind.OrGate">OR-Gatter</s:String>+ <s:String x:Key="Enum.PartKind.ZonePlate">Zonenplatte</s:String><s:String x:Key="Enum.TriangleType.Equilateral">Gleichseitig</s:String><s:String x:Key="Enum.TriangleType.RightIsosceles">Rechtwinklig-gleichschenklig (45°)</s:String><s:String x:Key="Enum.TriangleType.ThirtySixtyNinety">30-60-90</s:String>diff --cc WaveDudeNext.WPF/Strings/Strings.EN.xamlindex 19c5666,46c565e..5f16ca3--- a/WaveDudeNext.WPF/Strings/Strings.EN.xaml+++ b/WaveDudeNext.WPF/Strings/Strings.EN.xaml@@@ -271,10 -273,28 +276,29 @@@ version. It is distributed WITHOUT ANY<s:String x:Key="SectionCore">Core</s:String><s:String x:Key="SectionCladding">Cladding</s:String><s:String x:Key="SectionLayers">Layers</s:String>+ <s:String x:Key="SectionDesign">Design</s:String>+ <s:String x:Key="SectionLayout">Layout</s:String>+ <s:String x:Key="SectionPorts">Ports</s:String>+ <s:String x:Key="SectionOutputs">Outputs active</s:String>+ <s:String x:Key="TipGateWavelength">The wavelength the design frequency gives in a medium of index 1, with the simulation's source frequency scale</s:String>+ <s:String x:Key="LabelQuarterWave">Quarter-wave coating</s:String>+ <s:String x:Key="TipQuarterWave">The thickness of the least reflecting coating on the core, λ / (4 √n)</s:String>+ <s:String x:Key="LabelCoreWidth">Core width</s:String>+ <s:String x:Key="LabelCouplerGap">Coupler gap</s:String>+ <s:String x:Key="LabelCouplerLength">Coupler length</s:String>+ <s:String x:Key="LabelGateLength">Total length</s:String>+ <s:String x:Key="TipGateLayout">Computed from the design wavelength and the indices with the simulator's own wave equation (the 4th-order Laplacian)</s:String>+ <s:String x:Key="LabelInputA">Input A</s:String>+ <s:String x:Key="LabelInputB">Input B</s:String>+ <s:String x:Key="TipGatePorts">Canvas pixels. Feed the inputs with equal waves (the same frequency, amplitude and phase); a missing wave is a logical 0. The outputs line up with the inputs of gates set a port spacing above and below, one length on</s:String>+ <s:String x:Key="SectionZones">Zones</s:String>+ <s:String x:Key="LabelZoneCount">Number of zones</s:String>+ <s:String x:Key="LabelOuterZone">Outermost zone</s:String>+ <s:String x:Key="TipZones">The zones the plate gets within its diameter, and the width of the outermost whole one, which the grid must resolve (a few pixels at least)</s:String><s:String x:Key="SectionPoints">Points</s:String>+ <s:String x:Key="SectionNodes">Nodes</s:String><s:String x:Key="HintPolygonPoints">Vertices of the outline relative to the centre, before rotation. Empty: the regular polygon above is used.</s:String>- <s:String x:Key="HintFiberPoints">Vertices of the path relative to the centre, before rotation.</s:String>+ <s:String x:Key="HintFiberNodes">Nodes of the path relative to the centre, before rotation, each with the in- and out-handle of the segments meeting there, as offsets from the node. Fewer than two nodes paint nothing.</s:String><s:String x:Key="ButtonAddPoint">Add point</s:String><s:String x:Key="TipAddPoint">Append a point after the last one</s:String><s:String x:Key="TipRemovePoint">Remove this point</s:String>@@@ -666,8 -700,10 +728,12 @@@<s:String x:Key="Enum.PartKind.Fiber">Fibre</s:String><s:String x:Key="Enum.PartKind.BraggReflector">Bragg reflector</s:String><s:String x:Key="Enum.PartKind.GrinLens">GRIN lens</s:String>+ <s:String x:Key="Enum.FiberEnds.Flat">Flat</s:String>+ <s:String x:Key="Enum.FiberEnds.Round">Round</s:String>+ <s:String x:Key="Enum.PartKind.XorGate">XOR gate</s:String>+ <s:String x:Key="Enum.PartKind.AndGate">AND gate</s:String>+ <s:String x:Key="Enum.PartKind.OrGate">OR gate</s:String>+ <s:String x:Key="Enum.PartKind.ZonePlate">Zone plate</s:String><s:String x:Key="Enum.TriangleType.Equilateral">Equilateral</s:String><s:String x:Key="Enum.TriangleType.RightIsosceles">Right isosceles (45°)</s:String><s:String x:Key="Enum.TriangleType.ThirtySixtyNinety">30-60-90</s:String>diff --cc WaveDudeNext.WPF/Strings/Strings.FR.xamlindex 417d7c2,3da68c8..98eb441--- a/WaveDudeNext.WPF/Strings/Strings.FR.xaml+++ b/WaveDudeNext.WPF/Strings/Strings.FR.xaml@@@ -269,10 -271,28 +274,29 @@@ version. It is distributed WITHOUT ANY<s:String x:Key="SectionCore">Cœur</s:String><s:String x:Key="SectionCladding">Gaine</s:String><s:String x:Key="SectionLayers">Couches</s:String>+ <s:String x:Key="SectionDesign">Conception</s:String>+ <s:String x:Key="SectionLayout">Disposition</s:String>+ <s:String x:Key="SectionPorts">Ports</s:String>+ <s:String x:Key="SectionOutputs">Sorties actives</s:String>+ <s:String x:Key="TipGateWavelength">La longueur d'onde que donne la fréquence de conception dans un milieu d'indice 1, avec l'échelle de fréquence des sources de la simulation</s:String>+ <s:String x:Key="LabelQuarterWave">Traitement quart d'onde</s:String>+ <s:String x:Key="TipQuarterWave">L'épaisseur du traitement le moins réfléchissant sur le cœur, λ / (4 √n)</s:String>+ <s:String x:Key="LabelCoreWidth">Largeur du cœur</s:String>+ <s:String x:Key="LabelCouplerGap">Écart du coupleur</s:String>+ <s:String x:Key="LabelCouplerLength">Longueur du coupleur</s:String>+ <s:String x:Key="LabelGateLength">Longueur totale</s:String>+ <s:String x:Key="TipGateLayout">Calculé à partir de la longueur d'onde de conception et des indices avec l'équation d'onde du simulateur lui-même (le laplacien du 4e ordre)</s:String>+ <s:String x:Key="LabelInputA">Entrée A</s:String>+ <s:String x:Key="LabelInputB">Entrée B</s:String>+ <s:String x:Key="TipGatePorts">Pixels du canevas. Alimentez les entrées avec des ondes identiques (même fréquence, amplitude et phase) ; une onde absente est un 0 logique. Les sorties tombent sur les entrées des portes placées un écart de ports plus haut et plus bas, une longueur plus loin</s:String>+ <s:String x:Key="SectionZones">Zones</s:String>+ <s:String x:Key="LabelZoneCount">Nombre de zones</s:String>+ <s:String x:Key="LabelOuterZone">Zone la plus externe</s:String>+ <s:String x:Key="TipZones">Les zones que la lame reçoit dans son diamètre, et la largeur de la dernière zone entière, que la grille doit résoudre (au moins quelques pixels)</s:String><s:String x:Key="SectionPoints">Points</s:String>+ <s:String x:Key="SectionNodes">Nœuds</s:String><s:String x:Key="HintPolygonPoints">Sommets du contour par rapport au centre, avant rotation. Vide : le polygone régulier ci-dessus est utilisé.</s:String>- <s:String x:Key="HintFiberPoints">Sommets du trajet par rapport au centre, avant rotation.</s:String>+ <s:String x:Key="HintFiberNodes">Nœuds du trajet par rapport au centre, avant rotation, chacun avec les poignées d'entrée et de sortie des segments qui s'y rejoignent, en décalage par rapport au nœud. Moins de deux nœuds ne peignent rien.</s:String><s:String x:Key="ButtonAddPoint">Ajouter un point</s:String><s:String x:Key="TipAddPoint">Ajouter un point après le dernier</s:String><s:String x:Key="TipRemovePoint">Supprimer ce point</s:String>@@@ -664,8 -698,10 +726,12 @@@<s:String x:Key="Enum.PartKind.Fiber">Fibre</s:String><s:String x:Key="Enum.PartKind.BraggReflector">Réflecteur de Bragg</s:String><s:String x:Key="Enum.PartKind.GrinLens">Lentille GRIN</s:String>+ <s:String x:Key="Enum.FiberEnds.Flat">Plates</s:String>+ <s:String x:Key="Enum.FiberEnds.Round">Arrondies</s:String>+ <s:String x:Key="Enum.PartKind.XorGate">Porte XOR</s:String>+ <s:String x:Key="Enum.PartKind.AndGate">Porte AND</s:String>+ <s:String x:Key="Enum.PartKind.OrGate">Porte OR</s:String>+ <s:String x:Key="Enum.PartKind.ZonePlate">Lame à zones</s:String><s:String x:Key="Enum.TriangleType.Equilateral">Équilatéral</s:String><s:String x:Key="Enum.TriangleType.RightIsosceles">Rectangle isocèle (45°)</s:String><s:String x:Key="Enum.TriangleType.ThirtySixtyNinety">30-60-90</s:String>diff --cc WaveDudeNext.WPF/Strings/Strings.NL.xamlindex 664ed30,58494d3..460c067--- a/WaveDudeNext.WPF/Strings/Strings.NL.xaml+++ b/WaveDudeNext.WPF/Strings/Strings.NL.xaml@@@ -269,10 -271,28 +274,29 @@@ version. It is distributed WITHOUT ANY<s:String x:Key="SectionCore">Kern</s:String><s:String x:Key="SectionCladding">Mantel</s:String><s:String x:Key="SectionLayers">Lagen</s:String>+ <s:String x:Key="SectionDesign">Ontwerp</s:String>+ <s:String x:Key="SectionLayout">Indeling</s:String>+ <s:String x:Key="SectionPorts">Poorten</s:String>+ <s:String x:Key="SectionOutputs">Actieve uitgangen</s:String>+ <s:String x:Key="TipGateWavelength">De golflengte die de ontwerpfrequentie geeft in een medium met index 1, bij de bronfrequentieschaal van de simulatie</s:String>+ <s:String x:Key="LabelQuarterWave">Kwartgolf-coating</s:String>+ <s:String x:Key="TipQuarterWave">De dikte van de minst reflecterende coating op de kern, λ / (4 √n)</s:String>+ <s:String x:Key="LabelCoreWidth">Kernbreedte</s:String>+ <s:String x:Key="LabelCouplerGap">Spleet van de koppelaar</s:String>+ <s:String x:Key="LabelCouplerLength">Lengte van de koppelaar</s:String>+ <s:String x:Key="LabelGateLength">Totale lengte</s:String>+ <s:String x:Key="TipGateLayout">Berekend uit de ontwerpgolflengte en de indices met de eigen golfvergelijking van de simulator (de 4e-orde-Laplaciaan)</s:String>+ <s:String x:Key="LabelInputA">Ingang A</s:String>+ <s:String x:Key="LabelInputB">Ingang B</s:String>+ <s:String x:Key="TipGatePorts">Canvaspixels. Voed de ingangen met gelijke golven (dezelfde frequentie, amplitude en fase); een ontbrekende golf is een logische 0. De uitgangen liggen in lijn met de ingangen van poorten die een poortafstand hoger en lager staan, één lengte verder</s:String>+ <s:String x:Key="SectionZones">Zones</s:String>+ <s:String x:Key="LabelZoneCount">Aantal zones</s:String>+ <s:String x:Key="LabelOuterZone">Buitenste zone</s:String>+ <s:String x:Key="TipZones">De zones die de plaat binnen zijn diameter krijgt, en de breedte van de buitenste hele zone, die het rooster moet kunnen oplossen (minstens een paar pixels)</s:String><s:String x:Key="SectionPoints">Punten</s:String>+ <s:String x:Key="SectionNodes">Knooppunten</s:String><s:String x:Key="HintPolygonPoints">Hoekpunten van de omtrek ten opzichte van het middelpunt, vóór rotatie. Leeg: de regelmatige veelhoek hierboven wordt gebruikt.</s:String>- <s:String x:Key="HintFiberPoints">Punten van het pad ten opzichte van het middelpunt, vóór rotatie.</s:String>+ <s:String x:Key="HintFiberNodes">Knooppunten van het pad ten opzichte van het middelpunt, vóór rotatie, elk met de ingaande en uitgaande greep van de segmenten die daar samenkomen, als verschuiving ten opzichte van het knooppunt. Minder dan twee knooppunten tekenen niets.</s:String><s:String x:Key="ButtonAddPoint">Punt toevoegen</s:String><s:String x:Key="TipAddPoint">Punt na het laatste toevoegen</s:String><s:String x:Key="TipRemovePoint">Dit punt verwijderen</s:String>@@@ -664,8 -698,10 +726,12 @@@<s:String x:Key="Enum.PartKind.Fiber">Vezel</s:String><s:String x:Key="Enum.PartKind.BraggReflector">Bragg-reflector</s:String><s:String x:Key="Enum.PartKind.GrinLens">GRIN-lens</s:String>+ <s:String x:Key="Enum.FiberEnds.Flat">Vlak</s:String>+ <s:String x:Key="Enum.FiberEnds.Round">Rond</s:String>+ <s:String x:Key="Enum.PartKind.XorGate">XOR-poort</s:String>+ <s:String x:Key="Enum.PartKind.AndGate">AND-poort</s:String>+ <s:String x:Key="Enum.PartKind.OrGate">OR-poort</s:String>+ <s:String x:Key="Enum.PartKind.ZonePlate">Zoneplaat</s:String><s:String x:Key="Enum.TriangleType.Equilateral">Gelijkzijdig</s:String><s:String x:Key="Enum.TriangleType.RightIsosceles">Rechthoekig-gelijkbenig (45°)</s:String><s:String x:Key="Enum.TriangleType.ThirtySixtyNinety">30-60-90</s:String>diff --cc WaveDudeNext/Model/OpticalPart.csindex 414531d,aef9823..ac07fba--- a/WaveDudeNext/Model/OpticalPart.cs+++ b/WaveDudeNext/Model/OpticalPart.cs@@@ -16,10 -16,9 +16,11 @@@// <https://www.gnu.org/licenses/>.using System.Collections.ObjectModel;+using System.Collections.Specialized;using System.ComponentModel;+using System.ComponentModel.DataAnnotations;using System.Xml.Serialization;+ using WaveDudeNext.Parts;namespace WaveDudeNext.Model;@@@ -1992,3 -1515,675 +2001,686 @@@ public sealed class GrinLensPart : Opti/// <inheritdoc/>public override OpticalPart Clone() => ShallowClone<GrinLensPart>();}++ /// <summary>What one output of a <see cref="LogicGatePart"/> gives, in powers relative to one input's for the inputs 00, 10, 01, 11.</summary>+ public enum GateOutput+ {+ /// <summary>0, ½, ½, 0: exclusive or, the waves cancel when both are on.</summary>+ Xor,+ /// <summary>0, ½, ½, 2: the sum in phase; read as AND with a threshold between ½ and 2 (4 : 1, the most a passive linear gate gives).</summary>+ And,+ /// <summary>0, ½, ½, ½: or, the waves meet at 120° and two give what one gives.</summary>+ Or,+ /// <summary>0, ½, ½, 1½: what the OR gate's coupler sends the other way, the waves meeting at 60°.</summary>+ Remainder,+ }++ /// <summary>+ /// An optical logic gate, the interferometric logic of a Mach-Zehnder's combining half (the user's choice, 2026-10-21: a+ /// 2 × 2 directional coupler): two single-mode waveguides, input A above the axis and input B below, a phase section that+ /// puts wave B <see cref="PhaseShift"/> ahead of wave A, and a 3 dB coupler whose upper output carries (a + i·b) / √2 and+ /// lower output (i·a + b) / √2 of two coherent inputs (equal waves of the same frequency and phase). The phase shift alone+ /// makes the gate (the user's request, 2026-10-22, for AND and OR in the same dimensions as the XOR): +90° gives the upper+ /// output a − b (<see cref="XorGatePart"/>), −90° a + b (<see cref="AndGatePart"/>), +30° a + e^{i120°}·b+ /// (<see cref="OrGatePart"/>); the phase section sits in a stretch of the same length in all three, so they share their+ /// dimensions and ports and tile together. The whole layout follows from <see cref="DesignFrequency"/> (through+ /// <see cref="Wavelength"/>) and the indices (<see cref="LogicGateDesign"/>): the core width, the cladding, the gap, the+ /// coupler and phase-section lengths are computed with the engines' own discrete wave equation (the 4th-order stencil;+ /// the 9-point stencil's waves are slower and miss the design). Both ends are open and carry an anti-reflection band+ /// (<see cref="Coating"/>) unless switched off per end (<see cref="InputCoated"/>, <see cref="OutputCoated"/>), so light+ /// comes in from a fibre or a gate before and leaves into the next, and each output can+ /// be switched off by an absorber in its arm (<see cref="UpperOutputActive"/>, <see cref="LowerOutputActive"/>). The gate+ /// is passive; its inputs can be ordinary sources placed on <see cref="Ports"/>.+ /// </summary>+ public abstract class LogicGatePart : OpticalPart, IFrequencyDesigned+ {+ /// <summary>Default <see cref="DesignFrequency"/>: level 50, a wavelength of 32 px at the default solver settings, the user's wavelength (2026-10-21); twelve pixels a period in the core, so the grid resolves the guide well.</summary>+ public const double DefaultFrequency = 50.0;+ /// <summary>Lowest <see cref="DesignFrequency"/>.</summary>+ public const double MinFrequency = 1.0;+ /// <summary>Shortest <see cref="Wavelength"/> the design accepts, in pixels.</summary>+ public const double MinWavelength = 6.0;+ /// <summary>Longest <see cref="Wavelength"/> the design accepts, in pixels.</summary>+ public const double MaxWavelength = 200.0;+ /// <summary>+ /// Default <see cref="Coating"/> in pixels, the least reflecting band on the default gate, measured from the standing wave+ /// in an output arm (2026-10-22): 0, 3, 5, 6, 7, 8 and 9 px reflected 24, 16, 5.5, 3.4, 3.9, 7.5 and 11 % of the power.+ /// A little above the quarter wave λ / (4 √n) = 5.0 px of the core, as the mode runs partly in the cladding.+ /// </summary>+ public const int DefaultCoating = 6;+ /// <summary>+ /// Default <see cref="CoreIndex"/>, the largest: the strongest contrast to the cladding holds the mode tightest, so the+ /// bends and the coupler are shortest. Measured at λ 32 (2026-10-21): cores of 2.0, 2.3 and 2.55 made gates of 726, 588+ /// and 539 px whose XOR output kept 1.4, 1.9 and 1.1 % with both inputs on; a core of 1.6 at λ 16 made 1100 px.+ /// </summary>+ public const double DefaultCoreIndex = 2.55;+ /// <summary>Default <see cref="CladdingIndex"/>.</summary>+ public const double DefaultCladdingIndex = 1.45;+ /// <summary>Default <see cref="PortSpacing"/> in pixels: as close as the design allows (it raises any smaller value); 60 px at the defaults, a unit 120 px wide.</summary>+ public const int DefaultPortSpacing = 2;+ /// <summary>Largest <see cref="PortSpacing"/> in pixels.</summary>+ public const int MaxPortSpacing = 2000;++ private double _designFrequency = DefaultFrequency;+ private double _frequencyScale = Simulation.DefaultSourceFrequencyScale;+ private double _coreIndex = DefaultCoreIndex;+ private double _claddingIndex = DefaultCladdingIndex;+ private int _portSpacing = DefaultPortSpacing;+ private int _coating = DefaultCoating;+ private bool _inputCoated = true;+ private bool _outputCoated = true;+ private bool _upperOutputActive = true;+ private bool _lowerOutputActive = true;++ /// <summary>How far wave B leads wave A into the coupler, in degrees; fixed per kind.</summary>+ [XmlIgnore]+ [Browsable(false)]+ public abstract double PhaseShift { get; }++ /// <summary>What the upper output gives; fixed per kind.</summary>+ [XmlIgnore]+ [Browsable(false)]+ public abstract GateOutput UpperOutput { get; }++ /// <summary>What the lower output gives; fixed per kind.</summary>+ [XmlIgnore]+ [Browsable(false)]+ public abstract GateOutput LowerOutput { get; }++ /// <summary>+ /// The source frequency the gate is designed for, as a source level (the scale of <see cref="Source.Frequency"/>): the+ /// frequency of the sources that drive it (the user's point, 2026-10-22: every source input is a frequency, so the+ /// gate takes one too and shows the wavelength). The layout follows from the <see cref="Wavelength"/> it gives.+ /// </summary>+ [XmlAttribute]+ [DefaultValue(DefaultFrequency)]++ [Range(MinFrequency, Source.MaxLevel)]+ [Category("Design")]+ [DisplayName("Design frequency")]+ [Description("The source frequency the gate is designed for, on the same scale as a source's frequency: the frequency of the sources that drive it. The wavelength, and from it the core width, the coupler and the phase section, follow from it, so the gate works at this frequency only.")]+ public double DesignFrequency+ {+ get => _designFrequency;+ set+ {+ if (SetProperty(ref _designFrequency, value))+ {+ OnDesignChanged();+ }+ }+ }++ /// <summary>+ /// The simulation's <see cref="Simulation.SourceFrequencyScale"/>, which turns <see cref="DesignFrequency"/> into an+ /// angular frequency; kept current by the window's <see cref="Parts.GatePortFollower"/>, the default scale until then.+ /// Not stored: the project's simulation settings hold it. UI thread.+ /// </summary>+ [XmlIgnore]+ [Browsable(false)]+ public double FrequencyScale+ {+ get => _frequencyScale;+ set+ {+ if (SetProperty(ref _frequencyScale, value))+ {+ OnDesignChanged();+ }+ }+ }++ /// <summary>+ /// The wavelength in pixels in a medium of index 1 that <see cref="DesignFrequency"/> gives: λ = 2π / ω with+ /// ω = level / 255 × 0.5 × <see cref="FrequencyScale"/> radians per step and the engines' speed of 1 pixel per step at+ /// index 1 (<see cref="Simulation.Wavelength"/> with that speed); NaN for a frequency that gives none.+ /// </summary>+ [XmlIgnore]+ [Browsable(false)]+ public double Wavelength => Simulation.Wavelength(DesignFrequency, 1.0, FrequencyScale);++ /// <summary>Thickness in pixels of the anti-reflection band at the ends <see cref="InputCoated"/> and <see cref="OutputCoated"/> select, with the index √n of the core and of the cladding; 0 for none. A quarter-wave band is λ / (4 √n) thick.</summary>+ [XmlAttribute]+ [DefaultValue(DefaultCoating)]++ [Range(0, MaxCoating)]+ [Category("Material")]+ [DisplayName("AR coating")]+ [Description("Thickness in pixels of the anti-reflection band at the ends ticked below, with the index √n of the core and of the cladding; 0 for none. A quarter-wave band, the least reflecting, is λ / (4 √n) pixels thick; the form shows it for the core.")]+ public int Coating+ {+ get => _coating;+ set => SetProperty(ref _coating, value);+ }++ /// <summary>+ /// Whether the input end carries the anti-reflection band (<see cref="Coating"/>). Off where the gate takes its light+ /// from a gate before it (the user's request, 2026-10-22: a band in the junction keeps the wave from passing from one+ /// unit into the next).+ /// </summary>+ [XmlAttribute]+ [DefaultValue(true)]+ [Category("Material")]+ [DisplayName("AR on input side")]+ [Description("Put the anti-reflection band on the input end. Switch it off where the gate takes its light from a gate before it, so the wave passes through the junction.")]+ public bool InputCoated+ {+ get => _inputCoated;+ set => SetProperty(ref _inputCoated, value);+ }++ /// <summary>Whether the output end carries the anti-reflection band (<see cref="Coating"/>); off where the gate hands its light to a gate after it (see <see cref="InputCoated"/>).</summary>+ [XmlAttribute]+ [DefaultValue(true)]+ [Category("Material")]+ [DisplayName("AR on output side")]+ [Description("Put the anti-reflection band on the output end. Switch it off where the gate hands its light to a gate after it, so the wave passes through the junction.")]+ public bool OutputCoated+ {+ get => _outputCoated;+ set => SetProperty(ref _outputCoated, value);+ }++ /// <summary>Whether the upper output (<see cref="UpperOutput"/>) lets its light out; switched off, an absorber in the blue channel takes it in the arm's last stretch.</summary>+ [XmlAttribute]+ [DefaultValue(true)]+ [Category("Outputs")]+ [DisplayName("Upper output")]+ [Description("Let the upper output's light leave the gate. Switched off, an absorber with a soft rise takes it in the last stretch of the arm.")]+ public bool UpperOutputActive+ {+ get => _upperOutputActive;+ set => SetProperty(ref _upperOutputActive, value);+ }++ /// <summary>Whether the lower output (<see cref="LowerOutput"/>) lets its light out; switched off, an absorber in the blue channel takes it in the arm's last stretch.</summary>+ [XmlAttribute]+ [DefaultValue(true)]+ [Category("Outputs")]+ [DisplayName("Lower output")]+ [Description("Let the lower output's light leave the gate. Switched off, an absorber with a soft rise takes it in the last stretch of the arm.")]+ public bool LowerOutputActive+ {+ get => _lowerOutputActive;+ set => SetProperty(ref _lowerOutputActive, value);+ }++ /// <summary>Tells the form that the values derived from the design follow an edit of a design input.</summary>+ private void OnDesignChanged()+ {+ OnPropertyChanged(nameof(Wavelength));+ OnPropertyChanged(nameof(PortSpacingUsed));+ }++ /// <summary>Refractive index of the waveguide cores, 1.00 to 2.55; above the cladding's for guiding.</summary>+ [XmlAttribute]+ [DefaultValue(DefaultCoreIndex)]++ [Range(MinIndex, MaxIndex)]+ [Category("Material")]+ [DisplayName("Core index")]+ [Description("Refractive index of the waveguide cores, 1.00 to 2.55 in steps of 0.01. It must be above the cladding's; the larger the difference, the narrower the cores and the tighter the bends.")]+ public double CoreIndex+ {+ get => _coreIndex;+ set+ {+ if (SetProperty(ref _coreIndex, value))+ {+ OnPropertyChanged(nameof(PortSpacingUsed));+ }+ }+ }++ /// <summary>Refractive index of the cladding around the cores, 1.00 to 2.55.</summary>+ [XmlAttribute]+ [DefaultValue(DefaultCladdingIndex)]++ [Range(MinIndex, MaxIndex)]+ [Category("Material")]+ [DisplayName("Cladding index")]+ [Description("Refractive index of the cladding around the cores, 1.00 to 2.55 in steps of 0.01.")]+ public double CladdingIndex+ {+ get => _claddingIndex;+ set+ {+ if (SetProperty(ref _claddingIndex, value))+ {+ OnPropertyChanged(nameof(PortSpacingUsed));+ }+ }+ }++ /// <summary>Distance between the two inputs (and the two outputs) in pixels, centre to centre, as typed; the design raises a value below what it needs to keep the arms apart (<see cref="PortSpacingUsed"/>).</summary>+ [XmlAttribute]+ [DefaultValue(DefaultPortSpacing)]++ [Range(2, MaxPortSpacing)]+ [Category("Shape")]+ [DisplayName("Port spacing")]+ [Description("Distance between the two inputs, and between the two outputs, in pixels. A value below what the design needs to keep the arms apart is raised to it.")]+ public int PortSpacing+ {+ get => _portSpacing;+ set+ {+ if (SetProperty(ref _portSpacing, value))+ {+ OnPropertyChanged(nameof(PortSpacingUsed));+ }+ }+ }++ /// <summary>+ /// The port spacing the design uses, what the form shows and edits: <see cref="PortSpacing"/> raised to the design's+ /// minimum (60 px at the defaults), so every step of the box moves the ports (the user's report, 2026-10-21: the box+ /// stood at 2 and its steps up to the minimum changed nothing). Setting it sets <see cref="PortSpacing"/>. Not stored.+ /// </summary>+ [XmlIgnore]+ [Browsable(false)]+ public int PortSpacingUsed+ {+ get => Design?.PortSpacing ?? PortSpacing;+ set => PortSpacing = value;+ }++ /// <summary>The layout for the current values (guarded as the painter guards them), or null when the cores guide nothing. Any thread; cached.</summary>+ [XmlIgnore]+ [Browsable(false)]+ public LogicGateDesign? Design => double.IsFinite(Wavelength) && Wavelength > 0.0+ ? LogicGateDesign.For(Math.Round(Math.Clamp(Wavelength, MinWavelength, MaxWavelength), 3), NormalizeIndex(CoreIndex), NormalizeIndex(CladdingIndex), Math.Clamp(PortSpacing, 2, MaxPortSpacing), PhaseShift)+ : null;++ /// <inheritdoc/>+ public override double AxisReach => (Design?.Length ?? 0) / 2.0;++ /// <summary>The outer edge of the claddings: along the upper arm's top, back along the lower arm's bottom; a closed outline of the gate's extent.</summary>+ public override (double X, double Y)[] Outline()+ {+ if (Design is not { } design)+ {+ return [];+ }+ const int steps = 64;+ double outer = design.CoreWidth / 2.0 + design.CladdingThickness + design.AbsorberWidth;+ var points = new (double X, double Y)[2 * (steps + 1)];+ for (int i = 0; i <= steps; i++)+ {+ double x = design.Left + (double)design.Length * i / steps;+ double offset = design.ArmOffset(x) + outer;+ points[i] = (x, -offset);+ points[2 * steps + 1 - i] = (x, offset);+ }+ return points;+ }++ /// <summary>The ports in canvas pixels (rounded to the pixel a source would sit on): input A, input B, the upper output and the lower output; null without a design.</summary>+ public (int X, int Y)[]? Ports()+ {+ if (Design is not { } design)+ {+ return null;+ }+ double half = design.PortSpacing / 2.0;+ (int, int) At(double x, double y)+ {+ (double cx, double cy) = ToCanvas(x, y);+ return ((int)Math.Floor(cx), (int)Math.Floor(cy));+ }+ return [At(design.InputX, -half), At(design.InputX, half), At(design.OutputX, -half), At(design.OutputX, half)];+ }++ /// <inheritdoc/>+ public override void Normalize()+ {+ base.Normalize();+ DesignFrequency = double.IsFinite(DesignFrequency) ? Math.Round(Math.Clamp(DesignFrequency, MinFrequency, Source.MaxLevel), 2) : DefaultFrequency;+ CoreIndex = NormalizeIndex(CoreIndex);+ CladdingIndex = NormalizeIndex(CladdingIndex);+ PortSpacing = Math.Clamp(PortSpacing, 2, MaxPortSpacing);+ Coating = Math.Clamp(Coating, 0, MaxCoating);+ }+ }++ /// <summary>+ /// An XOR gate: wave B leads by 90°, so the upper output carries (a − b) / √2, dark when both inputs are on, and the lower+ /// the in-phase sum (the 2026-10-21 design, measured: with both inputs on the upper output keeps about 1 % of one input's+ /// power, the lower 1.9×).+ /// </summary>+ public sealed class XorGatePart : LogicGatePart+ {+ /// <inheritdoc/>+ public override PartKind Kind => PartKind.XorGate;++ /// <inheritdoc/>+ public override double PhaseShift => 90.0;++ /// <inheritdoc/>+ public override GateOutput UpperOutput => GateOutput.Xor;++ /// <inheritdoc/>+ public override GateOutput LowerOutput => GateOutput.And;++ /// <inheritdoc/>+ public override OpticalPart Clone() => ShallowClone<XorGatePart>();+ }++ /// <summary>+ /// An AND gate in the only sense a passive linear gate has one: wave A leads by 90°, so the upper output carries the in-phase+ /// sum (a + b) / √2, half an input's power for one input and twice it for two, 4 : 1, to be read with a threshold between;+ /// the lower output carries the XOR. The XOR gate with its outputs exchanged.+ /// </summary>+ public sealed class AndGatePart : LogicGatePart+ {+ /// <inheritdoc/>+ public override PartKind Kind => PartKind.AndGate;++ /// <inheritdoc/>+ public override double PhaseShift => -90.0;++ /// <inheritdoc/>+ public override GateOutput UpperOutput => GateOutput.And;++ /// <inheritdoc/>+ public override GateOutput LowerOutput => GateOutput.Xor;++ /// <inheritdoc/>+ public override OpticalPart Clone() => ShallowClone<AndGatePart>();+ }++ /// <summary>+ /// An OR gate: wave B leads by 30°, so the waves meet at 120° in the upper output, a + e^{i120°}·b over √2, and one input or+ /// two give the same half an input's power (1 + 1 + 2 cos 120° = 1); the lower output, where they meet at 60°, gives ½, ½ and 1½.+ /// </summary>+ public sealed class OrGatePart : LogicGatePart+ {+ /// <inheritdoc/>+ public override PartKind Kind => PartKind.OrGate;++ /// <inheritdoc/>+ public override double PhaseShift => 30.0;++ /// <inheritdoc/>+ public override GateOutput UpperOutput => GateOutput.Or;++ /// <inheritdoc/>+ public override GateOutput LowerOutput => GateOutput.Remainder;++ /// <inheritdoc/>+ public override OpticalPart Clone() => ShallowClone<OrGatePart>();+ }++ /// <summary>+ /// A Fresnel zone plate (the user's request, 2026-10-22), a diffractive lens: a plate of <see cref="Thickness"/> along the+ /// axis and <see cref="Diameter"/> across it, cut into zones at the radii rₙ = √(n·λ·f + (n·λ/2)²) from the axis, λ the+ /// <see cref="Wavelength"/> of <see cref="DesignFrequency"/> and f the <see cref="FocalLength"/>; every second zone is a+ /// block that absorbs (the user's choice of material), the central zone open, or a block when <see cref="Inverse"/>. The+ /// waves through the open zones arrive at the focus a whole number of periods apart and add there. The blocks are painted+ /// into the blue channel only, the refractive index left as it is: full at their middle, rising quadratically over+ /// <see cref="Coating"/> from the faces the wave meets and leaves, so they reflect little; their sides toward the+ /// neighbouring zones stay sharp, as the outer zones are narrow (about λ·f / <see cref="Diameter"/>). Light passes freely+ /// outside the diameter unless the absorbing <see cref="Mount"/> is on. Positions and lengths are canvas pixels.+ /// </summary>+ public sealed class ZonePlatePart : OpticalPart, IFrequencyDesigned+ {+ /// <summary>Default <see cref="Diameter"/> in pixels.</summary>+ public const int DefaultDiameter = 800;+ /// <summary>Default <see cref="Thickness"/> in pixels: two wavelengths at the default frequency, room for the rise on both faces (see <see cref="BlockAbsorption"/>).</summary>+ public const int DefaultThickness = 64;+ /// <summary>Default <see cref="Coating"/> in pixels: a wavelength at the default frequency (see <see cref="BlockAbsorption"/>).</summary>+ public const int DefaultCoating = 32;+ /// <summary>Default <see cref="DesignFrequency"/>: level 50, a wavelength of 32 px at the default solver settings, as the logic gates.</summary>+ public const double DefaultFrequency = 50.0;+ /// <summary>Default <see cref="FocalLength"/> in pixels.</summary>+ public const int DefaultFocalLength = 600;+ /// <summary>+ /// The absorption (blue) in the middle of a block. Measured on a block of the whole diameter with a plane wave at λ 32+ /// (2026-10-22, transmitted / reflected power): 255 over a 16 px rise in 48 px 0.4 / 10.7 %, over 24 px 0.3 / 4.9 %;+ /// 128 over 24 px 0.3 / 2.2 %; 64 over 24 px 2.7 / 0.9 %; in 64 px over 32 px, 64 1.0 / 0.7 %, 96 0.4 / 1.0 %, 128+ /// 0.3 / 1.2 %. A block that stops all and reflects nothing does not exist: a strong absorber is a wall of its own.+ /// </summary>+ public const int BlockAbsorption = 96;++ private int _diameter = DefaultDiameter;+ private int _thickness = DefaultThickness;+ private int _coating = DefaultCoating;+ private double _designFrequency = DefaultFrequency;+ private double _frequencyScale = Simulation.DefaultSourceFrequencyScale;+ private int _focalLength = DefaultFocalLength;+ private bool _inverse;+ private bool _mount;+ private int _mountWidth = DefaultMountWidth;++ /// <summary>Default <see cref="MountWidth"/> in pixels.</summary>+ public const int DefaultMountWidth = 200;++ /// <inheritdoc/>+ public override PartKind Kind => PartKind.ZonePlate;++ /// <summary>+ /// Whether an absorbing mount surrounds the plate (the user's request, 2026-10-22): a band of <see cref="MountWidth"/>+ /// on either side beyond the diameter, the plate's thickness and absorption, so no light passes outside the zones (which+ /// otherwise meets the focused light on the axis and pushes the focus on).+ /// </summary>+ [XmlAttribute]+ [DefaultValue(false)]+ [Category("Shape")]+ [Description("Surround the plate with an absorbing mount, so no light passes outside its diameter. Without it, that light meets the focused light on the axis and moves the focus further out, the more so the fewer zones the plate has.")]+ public bool Mount+ {+ get => _mount;+ set => SetProperty(ref _mount, value);+ }++ /// <summary>Width in pixels of the mount on either side, beyond the diameter.</summary>+ [XmlAttribute]+ [DefaultValue(DefaultMountWidth)]++ [Range(1, int.MaxValue)]+ [Category("Shape")]+ [DisplayName("Mount width")]+ [Description("Width in pixels of the absorbing mount on either side, beyond the diameter.")]+ public int MountWidth+ {+ get => _mountWidth;+ set => SetProperty(ref _mountWidth, value);+ }++ /// <summary>Half the plate's outer extent across the axis in pixels: half the diameter, plus the mount when it is on.</summary>+ [XmlIgnore]+ [Browsable(false)]+ public double OuterHalfWidth => Math.Max(2, Diameter) / 2.0 + (Mount ? Math.Max(1, MountWidth) : 0);++ /// <summary>Extent across the axis in pixels.</summary>+ [XmlAttribute]+ [DefaultValue(DefaultDiameter)]++ [Range(2, int.MaxValue)]+ [Category("Shape")]+ [Description("Extent across the axis in pixels; the zones fill it.")]+ public int Diameter+ {+ get => _diameter;+ set+ {+ if (SetProperty(ref _diameter, value))+ {+ OnPropertyChanged(nameof(ZoneCount));+ }+ }+ }++ /// <summary>Extent along the axis in pixels, the blocks' depth.</summary>+ [XmlAttribute]+ [DefaultValue(DefaultThickness)]++ [Range(1, int.MaxValue)]+ [Category("Shape")]+ [Description("Extent along the axis in pixels: the depth of the blocks. It should leave room for the anti-reflection rise on both faces.")]+ public int Thickness+ {+ get => _thickness;+ set => SetProperty(ref _thickness, value);+ }++ /// <summary>Depth in pixels over which a block's absorption rises from nothing at the faces the wave meets and leaves to its full strength; at most half the thickness takes effect.</summary>+ [XmlAttribute]+ [DefaultValue(DefaultCoating)]++ [Range(0, MaxAbsorptionRamp)]+ [Category("Shape")]+ [DisplayName("Anti-reflection")]+ [Description("Depth in pixels over which a block's absorption rises from nothing at its faces to its full strength, so the blocks reflect little; at most half the thickness takes effect.")]+ public int Coating+ {+ get => _coating;+ set => SetProperty(ref _coating, value);+ }++ /// <summary>The source frequency the plate is designed for, as a source level (the scale of <see cref="Source.Frequency"/>).</summary>+ [XmlAttribute]+ [DefaultValue(DefaultFrequency)]++ [Range(LogicGatePart.MinFrequency, Source.MaxLevel)]+ [Category("Design")]+ [DisplayName("Target frequency")]+ [Description("The source frequency the plate is designed for, on the same scale as a source's frequency. The zones follow from the wavelength it gives, so the plate focuses this frequency at the focal length; other frequencies focus elsewhere.")]+ public double DesignFrequency+ {+ get => _designFrequency;+ set+ {+ if (SetProperty(ref _designFrequency, value))+ {+ OnDesignChanged();+ }+ }+ }++ /// <inheritdoc/>+ [XmlIgnore]+ [Browsable(false)]+ public double FrequencyScale+ {+ get => _frequencyScale;+ set+ {+ if (SetProperty(ref _frequencyScale, value))+ {+ OnDesignChanged();+ }+ }+ }++ /// <summary>Distance in pixels from the plate's centre to the focus along the axis (+x'), for a plane wave arriving along it.</summary>+ [XmlAttribute]+ [DefaultValue(DefaultFocalLength)]++ [Range(1, int.MaxValue)]+ [Category("Design")]+ [DisplayName("Focal length")]+ [Description("Distance in pixels from the plate to its focus, for a plane wave arriving along the axis.")]+ public int FocalLength+ {+ get => _focalLength;+ set+ {+ if (SetProperty(ref _focalLength, value))+ {+ OnPropertyChanged(nameof(ZoneCount));+ }+ }+ }++ /// <summary>Whether the zones are exchanged: the central zone a block and the first ring open, and so on.</summary>+ [XmlAttribute]+ [DefaultValue(false)]+ [Category("Design")]+ [Description("Exchange the zones: the central zone becomes a block, the first ring open, and so on. The focus stays where it is.")]+ public bool Inverse+ {+ get => _inverse;+ set => SetProperty(ref _inverse, value);+ }++ /// <summary>The wavelength in pixels in a medium of index 1 that <see cref="DesignFrequency"/> gives with <see cref="FrequencyScale"/> (the engines' speed of 1 pixel per step); NaN for none.</summary>+ [XmlIgnore]+ [Browsable(false)]+ public double Wavelength => Simulation.Wavelength(DesignFrequency, 1.0, FrequencyScale);++ /// <summary>How many zones, open and blocked, fit within half the diameter (the last one cut by the rim); 0 without a wavelength.</summary>+ [XmlIgnore]+ [Browsable(false)]+ public int ZoneCount+ {+ get+ {+ double half = Math.Max(2, Diameter) / 2.0;+ return ZoneAt(half) is { } zone ? zone + 1 : 0;+ }+ }++ /// <summary>+ /// The zone, counted from 0 at the axis, that the distance <paramref name="r"/> from the axis falls in: the n with+ /// rₙ ≤ r < rₙ₊₁, from rₙ² = n·λ·f + (n·λ/2)², a quadratic in n; null without a wavelength or a focal length.+ /// </summary>+ public int? ZoneAt(double r)+ {+ double lambda = Wavelength;+ double f = Math.Max(1, FocalLength);+ if (!double.IsFinite(lambda) || lambda <= 0.0)+ {+ return null;+ }+ // (λ²/4)·n² + λf·n − r² = 0+ double a = lambda * lambda / 4.0;+ double b = lambda * f;+ double n = (-b + Math.Sqrt(b * b + 4.0 * a * r * r)) / (2.0 * a);+ return (int)Math.Floor(n);+ }++ /// <summary>Whether the distance <paramref name="r"/> from the axis falls in a block: the odd zones, or the even ones when inverse.</summary>+ public bool IsBlockAt(double r) => ZoneAt(Math.Abs(r)) is { } zone && (zone % 2 == 1) != Inverse;++ /// <summary>The width in pixels of the outermost whole zone within the diameter, rₙ − rₙ₋₁; what the grid must resolve.</summary>+ [XmlIgnore]+ [Browsable(false)]+ public double OuterZoneWidth+ {+ get+ {+ double lambda = Wavelength;+ int count = ZoneCount;+ if (count < 2)+ {+ return Math.Max(2, Diameter) / 2.0;+ }+ double f = Math.Max(1, FocalLength);+ double Radius(int n) => Math.Sqrt(n * lambda * f + n * lambda / 2.0 * (n * lambda / 2.0));+ return Radius(count - 1) - Radius(count - 2);+ }+ }++ /// <summary>Tells the form that the values derived from the wavelength follow an edit.</summary>+ private void OnDesignChanged()+ {+ OnPropertyChanged(nameof(Wavelength));+ OnPropertyChanged(nameof(ZoneCount));+ }++ /// <inheritdoc/>+ public override double AxisReach => Math.Max(1, Thickness) / 2.0;++ /// <summary>The plate's rectangle, the mount included when it is on.</summary>+ public override (double X, double Y)[] Outline()+ {+ double t = Math.Max(1, Thickness) / 2.0;+ double d = OuterHalfWidth;+ return [(-t, -d), (t, -d), (t, d), (-t, d)];+ }++ /// <inheritdoc/>+ public override void Normalize()+ {+ base.Normalize();+ MountWidth = Math.Max(1, MountWidth);+ Diameter = Math.Max(2, Diameter);+ Thickness = Math.Max(1, Thickness);+ Coating = Math.Clamp(Coating, 0, MaxAbsorptionRamp);+ DesignFrequency = double.IsFinite(DesignFrequency) ? Math.Round(Math.Clamp(DesignFrequency, LogicGatePart.MinFrequency, Source.MaxLevel), 2) : DefaultFrequency;+ FocalLength = Math.Max(1, FocalLength);+ }++ /// <inheritdoc/>+ public override OpticalPart Clone() => ShallowClone<ZonePlatePart>();+ }diff --cc WaveDudeNext/Model/Project.csindex 010f16c,05ac3b2..1429571--- a/WaveDudeNext/Model/Project.cs+++ b/WaveDudeNext/Model/Project.cs@@@ -349,9 -353,13 +353,13 @@@ public sealed class Project : ObservablPartKind.Ellipse => new EllipsePart(),PartKind.Triangle => new TrianglePart(),PartKind.Outline => new OutlinePart(),- PartKind.Fiber => new FiberPart { Points = FiberPart.DefaultPath() },+ PartKind.Fiber => new FiberPart { Nodes = FiberPart.DefaultPath() },PartKind.BraggReflector => new BraggReflectorPart(),PartKind.GrinLens => new GrinLensPart(),+ PartKind.XorGate => new XorGatePart(),+ PartKind.AndGate => new AndGatePart(),+ PartKind.OrGate => new OrGatePart(),+ PartKind.ZonePlate => new ZonePlatePart(),_ => throw new ArgumentOutOfRangeException(nameof(kind)),};part.Name = NumberedName(PartStem(kind), Parts.Select(p => p.Name));diff --cc WaveDudeNext/Parts/PartShape.csindex 44d0784,90e17ec..5fbaa98--- a/WaveDudeNext/Parts/PartShape.cs+++ b/WaveDudeNext/Parts/PartShape.cs@@@ -55,9 -55,11 +55,11 @@@ public abstract class PartShap{LensPart lens => new LensShape(lens),ShapePart shape => shape.Vertices().Length < 3 ? null : new VertexShape(shape),- FiberPart fiber => fiber.Points.Count < 2 ? null : new FiberShape(fiber),+ FiberPart fiber => FiberPart.Flatten(fiber.Nodes) is { Length: >= 2 } path ? new FiberShape(fiber, path) : null,BraggReflectorPart bragg => new BraggShape(bragg),GrinLensPart grin => new GrinShape(grin),+ LogicGatePart gate => gate.Design is { } design ? new LogicGateShape(gate, design) : null,+ ZonePlatePart plate => double.IsFinite(plate.Wavelength) && plate.Wavelength > 0.0 ? new ZonePlateShape(plate) : null,_ => null,};}diff --cc _tools/library_check/Program.csindex c21075f,57c8444..c8d3afd--- a/_tools/library_check/Program.cs+++ b/_tools/library_check/Program.cs@@@ -283,109 -276,6 +285,111 @@@ internal static class Prograreturn _failures == 0 ? 0 : 1;}+ /// <summary>+ /// Every <see cref="RangeAttribute"/> on the model agrees with its owner's Normalize(): a value below or above the+ /// range lands inside it, and a value at an inclusive bound stays as it is. Each leg runs on a fresh instance, so+ /// dependent clamps (a triangle's second base angle) see the state the case prepares.+ /// </summary>+ private static void CheckRanges()+ {+ Console.WriteLine("--- [Range] attributes against Normalize()");+ static (Action Normalize, object[] Targets) Part(OpticalPart part) => (part.Normalize, [part]);+ (string Name, Func<(Action Normalize, object[] Targets)> Make)[] cases =+ [+ ("Scene", () => { var s = new Scene(); return (s.Normalize, [s]); }),+ ("Simulation", () => { var s = new Simulation(); return (s.Normalize, [s]); }),+ ("Display", () => { var d = new Display(); return (d.Normalize, [d, d.Field, d.Intensity, d.Video]); }),+ ("Source", () => { var s = new Source { Array = new SourceArray() }; return (s.Normalize, [s, s.Array]); }),+ ("Probe", () => { var p = new Probe(); return (p.Normalize, [p]); }),+ ("ColorStop", () =>+ {+ var scheme = new ColorScheme();+ var stop = new ColorStop(0.5, new Rgb(1, 2, 3));+ scheme.Stops.Add(stop);+ return (scheme.Normalize, [stop]);+ }),+ ("LensPart", () => Part(new LensPart())),+ ("PolygonPart", () => Part(new PolygonPart())),+ ("RectanglePart", () => Part(new RectanglePart())),+ ("EllipsePart", () => Part(new EllipsePart())),+ // a custom triangle with the first angle at its minimum leaves the second its full range+ ("TrianglePart", () => Part(new TrianglePart { Type = TriangleType.Custom, AngleA = 1.0 })),+ ("OutlinePart", () => Part(new OutlinePart())),+ ("FiberPart", () => Part(new FiberPart())),+ ("BraggReflectorPart", () => Part(new BraggReflectorPart())),+ ("GrinLensPart", () => Part(new GrinLensPart())),++ ("XorGatePart", () => Part(new XorGatePart())),++ ("ZonePlatePart", () => Part(new ZonePlatePart())),+ ];+ int total = 0;+ foreach ((string name, Func<(Action Normalize, object[] Targets)> make) in cases)+ {+ var failures = new List<string>();+ int count = 0;+ object[] shape = make().Targets;+ for (int t = 0; t < shape.Length; t++)+ {+ foreach (PropertyInfo property in shape[t].GetType().GetProperties())+ {+ if (property.GetCustomAttribute<RangeAttribute>() is not { } range)+ {+ continue;+ }+ count++;+ bool integer = property.PropertyType == typeof(int);+ double min = Convert.ToDouble(range.Minimum, CultureInfo.InvariantCulture);+ double max = Convert.ToDouble(range.Maximum, CultureInfo.InvariantCulture);+ // the value to set and what Normalize() must leave: the bound itself, or NaN for "inside the range"+ var legs = new List<(string Leg, double Set, double Expect)>();+ if (min > (integer ? int.MinValue : double.MinValue))+ {+ legs.Add(("below", integer ? min - 1 : min - Math.Max(1.0, Math.Abs(min)), double.NaN));+ }+ if (max < (integer ? int.MaxValue : double.MaxValue))+ {+ legs.Add(("above", integer ? max + 1 : max + Math.Max(1.0, Math.Abs(max)), double.NaN));+ }+ if (!range.MinimumIsExclusive)+ {+ legs.Add(("at min", min, min));+ }+ if (!range.MaximumIsExclusive)+ {+ legs.Add(("at max", max, max));+ }+ foreach ((string leg, double set, double expect) in legs)+ {+ string where = $"{shape[t].GetType().Name}.{property.Name} {leg} ({range.Minimum}..{range.Maximum}): set {set}";+ try+ {+ (Action normalize, object[] targets) = make();+ object target = targets[t];+ property.SetValue(target, integer ? (object)(int)set : set);+ normalize();+ double got = Convert.ToDouble(property.GetValue(target), CultureInfo.InvariantCulture);+ bool inside = (range.MinimumIsExclusive ? got > min : got >= min) && (range.MaximumIsExclusive ? got < max : got <= max);+ if (!(double.IsNaN(expect) ? inside : got == expect))+ {+ failures.Add($"{where}, got {got}");+ }+ }+ catch (Exception e)+ {+ failures.Add($"{where}, threw {e.GetType().Name}: {e.Message}");+ }+ }+ }+ }+ total += count;+ Check(count > 0 && failures.Count == 0, $"{name}: {count} [Range] attribute(s) agree with Normalize()");+ foreach (string failure in failures)+ {+ Console.WriteLine(" " + failure);+ }+ }+ Console.WriteLine($" {total} ranged properties");+ }+/// <summary>"bench-render [w h]": what colouring a stored frame costs, per layer, at that size (the presenter's cost per picture).</summary>private static void BenchRender(int w, int h, bool load = false){@@@ -2416,9 -2153,9 +2422,10 @@@{back = Project.Load(stream);}- Check(back.Parts.Count == 9 && back.Parts.Select(p => p.Kind).SequenceEqual([PartKind.BraggReflector, PartKind.Lens, PartKind.Outline, PartKind.Polygon, PartKind.Rectangle, PartKind.Ellipse, PartKind.Triangle, PartKind.Fiber, PartKind.GrinLens]), "the nine kinds load back in order");+ Check(back.Parts.Count == 10 && back.Parts.Select(p => p.Kind).SequenceEqual([PartKind.BraggReflector, PartKind.Lens, PartKind.Outline, PartKind.Polygon, PartKind.Rectangle, PartKind.Ellipse, PartKind.Triangle, PartKind.Fiber, PartKind.GrinLens, PartKind.XorGate])+ && back.Parts[9] is XorGatePart { DesignFrequency: 80 }, "the ten kinds load back in order");- Check(back.Parts[7] is FiberPart { Points.Count: 2 } loaded && loaded.Points[0].X == -100 && loaded.Points[1].X == 100, "a loaded fibre has its two points, not the default path on top of them");+ Check(xml.Contains("<Node X=\"-100\" Y=\"0\" OutX=\"67\" />") && xml.Contains("<Node X=\"100\" Y=\"0\" InX=\"-67\" />"), "a fibre's nodes are sparse Node children: handles only where set, Smooth only when off");+ Check(back.Parts[7] is FiberPart { Nodes.Count: 2, Ends: FiberEnds.Flat } loaded && loaded.Nodes[0] is { X: -100, OutX: 67, Smooth: true } && loaded.Nodes[1] is { X: 100, InX: -67 }, "a loaded fibre has its two nodes with their handles, not the default path on top of them");Check(back.Parts[2] is OutlinePart { Mirror: true, Points.Count: 1 } && back.Parts[0] is BraggReflectorPart { Angle: 45, Index2: 2.2, Pairs: 10 } && back.Parts[4] is RectanglePart { Width: 7, Length: 60 } && back.Parts[5] is EllipsePart { Width: 9, Length: 9, Linked: true } && back.Parts[6] is TrianglePart { Type: TriangleType.RightIsosceles, AngleB: 45 },"a loaded outline keeps its point and mirror flag, the reflector its angle and index, the rectangle its width, the triangle its type");var watched = new ProjectWatcher(back);