diff options
| author | Ray <[email protected]> | 2022-01-15 22:12:58 +0100 |
|---|---|---|
| committer | Ray <[email protected]> | 2022-01-15 22:12:58 +0100 |
| commit | 8ee0eb8f36e65e45d3ab0ed35b9d8dbf219d19c1 (patch) | |
| tree | 3f9c7ec351b9756dc251bc9de68a21d70b469e5f /src/raymath.h | |
| parent | f4dea6919a34fa8c77cad8a589e5f4c20595988c (diff) | |
| download | raylib-8ee0eb8f36e65e45d3ab0ed35b9d8dbf219d19c1.tar.gz raylib-8ee0eb8f36e65e45d3ab0ed35b9d8dbf219d19c1.zip | |
ADDED: `Vector2Transform()`
Diffstat (limited to 'src/raymath.h')
| -rw-r--r-- | src/raymath.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/raymath.h b/src/raymath.h index 9b86b293..d0d34e34 100644 --- a/src/raymath.h +++ b/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) { |
