From 97a0b2fee5dd9d9db19e80bf59cd9f13e7a34301 Mon Sep 17 00:00:00 2001 From: That-One-Nerd Date: Mon, 10 Jul 2023 16:34:07 -0400 Subject: [PATCH] Fixed some blunders and finished #31. --- Changelog.md | 11 +++++++++++ Nerd_STF/Mathematics/Abstract/IMatrix.cs | 1 + Nerd_STF/Mathematics/Algebra/Matrix.cs | 7 ++++++- Nerd_STF/Mathematics/Algebra/Matrix2x2.cs | 4 ++-- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Changelog.md b/Changelog.md index 66fb4ad..4440fd6 100644 --- a/Changelog.md +++ b/Changelog.md @@ -6,10 +6,21 @@ Here's the full changelog: ``` * Nerd_STF * Mathematics + * Abstract + * IMatrix + + Cofactor() + * Algebra + * Matrix + = Fixed a blunder in `SignGrid(Int2)` with signs being incorrectly placed on matrixes with even column count. + * Matrix2x2 + = Fixed a blunder in `Cofactor()` with the position of elements. * NumberSystems * Complex + operator Complex(SystemComplex) + operator SystemComplex(Complex) + * Quaternion + + operator Quaternion(SystemQuaternion) + + operator SystemQuaternion(Quaternion) * Float3 = Added a setter to `XY` = Added a setter to `XZ` diff --git a/Nerd_STF/Mathematics/Abstract/IMatrix.cs b/Nerd_STF/Mathematics/Abstract/IMatrix.cs index 84429c2..34974f5 100644 --- a/Nerd_STF/Mathematics/Abstract/IMatrix.cs +++ b/Nerd_STF/Mathematics/Abstract/IMatrix.cs @@ -6,6 +6,7 @@ public interface IMatrix : IAbsolute, ICeiling, IClamp, IDivide, where T : IMatrix { public T Adjugate(); + public T Cofactor(); public float Determinant(); public T? Inverse(); public T Transpose(); diff --git a/Nerd_STF/Mathematics/Algebra/Matrix.cs b/Nerd_STF/Mathematics/Algebra/Matrix.cs index 3d13abc..b48d138 100644 --- a/Nerd_STF/Mathematics/Algebra/Matrix.cs +++ b/Nerd_STF/Mathematics/Algebra/Matrix.cs @@ -20,7 +20,12 @@ public class Matrix : IMatrix return m; } public static Matrix One(Int2 size) => new(size, 1); - public static Matrix SignGrid(Int2 size) => new(size, Fills.SignFill); + public static Matrix SignGrid(Int2 size) => new(size, delegate (int x) + { + float sgnValue = Fills.SignFill(x); + if (size.y % 2 == 0 && x / size.y % 2 == 1) sgnValue *= -1; + return sgnValue; + }); public static Matrix Zero(Int2 size) => new(size); public bool HasMinors => Size.x > 1 && Size.y > 1; diff --git a/Nerd_STF/Mathematics/Algebra/Matrix2x2.cs b/Nerd_STF/Mathematics/Algebra/Matrix2x2.cs index 620b6a2..f842a94 100644 --- a/Nerd_STF/Mathematics/Algebra/Matrix2x2.cs +++ b/Nerd_STF/Mathematics/Algebra/Matrix2x2.cs @@ -223,8 +223,8 @@ public record class Matrix2x2 : IStaticMatrix { Matrix2x2 swapped = new(new[,] { - { r2c2, r1c2 }, - { r2c1, r1c1 } + { r2c2, r2c1 }, + { r1c2, r1c1 } }); return swapped ^ SignGrid; }