Created
August 7, 2022 11:38
-
-
Save RicoP/1ac4030eee42624a91fbce5b600caf39 to your computer and use it in GitHub Desktop.
fast repeat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
inline float repeat(float v, float min, float max) | |
{ | |
v -= min; | |
v *= 1.0f / (max - min); | |
v -= (float)(int)(v); | |
v += 1.0f; | |
v -= (float)(int)(v); | |
v *= max - min; | |
v += min; | |
return v; | |
} | |
// Identiacal to repeat (v, 0, 1); | |
inline float repeat(float v) | |
{ | |
v -= (float)(int)(v); | |
v += 1.0f; | |
v -= (float)(int)(v); | |
return v; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment