Browse Source

ADDED: `Vector2Transform()`

Ray 3 years ago
parent
commit
8ee0eb8f36
1 changed files with 15 additions and 0 deletions
  1. 15 0
      src/raymath.h

+ 15 - 0
src/raymath.h

@@ -334,6 +334,21 @@ RMAPI Vector2 Vector2Normalize(Vector2 v)
     return result;
 }
 
+// Transforms a Vector2 by a given Matrix
+Vector2 Vector2Transform(Vector2 v, Matrix mat)
+{
+	Vector2 result = { 0 };
+
+	float x = v.x;
+	float y = v.y;
+	float z = 0;
+
+	result.x = mat.m0*x + mat.m4*y + mat.m8*z + mat.m12;
+	result.y = mat.m1*x + mat.m5*y + mat.m9*z + mat.m13;
+
+	return result;
+}
+
 // Calculate linear interpolation between two vectors
 RMAPI Vector2 Vector2Lerp(Vector2 v1, Vector2 v2, float amount)
 {