Skip to content

SharpMath 2.0: .NET 10, immutable geometry, cross-platform canvas renderers - #10

Merged
dbforge merged 14 commits into
masterfrom
refactor/v2
Oct 11, 2026
Merged

dbforge merged 14 commits into
masterfrom
refactor/v2

Conversation

@begerdom

@begerdom begerdom commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

SharpMath 2.0 is a rewrite for .NET 10 (C# 14). It is a breaking release; CHANGELOG.md lists every change and works as a migration guide from 1.x.

Highlights

  • Five assemblies: SharpMath (no dependencies), SharpMath.Canvas (model + SVG), SharpMath.Canvas.Skia, SharpMath.Canvas.WinForms (GDI+), SharpMath.Canvas.Avalonia.
  • Immutable vectors, points and matrices with System.Numerics-style names, column-vector convention, closed-form determinants/inverses and tolerance-based predicates.
  • New MatrixMxN (LU), Line2D in general form, LineSegment2D, canonical Line3D, intersection results.
  • Rewritten expression parser: variables, implicit multiplication, ExpressionContext, allocation-free evaluation, error positions.
  • Platform-neutral canvas rendering through IDrawingContext with SVG, SkiaSharp and GDI+ renderers, WinForms and Avalonia controls, PNG/SVG export.
  • About 50 bugs fixed, e.g. Inverse() returning the identity and Polygon == overflowing the stack.

Verification

  • xUnit v3 tests incl. CsCheck property tests and zero-allocation tests; ≥ 90 % line coverage gate (currently 99 %).
  • GitHub Actions on Windows, Linux and macOS.
  • Benchmarks in doc/benchmarks.md.

Fixes #3
Refs #9, #5

Vectors, points and matrices become readonly structs with System.Numerics
vocabulary, closed-form determinants and inverses, column-vector convention
and tolerance-based predicates. Adds MatrixMxN, LineSegment2D, general-form
Line2D, canonical Line3D and intersection results. Removes Analysis, MathHelper,
FloatingNumber and the generic matrix/vector utilities.
Recursive-descent parser with variables, parse-once/evaluate-many,
implicit multiplication, comma-separated arguments, scientific notation,
modulo, factorial, more built-ins and per-instance ExpressionContext.
Every syntax error is a ParserException with a position.
Canvas2D now renders through IDrawingContext and owns viewport, grid,
nice-number ticks, function sampling with pole detection, clipping and
input handling. Fixes the zoom drift and overflows from issue #3 (Fixes #3).
Adds geometry and expression items and a configurable style.
The view records the canvas on the UI thread into a display list and
replays it with the Skia renderer on Avalonia's render thread.
CsCheck checks algebraic invariants of matrices, geometry and the parser.
Allocation tests guard the hot paths; evaluating with a named variable no
longer allocates a closure. eng/CheckCoverage.cs enforces line coverage.
…ples

The perspective demo now uses the column-vector convention, LookAt and the
right-handed projection. The export sample renders the README images.
Polygon.Contains caches the largest coordinate of the polygon and computes
the border tolerance once per call instead of once per edge; the function
sampler reuses its buffers, so rendering no longer allocates per frame.
… Linux and macOS

The outdated 1.x screenshots in the repository root are replaced by the
images the export sample generates in doc/images.
@dbforge
dbforge merged commit 8001b11 into master Oct 11, 2026
6 checks passed
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.

Canvas2D sometimes throws an OverflowException

2 participants