Skip to content

Handle calm and invalid GRAMM wind in section drawing - #95

Closed
Borealis-Thoon wants to merge 2 commits into
GralDispersionModel:V2701from
Borealis-Thoon:codex/fix-gramm-section-calm-wind
Closed

Borealis-Thoon wants to merge 2 commits into
GralDispersionModel:V2701from
Borealis-Thoon:codex/fix-gramm-section-calm-wind

Conversation

@Borealis-Thoon

@Borealis-Thoon Borealis-Thoon commented Sep 14, 2026 •

Copy link
Copy Markdown

A GRAMM section crossing a cell with u = v = 0 can throw OverflowException when Vector3D.AngleBetween returns NaN and the arrow length is converted to Int32. The change uses direct projection, validates drawing values, and displays a warning when invalid vectors are omitted. It retains the Windows unsigned transverse colour convention and displays vertical-only wind.

Following the review, I compared this with a Windows build using only the legacy MONO angle code. Yes, Math.Atan2(0, 0) avoids the reported calm-wind exception. That candidate passes six synthetic comparison cases and five sections from the example 00021.wnd. It still throws on NaN wind and excessive scaling, and its signed transverse component changes the Windows colour convention. Direct projection gives the same finite along-section component without the angle conversion and trigonometry, so I retained the guards and added the MONO comparison to the regression suite.

The base is now V2701. The PR contains only drawing code and tests; it is independent of the source-group work.

Validation on Windows/.NET 10.0.9:

  • 14 patched regression cases, including 10000 finite-vector comparisons, calm and vertical-only wind, invalid data, degenerate sections, excessive scaling, and legend handling.
  • Six MONO-only comparison cases, including expected remaining failures for invalid input and scaling.
  • Five real-field section cases for each candidate. The input wind field was unchanged.
  • Release build succeeds with the same nine warnings as the baseline.

Reproduction instructions

Tests call actual paint functions offscreen. Linux/Mono runtime execution, the reported .NET 10.0.12 environment, and every interactive workflow remain untested. Normal finite-vector results are equivalent within floating-point rounding; exact pixel identity is not a general guarantee. This contribution changes no upstream version labels or source-group behavior.

@MarkusKuntner MarkusKuntner added bug Something isn't working and removed bug Something isn't working labels Sep 14, 2026
@MarkusKuntner

Copy link
Copy Markdown
Member

Thank you very much for all your hard work; we had never noticed this bug before, probably because we rarely use the section view. Other bugs have been fixed in the current development branch, V2701.
I’ll study your code and will be happy to merge it. Is it possible that the fix would also work if you simply use the old MONO code? Could you please submit the pull request into the V2701 development branch?
Best regards
Markus

@Borealis-Thoon
Borealis-Thoon changed the base branch from main to V2701 September 15, 2026 02:49
@Borealis-Thoon Borealis-Thoon changed the title fix gramm section calm wind Handle calm and invalid GRAMM wind in section drawing Sep 15, 2026
@MarkusKuntner

Copy link
Copy Markdown
Member

I solved the problem, there are just a view lines of codes changed, see commit a95e6de
I would therefore close this pull request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants