From 91d37e2f17ca0e3d9f122c54268356edb1fd2978 Mon Sep 17 00:00:00 2001 From: bonmas14 Date: Wed, 25 Oct 2023 01:02:43 +0300 Subject: full left-to-right order in matrix x vector multiplication --- AudioTester/Program.cs | 4 ++-- RayRoom/Core/Matrix2x2.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/AudioTester/Program.cs b/AudioTester/Program.cs index 7557142..14212af 100644 --- a/AudioTester/Program.cs +++ b/AudioTester/Program.cs @@ -28,8 +28,8 @@ namespace AudioTester for (int i = 0; i < array.Length; i++) { - g.DrawLine(background, (mat * array[i].a + new Vector2(1000, 1000)).GetPoint(), (mat * array[i].b + new Vector2(1000, 1000)).GetPoint()); - g.DrawLine(foreground, (mat * array[i].a + new Vector2(1000, 1000)).GetPoint(), (mat * array[i].b + new Vector2(1000, 1000)).GetPoint()); + g.DrawLine(background, (array[i].a * mat + new Vector2(1000, 1000)).GetPoint(), (array[i].b * mat + new Vector2(1000, 1000)).GetPoint()); + g.DrawLine(foreground, (array[i].a * mat + new Vector2(1000, 1000)).GetPoint(), (array[i].b * mat + new Vector2(1000, 1000)).GetPoint()); } } diff --git a/RayRoom/Core/Matrix2x2.cs b/RayRoom/Core/Matrix2x2.cs index 4a5639a..d2ef642 100644 --- a/RayRoom/Core/Matrix2x2.cs +++ b/RayRoom/Core/Matrix2x2.cs @@ -26,14 +26,14 @@ namespace AudioTester public readonly float Determinant => (a*d) - (b*c); - public static Vector2 operator*(Matrix2x2 matrix, Vector2 vector) + public static Vector2 operator*(Vector2 vector, Matrix2x2 matrix) { return new Vector2(matrix.a, matrix.c) * vector.X + new Vector2(matrix.b, matrix.d) * vector.Y; } public static Matrix2x2 operator*(Matrix2x2 a, Matrix2x2 b) { - return new Matrix2x2(b * new Vector2(a.a, a.c), b * new Vector2(a.b, a.d)); + return new Matrix2x2(new Vector2(a.a, a.c) * b, new Vector2(a.b, a.d) * b); } } } \ No newline at end of file -- cgit v1.2.3-70-g09d2