Adding Norm and Remap functions

// Normalize input value within input range
// Remap input value within input range to output range
This commit is contained in:
Noor Wachid 2020-05-13 22:15:26 +07:00 committed by GitHub
parent 4ec40e720c
commit f88638fdaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -154,6 +154,17 @@ RMDEF float Lerp(float start, float end, float amount)
return start + amount*(end - start); return start + amount*(end - start);
} }
// Normalize input value within input range
RMDEF float Norm(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 Lerp(outputStart, outputEnd, Norm(value, inputStart, inputEnd));
}
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Module Functions Definition - Vector2 math // Module Functions Definition - Vector2 math
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------