Browse Source

Adding Normalize and Remap functions (#1247)

* Adding Norm and Remap functions

// Normalize input value within input range
// Remap input value within input range to output range

* Rename Norm to Normalize

To make it uniforms with Raylib's functions

* Calculate Remap without other functions
pull/1251/head
Noor Wachid 4 years ago
committed by GitHub
parent
commit
abb94bd2ff
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 0 deletions
  1. +12
    -0
      src/raymath.h

+ 12
- 0
src/raymath.h View File

@ -154,6 +154,18 @@ RMDEF float Lerp(float start, float end, float amount)
return start + amount*(end - start);
}
// Normalize input value within input range
RMDEF float Normalize(float value, float start, float end)
{
return (value - start) / (end - start);
}
// Remap input value within input range to output range
RMDEF float Remap(float value, float inputStart, float inputEnd, float outputStart, float outputEnd)
{
return (value - inputStart) / (inputEnd - inputStart) * (outputEnd - outputStart) + outputStart;
}
//----------------------------------------------------------------------------------
// Module Functions Definition - Vector2 math
//----------------------------------------------------------------------------------

Loading…
Cancel
Save