Optimize Vector2Rotate()
function (#2340)
This commit is contained in:
parent
f40eed5adf
commit
b54e9db764
1 changed files with 6 additions and 3 deletions
|
@ -189,7 +189,7 @@ RMAPI float Normalize(float value, float start, float end)
|
||||||
// Remap input value within input range to output range
|
// Remap input value within input range to output range
|
||||||
RMAPI float Remap(float value, float inputStart, float inputEnd, float outputStart, float outputEnd)
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -378,8 +378,11 @@ RMAPI Vector2 Vector2Rotate(Vector2 v, float angle)
|
||||||
{
|
{
|
||||||
Vector2 result = { 0 };
|
Vector2 result = { 0 };
|
||||||
|
|
||||||
result.x = v.x*cosf(angle) - v.y*sinf(angle);
|
float cosres = cosf(angle);
|
||||||
result.y = v.x*sinf(angle) + v.y*cosf(angle);
|
float sinres = sinf(angle);
|
||||||
|
|
||||||
|
result.x = v.x*cosres - v.y*sinres;
|
||||||
|
result.y = v.x*sinres + v.y*cosres;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue