PeachDrawing.Core

PeachDrawing.Core

Matrix3x2Extensions Class

The two composition helpers the former RMatrix type had that System.Numerics.Matrix3x2 does not: a named “apply this first” alias for value1 * value2 (the same row-vector convention System.Numerics.Matrix3x2’s own operator * already uses - a.Then(b) and a * b compute identical results), and re-basing a transform’s fixed point without touching its linear part. TryInvert(this Matrix3x2, Matrix3x2) is a from-scratch reimplementation, not a thin wrapper over System.Numerics.Matrix3x2.Invert(System.Numerics.Matrix3x2,System.Numerics.Matrix3x2@): the BCL method’s own near-singular guard (MathF.Abs(det) < float.Epsilon) does not reject a NaN determinant (a NaN comparison is always false, so the guard is skipped and the division silently produces a NaN matrix instead of failing), which the CSS matrix()/transform pipeline relies on failing cleanly for.

public static class Matrix3x2Extensions

Inheritance System.Object → Matrix3x2Extensions

Methods  
RebaseOrigin(this Matrix3x2, double, double) Reinterprets this matrix - built treating the box’s own top-left corner as local (0, 0) - as pivoting around the given absolute (page-space) point instead. Equivalent to translate(-px,-py) * this * translate(px,py): the linear part (M11/M12/M21/M22) is unchanged, only the offset shifts so that (px, py) becomes a fixed point wherever it sits on the page. Needed because painting draws in absolute page coordinates, and a box’s page position (its Bounds plus the current page’s scroll offset) can vary across repeated paint passes (e.g. pagination), while the underlying matrix itself is cached and computed once.
Then(this Matrix3x2, Matrix3x2) The transform that applies this one first and next after it.
TryInvert(this Matrix3x2, Matrix3x2) The transform that undoes this one; false when it collapses the plane (or is not finite) and has none.