From 3f0be672f9c5a07a98be0dc703b95f1bbe73f33e Mon Sep 17 00:00:00 2001 From: nathansmithsmith Date: Sun, 9 Jul 2023 00:53:10 -0600 Subject: Mouse control working --- src/util.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/util.c') diff --git a/src/util.c b/src/util.c index 63cc9ab..10d4c09 100644 --- a/src/util.c +++ b/src/util.c @@ -3,3 +3,23 @@ AxisAngle AxisAngleIdentity() { return (AxisAngle){Vector3Zero(), 0.0}; } + +float signum(float n) { + if (n > 0.0) + return 1.0; + else if (n < 0.0) + return -1.0; + else + return 0.0; +} + +float closestAngle(float a1, float a2) { + float a = fmodf(a1, PI); + float b = fmodf(a2, PI); + float dir = b - a; + + if (fabsf(dir) > (PI/2)) + dir = -(signum(dir) * PI) + dir; + + return dir; +} -- cgit v1.2.3