public static float CalcEulerSafeX(float x) { if (x >= -90 && x <= 90) return x; x = x % 180; if (x > 0) x -= 180; else x += 180; return x; }