diff options
| author | Noor Wachid <[email protected]> | 2020-05-15 18:08:28 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-05-15 13:08:28 +0200 |
| commit | abb94bd2fff7f7722f7f0bee492337dd8bd95b35 (patch) | |
| tree | 12b8f4ceb449340d7db6e3254123cfc5fe2ce2ff /src/raymath.h | |
| parent | b897ae092a31f29f6ac6ebd2b6dac3080ccd5372 (diff) | |
| download | raylib-abb94bd2fff7f7722f7f0bee492337dd8bd95b35.tar.gz raylib-abb94bd2fff7f7722f7f0bee492337dd8bd95b35.zip | |
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
Diffstat (limited to 'src/raymath.h')
| -rw-r--r-- | src/raymath.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/raymath.h b/src/raymath.h index 662ce25c..c00aa06f 100644 --- a/src/raymath.h +++ b/src/raymath.h @@ -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 //---------------------------------------------------------------------------------- |
