diff options
| author | Jaedeok Kim <[email protected]> | 2022-02-14 02:43:17 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-02-13 18:43:17 +0100 |
| commit | b54e9db7647ae6e5ed86a8a5d92dbd63157c89ac (patch) | |
| tree | 24c0a5cee278ef22c52d4ab91b030ed3d090a8d9 /src | |
| parent | f40eed5adf6a707250ac6c7783fe5eb097d29297 (diff) | |
| download | raylib-b54e9db7647ae6e5ed86a8a5d92dbd63157c89ac.tar.gz raylib-b54e9db7647ae6e5ed86a8a5d92dbd63157c89ac.zip | |
Optimize `Vector2Rotate()` function (#2340)
Diffstat (limited to 'src')
| -rw-r--r-- | src/raymath.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/raymath.h b/src/raymath.h index 51dc2abc..00c134d8 100644 --- a/src/raymath.h +++ b/src/raymath.h @@ -189,7 +189,7 @@ RMAPI float Normalize(float value, float start, float end) // Remap input value within input range to output range RMAPI float Remap(float value, float inputStart, float inputEnd, float outputStart, float outputEnd) { - float result =(value - inputStart)/(inputEnd - inputStart)*(outputEnd - outputStart) + outputStart; + float result = (value - inputStart)/(inputEnd - inputStart)*(outputEnd - outputStart) + outputStart; return result; } @@ -378,8 +378,11 @@ RMAPI Vector2 Vector2Rotate(Vector2 v, float angle) { Vector2 result = { 0 }; - result.x = v.x*cosf(angle) - v.y*sinf(angle); - result.y = v.x*sinf(angle) + v.y*cosf(angle); + float cosres = cosf(angle); + float sinres = sinf(angle); + + result.x = v.x*cosres - v.y*sinres; + result.y = v.x*sinres + v.y*cosres; return result; } |
