Slight optimisation to angle modding functions (mainly Clamp180 would shift a negative angle to be 0-360 and then shift it back).
Slight optimisation to angle modding functions (mainly Clamp180 would shift a negative angle to be 0-360 and then shift it back).
Now completely avoid the mod operator and just does repeated add/subtract until in the correct range.

--- a/KerbalEngineer/Helpers/AngleHelper.cs
+++ b/KerbalEngineer/Helpers/AngleHelper.cs
@@ -25,20 +25,42 @@
     {
         public static double Clamp180(double angle)
         {
-            angle = Clamp360(angle);
-            if (angle > 180.0)
+            if (angle < -180.0)
             {
-                angle = angle - 360.0;
+                do
+                {
+                    angle += 360.0;
+                }
+                while (angle < -180.0);
+            }
+            else if (angle > 180.0)
+            {
+                do
+                {
+                    angle -= 360.0;
+                }
+                while (angle > 180.0);
             }
             return angle;
         }
 
         public static double Clamp360(double angle)
         {
-            angle = angle % 360.0;
             if (angle < 0.0)
             {
-                angle = angle + 360.0;
+                do
+                {
+                    angle += 360.0;
+                }
+                while (angle < 0.0);
+            }
+            else if (angle > 360.0)
+            {
+                do
+                {
+                    angle -= 360.0;
+                }
+                while (angle > 360.0);
             }
             return angle;
         }