diff options
author | nathansmithsmith <thenathansmithsmith@gmail.com> | 2023-07-09 00:53:10 -0600 |
---|---|---|
committer | nathansmithsmith <thenathansmithsmith@gmail.com> | 2023-07-09 00:53:10 -0600 |
commit | 3f0be672f9c5a07a98be0dc703b95f1bbe73f33e (patch) | |
tree | aeb7776878e3460f7ba1f33cf2c0d195eb45f2c5 /src/util.c | |
parent | b92adb44b618db0272819cb77e5727441c566838 (diff) |
Mouse control working
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -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; +} |