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#
Composite sources: a rotation angle with a handle on the picture
Alexander Graefbc949e3aaf1a
diff --git a/CLAUDE.md b/CLAUDE.mdindex 83102bb..22ce75b 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -128,6 +128,18 @@ WPF shell as it stands:`PreviewPane.OverlayImage` on the picture cells). WPF composites source-over, not additively:the layer's alpha is the edge strength × gain and its colour the edge colour at full brightness,so the preview and a baked export differ slightly at strong edges.+- **Array rotation** (2026-10-14, the user's request): `SourceArray.Angle` in degrees, counter-clockwise on+ the screen (y points down, so x' = x cos + y sin, y' = y cos − x sin about the source position),+ normalised into (−180, 180]; applied in `Source.GenerateElements` before the random offsets, edited in the+ source view's Array section, and the emitter dots follow at once (the scene overlay regenerates the owner+ of an edited array). The author's format has no rotation; the importer leaves it 0. On the pictures a+ composite source carries a **rotation handle** (`MarkerThumb` role `SourceAngle`, id `SourceAngle:<name>`,+ the `AngleMarker` style: a bent arrow) on its row axis just beyond the first row (at least 28 px from the+ centre), joined to the centre by a dotted lever line, both shown only while the source is selected (the+ user's rule; collapsed, the handle is out of the Tab cycle until the source is selected through its+ handle or the tree): dragging turns the array to follow the mouse (whole+ degrees, Shift snaps to 15), the arrow keys turn it by a degree (ten with Shift), focusing it selects the+ source.- **Languages** (2026-10-14): `Strings/Strings.EN|DE|FR|NL.xaml` carry the same keys (menu headerswith their mnemonics; the shortcut letters I/O/X/L/F/F5 stay). `Localization/LanguageController`mirrors the theme controller: View > Language lists "System" then the tables by their own names,diff --git a/WaveDude.WPF/Controls/MarkerThumb.cs b/WaveDude.WPF/Controls/MarkerThumb.csindex 08a8fa6..34a7ec1 100644--- a/WaveDude.WPF/Controls/MarkerThumb.cs+++ b/WaveDude.WPF/Controls/MarkerThumb.cs@@ -8,6 +8,8 @@ public enum MarkerRole{/// <summary>The position of a source (its centre for a composite source).</summary>Source,+ /// <summary>The rotation handle of a composite source: sits on the array's row axis and turns it (2026-10-14).</summary>+ SourceAngle,/// <summary>Point A of a probe (the point of a point probe, the start of a line probe).</summary>ProbeA,/// <summary>Point B of a line probe.</summary>diff --git a/WaveDude.WPF/Controls/SceneOverlay.cs b/WaveDude.WPF/Controls/SceneOverlay.csindex 9d29996..9b5eb1b 100644--- a/WaveDude.WPF/Controls/SceneOverlay.cs+++ b/WaveDude.WPF/Controls/SceneOverlay.cs@@ -14,8 +14,9 @@ namespace WaveDude.WPF.Controls;/// <summary>/// The sources and probes of a <see cref="Project"/> drawn over a picture of the canvas, as draggable/// handles (<see cref="MarkerThumb"/>): a source's position, a point probe's point, a line probe's two-/// ends with the line between them, plus the emitters of a composite source as dots and the item names-/// as labels. Dragging a handle, or moving it with the arrow keys while it has keyboard focus, writes the+/// ends with the line between them, plus the emitters of a composite source as dots, its rotation handle on+/// the row axis (shown while the source is selected; drag turns the array; Shift snaps to 15°; the arrow keys+/// turn it by a degree, 2026-10-14) and the item names as labels. Dragging a handle, or moving it with the arrow keys while it has keyboard focus, writes the/// new canvas coordinates to the model; grabbing or focusing a handle makes its item the/// <see cref="SelectedItem"/>. The overlay fills the same rectangle as the picture (an/// <see cref="Image"/> with <see cref="Stretch.Uniform"/>), so it maps canvas pixels to its own@@ -45,6 +46,10 @@ public sealed class SceneOverlay : Panelpublic static readonly DependencyProperty SourceStyleProperty = DependencyProperty.Register(nameof(SourceStyle), typeof(Style), typeof(SceneOverlay), new PropertyMetadata(null, (d, _) => ((SceneOverlay)d).Rebuild()));+ /// <summary>Identifies the <see cref="AngleStyle"/> property.</summary>+ public static readonly DependencyProperty AngleStyleProperty = DependencyProperty.Register(+ nameof(AngleStyle), typeof(Style), typeof(SceneOverlay), new PropertyMetadata(null, (d, _) => ((SceneOverlay)d).Rebuild()));+/// <summary>Identifies the <see cref="ProbeStyle"/> property.</summary>public static readonly DependencyProperty ProbeStyleProperty = DependencyProperty.Register(nameof(ProbeStyle), typeof(Style), typeof(SceneOverlay), new PropertyMetadata(null, (d, _) => ((SceneOverlay)d).Rebuild()));@@ -65,6 +70,12 @@ public sealed class SceneOverlay : Panelprivate const int KeyStep = 1;private const int KeyStepFast = 10;private const double LabelOffset = 13.0;++ /// <summary>Least distance of a rotation handle from its source's centre, in pixels.</summary>+ private const double AngleHandleReach = 28.0;++ /// <summary>Room between the end of the first row and the rotation handle, in pixels.</summary>+ private const double AngleHandleGap = 14.0;private const double ElementDotRadius = 2.5;private static readonly Brush HaloBrush = Freeze(new SolidColorBrush(Color.FromArgb(0xC0, 0, 0, 0)));private static readonly Typeface LabelTypeface = new("Segoe UI");@@ -114,6 +125,13 @@ public sealed class SceneOverlay : Panelset => SetValue(SourceStyleProperty, value);}+ /// <summary>Style of the rotation handles of composite sources (a <see cref="MarkerThumb"/> style).</summary>+ public Style? AngleStyle+ {+ get => (Style?)GetValue(AngleStyleProperty);+ set => SetValue(AngleStyleProperty, value);+ }+/// <summary>Style of the probe handles (a <see cref="MarkerThumb"/> style).</summary>public Style? ProbeStyle{@@ -185,6 +203,10 @@ public sealed class SceneOverlay : Panel}Regenerate(source);AddThumb(source, MarkerRole.Source, SourceStyle, source.Name, "Source:" + source.Name);+ if (source.Array != null)+ {+ AddThumb(source, MarkerRole.SourceAngle, AngleStyle, source.Name, "SourceAngle:" + source.Name, "TipAngleMarkerFormat");+ }}foreach (Probe probe in project.Probes){@@ -207,10 +229,10 @@ public sealed class SceneOverlay : Panel}}- private void AddThumb(object item, MarkerRole role, Style? style, string name, string automationId)+ private void AddThumb(object item, MarkerRole role, Style? style, string name, string automationId, string tipKey = "TipMarkerFormat"){var thumb = new MarkerThumb(item, role) { Style = style };- thumb.ToolTip = TryFindResource("TipMarkerFormat") is string format ? string.Format(CultureInfo.CurrentUICulture, format, name) : name;+ thumb.ToolTip = TryFindResource(tipKey) is string format ? string.Format(CultureInfo.CurrentUICulture, format, name) : name;AutomationProperties.SetName(thumb, name);AutomationProperties.SetAutomationId(thumb, automationId);thumb.DragStarted += OnDragStarted;@@ -231,6 +253,10 @@ public sealed class SceneOverlay : Panelcase Source source:Regenerate(source);break;+ case SourceArray array when Project?.Sources.FirstOrDefault(s => ReferenceEquals(s.Array, array)) is { } owner:+ // a grid edit (size, spacing, rotation) moves the emitter dots at once+ Regenerate(owner);+ break;}if (e.PropertyName is nameof(Source.Name) or nameof(Source.Enabled) or nameof(Probe.Active)){@@ -265,6 +291,11 @@ public sealed class SceneOverlay : Panelforeach (MarkerThumb thumb in Children){thumb.IsSelectedMarker = ReferenceEquals(thumb.Item, selected);+ if (thumb.Role == MarkerRole.SourceAngle)+ {+ // the rotation handle only while its source is selected (the user's rule, 2026-10-14); collapsed, it is out of the Tab cycle too+ thumb.Visibility = thumb.IsSelectedMarker ? Visibility.Visible : Visibility.Collapsed;+ }}InvalidateVisual();}@@ -298,6 +329,39 @@ public sealed class SceneOverlay : Panel/// <summary>The centre of canvas pixel (x, y) in this element's coordinates at its current size.</summary>private Point ToView(int x, int y) => ToView(x, y, RenderSize);+ /// <summary>+ /// Where the rotation handle of a composite source sits, for an element of <paramref name="size"/>: on the+ /// array's row axis, turned by its angle (counter-clockwise on the screen), just beyond the first row's+ /// half-width and at least <see cref="AngleHandleReach"/> from the centre.+ /// </summary>+ private Point AnglePoint(Source source, Size size)+ {+ Point centre = ToView(source.X, source.Y, size);+ SourceArray array = source.Array!;+ double reach = Math.Max(AngleHandleReach, (array.SizeX - 1) / 2.0 * array.SpacingX * ScaleFor(size) + AngleHandleGap);+ double radians = array.Angle * Math.PI / 180.0;+ return new Point(centre.X + reach * Math.Cos(radians), centre.Y - reach * Math.Sin(radians));+ }++ /// <summary>Turns the array so its row axis points from the source to <paramref name="view"/>: to whole degrees, or to the nearest 15 with <paramref name="snap"/>.</summary>+ private void SetAngle(Source source, Point view, bool snap)+ {+ Point centre = ToView(source.X, source.Y);+ double degrees = Math.Atan2(-(view.Y - centre.Y), view.X - centre.X) * 180.0 / Math.PI;+ double unit = snap ? 15.0 : 1.0;+ SetAngle(source, Math.Round(degrees / unit) * unit);+ }++ /// <summary>Sets the array's angle, kept in (-180, 180].</summary>+ private static void SetAngle(Source source, double degrees)+ {+ if (source.Array is { } array)+ {+ array.Angle = degrees;+ array.Normalize();+ }+ }+private static (int X, int Y) PointOf(MarkerThumb thumb) => (thumb.Item, thumb.Role) switch{(Source source, _) => (source.X, source.Y),@@ -343,7 +407,7 @@ public sealed class SceneOverlay : Panelforeach (MarkerThumb thumb in Children){(int x, int y) = PointOf(thumb);- Point centre = ToView(x, y, finalSize);+ Point centre = thumb.Role == MarkerRole.SourceAngle ? AnglePoint((Source)thumb.Item, finalSize) : ToView(x, y, finalSize);Size size = thumb.DesiredSize;thumb.Arrange(new Rect(centre.X - size.Width / 2, centre.Y - size.Height / 2, size.Width, size.Height));}@@ -378,8 +442,16 @@ public sealed class SceneOverlay : Panel{continue;}- Brush dots = ReferenceEquals(source, selected) ? AccentBrush : LineBrush;+ bool isSelected = ReferenceEquals(source, selected);+ Brush dots = isSelected ? AccentBrush : LineBrush;var halo = new Pen(HaloBrush, 1.5);+ if (isSelected)+ {+ // the row axis from the centre to the rotation handle, so the turn reads as a lever; with the handle, only while selected+ Point axisEnd = AnglePoint(source, RenderSize);+ dc.DrawLine(new Pen(HaloBrush, 3.0), ToView(source.X, source.Y), axisEnd);+ dc.DrawLine(new Pen(dots, 1.0) { DashStyle = DashStyles.Dot }, ToView(source.X, source.Y), axisEnd);+ }foreach (SourceElement element in source.Elements){dc.DrawEllipse(dots, halo, ToView(element.X, element.Y), ElementDotRadius, ElementDotRadius);@@ -387,7 +459,7 @@ public sealed class SceneOverlay : Panel}foreach (MarkerThumb thumb in Children){- if (thumb.Role == MarkerRole.ProbeB)+ if (thumb.Role is MarkerRole.ProbeB or MarkerRole.SourceAngle){continue;}@@ -395,8 +467,10 @@ public sealed class SceneOverlay : PanelPoint centre = ToView(x, y);string name = thumb.Item is Source source ? source.Name : ((Probe)thumb.Item).Name;var label = new FormattedText(name, CultureInfo.CurrentUICulture, FlowDirection.LeftToRight, LabelTypeface, 11, thumb.IsSelectedMarker ? AccentBrush : LabelBrush, VisualTreeHelper.GetDpi(this).PixelsPerDip);- double lx = Math.Min(centre.X + LabelOffset, Math.Max(0, ActualWidth - label.Width));- double ly = Math.Clamp(centre.Y - label.Height / 2, 0, Math.Max(0, ActualHeight - label.Height));+ // beside the point; below it for a composite source, whose rotation handle sits beside it at 0 degrees+ bool below = thumb.Item is Source { Array: not null };+ double lx = below ? Math.Clamp(centre.X - label.Width / 2, 0, Math.Max(0, ActualWidth - label.Width)) : Math.Min(centre.X + LabelOffset, Math.Max(0, ActualWidth - label.Width));+ double ly = below ? Math.Min(centre.Y + LabelOffset, Math.Max(0, ActualHeight - label.Height)) : Math.Clamp(centre.Y - label.Height / 2, 0, Math.Max(0, ActualHeight - label.Height));var origin = new Point(lx, ly);// the text's outline in dark first (a halo), then the textdc.DrawGeometry(null, new Pen(HaloBrush, 3.0) { LineJoin = PenLineJoin.Round }, label.BuildGeometry(origin));@@ -424,6 +498,12 @@ public sealed class SceneOverlay : Panel{return;}+ if (thumb.Role == MarkerRole.SourceAngle)+ {+ // the handle follows the mouse around the centre; Shift snaps to 15 degrees+ SetAngle((Source)thumb.Item, Mouse.GetPosition(this), (Keyboard.Modifiers & ModifierKeys.Shift) != 0);+ return;+ }thumb.DragDeltaX += e.HorizontalChange / scale;thumb.DragDeltaY += e.VerticalChange / scale;SetPoint(thumb, thumb.DragStartX + (int)Math.Round(thumb.DragDeltaX), thumb.DragStartY + (int)Math.Round(thumb.DragDeltaY));@@ -435,7 +515,7 @@ public sealed class SceneOverlay : Panelreturn brush;}- /// <summary>The arrow keys move the focused handle by one canvas pixel, ten with Shift.</summary>+ /// <summary>The arrow keys move the focused handle by one canvas pixel, ten with Shift; on a rotation handle they turn the array by a degree (Right and Up counter-clockwise), ten with Shift.</summary>protected override void OnKeyDown(KeyEventArgs e){base.OnKeyDown(e);@@ -444,6 +524,16 @@ public sealed class SceneOverlay : Panelreturn;}int step = (Keyboard.Modifiers & ModifierKeys.Shift) != 0 ? KeyStepFast : KeyStep;+ if (thumb.Role == MarkerRole.SourceAngle)+ {+ int turn = e.Key switch { Key.Right or Key.Up => step, Key.Left or Key.Down => -step, _ => 0 };+ if (turn != 0 && thumb.Item is Source turned)+ {+ SetAngle(turned, (turned.Array?.Angle ?? 0.0) + turn);+ e.Handled = true;+ }+ return;+ }(int dx, int dy) = e.Key switch{Key.Left => (-step, 0),diff --git a/WaveDude.WPF/Panes/PreviewPane.xaml b/WaveDude.WPF/Panes/PreviewPane.xamlindex c1b297a..7b895c2 100644--- a/WaveDude.WPF/Panes/PreviewPane.xaml+++ b/WaveDude.WPF/Panes/PreviewPane.xaml@@ -151,6 +151,21 @@</Setter.Value></Setter></Style>+ <StreamGeometry x:Key="AngleGlyph">M15,10 A5,5 0 1 1 12.5,5.67 M12.5,5.67 L9.2,5.3 M12.5,5.67 L13,9</StreamGeometry>+ <Style x:Key="AngleMarker" TargetType="{x:Type controls:MarkerThumb}" BasedOn="{StaticResource MarkerBase}">+ <Setter Property="Cursor" Value="Hand" />+ <Setter Property="Template">+ <Setter.Value>+ <ControlTemplate TargetType="{x:Type controls:MarkerThumb}">+ <Grid Background="Transparent">+ <Ellipse Width="14" Height="14" Fill="{TemplateBinding Background}" />+ <Path Data="{StaticResource AngleGlyph}" Stroke="Black" StrokeThickness="{TemplateBinding HaloThickness}" StrokeStartLineCap="Round" StrokeEndLineCap="Round" StrokeLineJoin="Round" Opacity="0.75" />+ <Path Data="{StaticResource AngleGlyph}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{TemplateBinding StrokeThickness}" StrokeStartLineCap="Round" StrokeEndLineCap="Round" StrokeLineJoin="Round" />+ </Grid>+ </ControlTemplate>+ </Setter.Value>+ </Setter>+ </Style><Style x:Key="ProbeMarker" TargetType="{x:Type controls:MarkerThumb}" BasedOn="{StaticResource MarkerBase}"><Setter Property="Template"><Setter.Value>@@ -351,7 +366,7 @@<Image Source="{Binding Path=(local:PreviewPane.OverlayImage), RelativeSource={RelativeSource TemplatedParent}}"Stretch="Uniform" IsHitTestVisible="False" /><!-- styled here, not implicitly: WPF applies implicit styles inside a template only to Controls, and the overlay is a Panel -->- <controls:SceneOverlay SourceStyle="{StaticResource SourceMarker}" ProbeStyle="{StaticResource ProbeMarker}"+ <controls:SceneOverlay SourceStyle="{StaticResource SourceMarker}" ProbeStyle="{StaticResource ProbeMarker}" AngleStyle="{StaticResource AngleMarker}"LineBrush="White" LabelBrush="White" AccentBrush="{DynamicResource Accent}"Project="{Binding Project, RelativeSource={RelativeSource AncestorType={x:Type local:PreviewPane}}}"CanvasWidth="{Binding CanvasWidth, RelativeSource={RelativeSource AncestorType={x:Type local:PreviewPane}}}"diff --git a/WaveDude.WPF/Strings/Strings.DE.xaml b/WaveDude.WPF/Strings/Strings.DE.xamlindex 36f535d..f3b9c3b 100644--- a/WaveDude.WPF/Strings/Strings.DE.xaml+++ b/WaveDude.WPF/Strings/Strings.DE.xaml@@ -86,6 +86,7 @@<s:String x:Key="TipPreviewShowField">Feldbild anzeigen</s:String><s:String x:Key="TipPreviewShowIntensity">Intensitätsbild anzeigen</s:String><s:String x:Key="TipMarkerFormat">{0}: zum Verschieben ziehen; mit Tastaturfokus bewegen die Pfeiltasten um ein Pixel, mit Umschalt um zehn</s:String>+ <s:String x:Key="TipAngleMarkerFormat">{0}: zum Drehen des Rasters ziehen (Umschalt rastet auf 15 Grad ein); mit Tastaturfokus drehen die Pfeiltasten um ein Grad, mit Umschalt um zehn</s:String><s:String x:Key="LabelPreviewStep">Schritt</s:String><s:String x:Key="TipPreviewStep">Simulationsschritt des gezeigten Bildes</s:String><s:String x:Key="TipPreviewSplitter">Ziehen oder Pfeiltasten zum Umverteilen; Doppelklick oder Eingabe setzt auf die Mitte zurück</s:String>@@ -310,6 +311,8 @@<s:String x:Key="Hint.SourceArray.SpacingX">Abstand benachbarter Spalten in Leinwandpixeln.</s:String><s:String x:Key="Label.SourceArray.SpacingY">Vertikaler Abstand</s:String><s:String x:Key="Hint.SourceArray.SpacingY">Abstand benachbarter Zeilen in Leinwandpixeln.</s:String>+ <s:String x:Key="Label.SourceArray.Angle">Drehung</s:String>+ <s:String x:Key="Hint.SourceArray.Angle">Drehung des Rasters um die Quellposition in Grad, auf dem Bildschirm gegen den Uhrzeigersinn. 0 lässt die Zeilen waagerecht.</s:String><s:String x:Key="Label.SourceArray.RandomFrequency">Frequenz</s:String><s:String x:Key="Hint.SourceArray.RandomFrequency">Die Stufe jedes Strahlers wird um bis zu ± diesen Betrag versetzt. 0 schaltet es ab.</s:String><s:String x:Key="Label.SourceArray.RandomPhase">Phase</s:String>diff --git a/WaveDude.WPF/Strings/Strings.EN.xaml b/WaveDude.WPF/Strings/Strings.EN.xamlindex ab0602c..c3036d5 100644--- a/WaveDude.WPF/Strings/Strings.EN.xaml+++ b/WaveDude.WPF/Strings/Strings.EN.xaml@@ -86,6 +86,7 @@<s:String x:Key="TipPreviewShowField">Show the field picture</s:String><s:String x:Key="TipPreviewShowIntensity">Show the intensity picture</s:String><s:String x:Key="TipMarkerFormat">{0}: drag to move; with keyboard focus the arrow keys move it by a pixel, ten with Shift</s:String>+ <s:String x:Key="TipAngleMarkerFormat">{0}: drag to turn the array (Shift snaps to 15 degrees); with keyboard focus the arrow keys turn it by a degree, ten with Shift</s:String><s:String x:Key="LabelPreviewStep">step</s:String><s:String x:Key="TipPreviewStep">Simulation step of the frame shown</s:String><s:String x:Key="TipPreviewSplitter">Drag or use the arrow keys to resize; double-click or Enter resets to half</s:String>@@ -310,6 +311,8 @@<s:String x:Key="Hint.SourceArray.SpacingX">Distance between neighbouring columns in canvas pixels.</s:String><s:String x:Key="Label.SourceArray.SpacingY">Vertical spacing</s:String><s:String x:Key="Hint.SourceArray.SpacingY">Distance between neighbouring rows in canvas pixels.</s:String>+ <s:String x:Key="Label.SourceArray.Angle">Rotation</s:String>+ <s:String x:Key="Hint.SourceArray.Angle">Rotation of the grid about the source position in degrees, counter-clockwise on the screen. 0 keeps the rows horizontal.</s:String><s:String x:Key="Label.SourceArray.RandomFrequency">Frequency</s:String><s:String x:Key="Hint.SourceArray.RandomFrequency">Each emitter's level is offset by up to ± this amount. 0 turns it off.</s:String><s:String x:Key="Label.SourceArray.RandomPhase">Phase</s:String>diff --git a/WaveDude.WPF/Strings/Strings.FR.xaml b/WaveDude.WPF/Strings/Strings.FR.xamlindex 788c7e0..25f6d35 100644--- a/WaveDude.WPF/Strings/Strings.FR.xaml+++ b/WaveDude.WPF/Strings/Strings.FR.xaml@@ -86,6 +86,7 @@<s:String x:Key="TipPreviewShowField">Afficher l'image du champ</s:String><s:String x:Key="TipPreviewShowIntensity">Afficher l'image de l'intensité</s:String><s:String x:Key="TipMarkerFormat">{0} : glisser pour déplacer ; avec le focus clavier, les flèches déplacent d'un pixel, de dix avec Maj</s:String>+ <s:String x:Key="TipAngleMarkerFormat">{0} : glisser pour tourner la grille (Maj aligne sur 15 degrés) ; avec le focus clavier, les flèches la tournent d'un degré, de dix avec Maj</s:String><s:String x:Key="LabelPreviewStep">pas</s:String><s:String x:Key="TipPreviewStep">Pas de simulation de l'image affichée</s:String><s:String x:Key="TipPreviewSplitter">Glisser ou utiliser les flèches pour redimensionner ; double-clic ou Entrée remet au milieu</s:String>@@ -310,6 +311,8 @@<s:String x:Key="Hint.SourceArray.SpacingX">Distance entre colonnes voisines en pixels de toile.</s:String><s:String x:Key="Label.SourceArray.SpacingY">Espacement vertical</s:String><s:String x:Key="Hint.SourceArray.SpacingY">Distance entre lignes voisines en pixels de toile.</s:String>+ <s:String x:Key="Label.SourceArray.Angle">Rotation</s:String>+ <s:String x:Key="Hint.SourceArray.Angle">Rotation de la grille autour de la position de la source en degrés, dans le sens antihoraire à l'écran. 0 garde les lignes horizontales.</s:String><s:String x:Key="Label.SourceArray.RandomFrequency">Fréquence</s:String><s:String x:Key="Hint.SourceArray.RandomFrequency">Le niveau de chaque émetteur est décalé d'au plus ± cette valeur. 0 désactive.</s:String><s:String x:Key="Label.SourceArray.RandomPhase">Phase</s:String>diff --git a/WaveDude.WPF/Strings/Strings.NL.xaml b/WaveDude.WPF/Strings/Strings.NL.xamlindex 47d6d05..872e752 100644--- a/WaveDude.WPF/Strings/Strings.NL.xaml+++ b/WaveDude.WPF/Strings/Strings.NL.xaml@@ -86,6 +86,7 @@<s:String x:Key="TipPreviewShowField">Veldbeeld tonen</s:String><s:String x:Key="TipPreviewShowIntensity">Intensiteitsbeeld tonen</s:String><s:String x:Key="TipMarkerFormat">{0}: slepen om te verplaatsen; met toetsenbordfocus verplaatsen de pijltoetsen één pixel, tien met Shift</s:String>+ <s:String x:Key="TipAngleMarkerFormat">{0}: slepen om het raster te draaien (Shift klikt vast op 15 graden); met toetsenbordfocus draaien de pijltoetsen het één graad, tien met Shift</s:String><s:String x:Key="LabelPreviewStep">stap</s:String><s:String x:Key="TipPreviewStep">Simulatiestap van het getoonde beeld</s:String><s:String x:Key="TipPreviewSplitter">Slepen of pijltoetsen om de verdeling te wijzigen; dubbelklik of Enter zet terug op de helft</s:String>@@ -310,6 +311,8 @@<s:String x:Key="Hint.SourceArray.SpacingX">Afstand tussen naburige kolommen in canvaspixels.</s:String><s:String x:Key="Label.SourceArray.SpacingY">Verticale afstand</s:String><s:String x:Key="Hint.SourceArray.SpacingY">Afstand tussen naburige rijen in canvaspixels.</s:String>+ <s:String x:Key="Label.SourceArray.Angle">Rotatie</s:String>+ <s:String x:Key="Hint.SourceArray.Angle">Rotatie van het raster om de bronpositie in graden, tegen de klok in op het scherm. 0 houdt de rijen horizontaal.</s:String><s:String x:Key="Label.SourceArray.RandomFrequency">Frequentie</s:String><s:String x:Key="Hint.SourceArray.RandomFrequency">Het niveau van elke emitter wordt tot ± dit bedrag verschoven. 0 schakelt het uit.</s:String><s:String x:Key="Label.SourceArray.RandomPhase">Fase</s:String>diff --git a/WaveDude.WPF/Views/SourceView.xaml b/WaveDude.WPF/Views/SourceView.xamlindex 87d007f..e754c89 100644--- a/WaveDude.WPF/Views/SourceView.xaml+++ b/WaveDude.WPF/Views/SourceView.xaml@@ -110,6 +110,9 @@<TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:SourceArray.SpacingY}" /><controls:NumberBox Text="{Binding SpacingY}" ToolTip="{meta:Hint model:SourceArray.SpacingY}" />+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:SourceArray.Angle}" />+ <controls:NumberBox Text="{Binding Angle}" Minimum="-180" Maximum="180" Increment="5" ToolTip="{meta:Hint model:SourceArray.Angle}" />+<!-- the four random amounts are offsets added per emitter on top of the values above (the author's point 9) --><TextBlock controls:FormPanel.FullWidth="True" Style="{StaticResource FormSection}" Text="{DynamicResource SectionRandom}" />diff --git a/WaveDude/Model/Source.cs b/WaveDude/Model/Source.csindex 9dcbf25..242ab37 100644--- a/WaveDude/Model/Source.cs+++ b/WaveDude/Model/Source.cs@@ -262,7 +262,8 @@ public sealed class Source : ObservableObject/// <summary>/// Rebuilds <see cref="Elements"/>: one emitter for a single source, or the array grid- /// centred on (<see cref="X"/>, <see cref="Y"/>) with the array's random offsets applied.+ /// centred on (<see cref="X"/>, <see cref="Y"/>), rotated by the array's <see cref="SourceArray.Angle"/>+ /// (counter-clockwise on the screen, whose y axis points down), with the random offsets applied./// Deterministic for a given project seed, name and settings./// </summary>public void GenerateElements(int projectSeed)@@ -276,13 +277,19 @@ public sealed class Source : ObservableObject}else{+ double radians = array.Angle * Math.PI / 180.0;+ double cos = Math.Cos(radians);+ double sin = Math.Sin(radians);for (int row = 0; row < array.SizeY; row++){for (int column = 0; column < array.SizeX; column++){- // grid centred on (X, Y); with an even size the centre falls between two emitters- int x = X + (int)Math.Round((column - (array.SizeX - 1) / 2.0) * array.SpacingX);- int y = Y + (int)Math.Round((row - (array.SizeY - 1) / 2.0) * array.SpacingY);+ // grid centred on (X, Y); with an even size the centre falls between two emitters. Rotated about the+ // centre: with y pointing down, a counter-clockwise turn on the screen is x' = x cos + y sin, y' = y cos - x sin+ double dx = (column - (array.SizeX - 1) / 2.0) * array.SpacingX;+ double dy = (row - (array.SizeY - 1) / 2.0) * array.SpacingY;+ int x = X + (int)Math.Round(dx * cos + dy * sin);+ int y = Y + (int)Math.Round(dy * cos - dx * sin);elements.Add(new SourceElement{X = x + Jitter(rng, array.RandomPosition),@@ -324,6 +331,7 @@ public sealed class SourceArray : ObservableObjectprivate int _sizeY = 1;private int _spacingX = DefaultSpacing;private int _spacingY = DefaultSpacing;+ private double _angle;private int _randomFrequency;private int _randomPhase;private int _randomOffWidth;@@ -377,6 +385,18 @@ public sealed class SourceArray : ObservableObjectset => SetProperty(ref _spacingY, value);}+ /// <summary>Rotation of the grid about the source position in degrees, counter-clockwise as seen on the screen; 0 keeps the rows horizontal (2026-10-14, the user's request).</summary>+ [XmlAttribute]+ [DefaultValue(0.0)]+ [Category("Grid")]+ [DisplayName("Rotation")]+ [Description("Rotation of the grid about the source position in degrees, counter-clockwise on the screen. 0 keeps the rows horizontal.")]+ public double Angle+ {+ get => _angle;+ set => SetProperty(ref _angle, value);+ }+/// <summary>Half-range of the per-emitter frequency offset in levels; 0 turns it off.</summary>[XmlAttribute][DefaultValue(0)]@@ -430,11 +450,19 @@ public sealed class SourceArray : ObservableObject[Browsable(false)]public bool IsRandomized => RandomFrequency > 0 || RandomPhase > 0 || RandomOffWidth > 0 || RandomPosition > 0;- /// <summary>Clamps every value into its valid range.</summary>+ /// <summary>Clamps every value into its valid range; the angle is brought into (-180, 180].</summary>public void Normalize(){SizeX = Math.Max(1, SizeX);SizeY = Math.Max(1, SizeY);+ if (!double.IsFinite(Angle))+ {+ Angle = 0.0;+ }+ else if (Angle <= -180.0 || Angle > 180.0)+ {+ Angle = Angle - 360.0 * Math.Ceiling((Angle - 180.0) / 360.0);+ }RandomFrequency = Math.Max(0, RandomFrequency);RandomPhase = Math.Max(0, RandomPhase);RandomOffWidth = Math.Max(0, RandomOffWidth);