diff options
author | rexim <reximkut@gmail.com> | 2024-03-23 01:48:53 +0700 |
---|---|---|
committer | rexim <reximkut@gmail.com> | 2024-03-23 01:48:53 +0700 |
commit | 302f9700a8a59bda6e9e93a400602ab73ab31856 (patch) | |
tree | 15966e0442ae838c249d300fec6c5c5b67d46f3e /test.adb | |
parent | c2f061eada75e8f8be5ed7cb982ff20d8d844911 (diff) |
Implement Angular Velocity for the Eyes
Diffstat (limited to 'test.adb')
-rw-r--r-- | test.adb | 32 |
1 files changed, 30 insertions, 2 deletions
@@ -5,8 +5,36 @@ with Interfaces.C.Strings; use Interfaces.C.Strings; with Ada.Unchecked_Conversion; function Test return Integer is + function Clamp(X, Lo, Hi: Float) return Float is + begin + if X < Lo then + return Lo; + elsif X > Hi then + return Hi; + else + return X; + end if; + end; + + function Repeat(T, Length: Float) return Float is + function Floorf(A: C_Float) return C_Float + with + Import => True, + Convention => C, + External_Name => "floorf"; + begin + return Clamp(T - Float(Floorf(C_Float(T/Length)))*Length, 0.0, Length); + end; + + function Delta_Angle(A, B: Float) return Float is + Dlt: Float := Repeat(B - A, 360.0); + begin + if Dlt > 180.0 then + Dlt := Dlt - 360.0; + end if; + return Dlt + end; begin - Put_Line("Working Directory: " & To_Ada(Value(Get_Working_Directory))); - Put_Line("Application Directory: " & To_Ada(Value(Get_Application_Directory))); + Put_Line(Float'Image(Repeat(-1.0, 360.0))); return 0; end; |