diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2021-01-29 22:33:31 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2021-01-29 22:33:31 -0500 |
commit | 55fd631d86769e719f81206901bc1c3fb598fb5e (patch) | |
tree | eca599d625d8d55d03c2d793e5f85d51f712a2c2 /math.c | |
parent | 3cc173dd38e85c751bb1a9f9288ebe974e567ba4 (diff) |
quitting, closing tabs
Diffstat (limited to 'math.c')
-rw-r--r-- | math.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -46,12 +46,31 @@ static int clampi(int x, int a, int b) { return x; } +static i16 clamp_i16(i16 x, i16 a, i16 b) { + if (x < a) return a; + if (x > b) return b; + return x; +} + +static u16 clamp_u16(u16 x, u16 a, u16 b) { + if (x < a) return a; + if (x > b) return b; + return x; +} + static i32 clamp_i32(i32 x, i32 a, i32 b) { if (x < a) return a; if (x > b) return b; return x; } +static u32 clamp_u32(u32 x, u32 a, u32 b) { + if (x < a) return a; + if (x > b) return b; + return x; +} + + // remap x from the interval [from_a, from_b] to the interval [to_a, to_b], NOT clamping if x is outside the "from" interval. static float remapf(float x, float from_a, float from_b, float to_a, float to_b) { float pos = (x - from_a) / (from_b - from_a); |