summaryrefslogtreecommitdiff
path: root/math.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-01-29 22:33:31 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-01-29 22:33:31 -0500
commit55fd631d86769e719f81206901bc1c3fb598fb5e (patch)
treeeca599d625d8d55d03c2d793e5f85d51f712a2c2 /math.c
parent3cc173dd38e85c751bb1a9f9288ebe974e567ba4 (diff)
quitting, closing tabs
Diffstat (limited to 'math.c')
-rw-r--r--math.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/math.c b/math.c
index 71afabc..130aff7 100644
--- a/math.c
+++ b/math.c
@@ -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);