How to avoid gimbal lock (c++)?

Done! Glad you got it sorted!