diff options
| author | Pijus <[email protected]> | 2022-06-14 22:28:39 +0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-06-14 21:28:39 +0200 |
| commit | c392f0c16b18668d7db59d374937996d3fc2f17d (patch) | |
| tree | 5f568fa2b827ce53278cf4bc0cc05a8afd7cd4ce /src/raymath.h | |
| parent | 377dcef9f453d9f1d3a610cb0ddbe6f16996f592 (diff) | |
| download | raylib-c392f0c16b18668d7db59d374937996d3fc2f17d.tar.gz raylib-c392f0c16b18668d7db59d374937996d3fc2f17d.zip | |
Add wrap (#2522)
* add wrap function
* fixed Wrap function wrapping wrong
Diffstat (limited to 'src/raymath.h')
| -rw-r--r-- | src/raymath.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/raymath.h b/src/raymath.h index abe43545..503a157b 100644 --- a/src/raymath.h +++ b/src/raymath.h @@ -158,7 +158,7 @@ typedef struct float16 { float v[16]; } float16; -#include <math.h> // Required for: sinf(), cosf(), tan(), atan2f(), sqrtf(), fminf(), fmaxf(), fabs() +#include <math.h> // Required for: sinf(), cosf(), tan(), atan2f(), sqrtf(), floor(), fminf(), fmaxf(), fabs() //---------------------------------------------------------------------------------- // Module Functions Definition - Utils math @@ -198,6 +198,14 @@ RMAPI float Remap(float value, float inputStart, float inputEnd, float outputSta return result; } +// Wrap input value from min to max +RMAPI float Wrap(float value, float min, float max) +{ + float result = value - (max - min)*floor((value - min)/(max - min)); + + return result; +} + // Check whether two given floats are almost equal RMAPI int FloatEquals(float x, float y) { |
