Browse Source

Optimize `Vector2Rotate()` function (#2340)

pull/2343/head
Jaedeok Kim 3 years ago
committed by GitHub
parent
commit
b54e9db764
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 3 deletions
  1. +6
    -3
      src/raymath.h

+ 6
- 3
src/raymath.h View File

@ -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;
}

Loading…
Cancel
Save