From 0fb7e98cb519735d41fbcc33f19927b241acd656 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Tue, 15 Mar 2022 23:02:38 -0700 Subject: [PATCH] add Vector2.Transform Matrix3x2 overload --- src/Math/Vector2.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Math/Vector2.cs b/src/Math/Vector2.cs index 0749cad..89c4a3c 100644 --- a/src/Math/Vector2.cs +++ b/src/Math/Vector2.cs @@ -877,6 +877,20 @@ namespace MoonWorks.Math result.Y = value.Y + y * rotation.W + (rotation.Z * x - rotation.X * z); } + /// + /// Creates a new that contains a transformation of 2d-vector by the specified . + /// + /// Source . + /// The transformation . + /// Transformed . + public static Vector2 Transform(Vector2 position, Matrix3x2 matrix) + { + return new Vector2( + (position.X * matrix.M11) + (position.Y * matrix.M21) + matrix.M31, + (position.X * matrix.M12) + (position.Y * matrix.M22) + matrix.M32 + ); + } + /// /// Apply transformation on all vectors within array of by the specified and places the results in an another array. ///