Describing aircraft attitude with Euler angles has probably been the most common way to do so, especially when considering the kinematic equations that describe aircraft motion. However solving the Euler based kinematic equations for simulation purposes contains a mighty trap… singularities! Those singularities are due to the vertical tangent of pitch angle (theta) which result to the phenomenon of gimbal lock. In short gimbal lock is encountered when the grand-parent and grand-child axis of a three-set gimbals align and that’s the point where you lose one degree of freedom and cannot rotate as desired anymore. Your system of equations blows up and you are trapped in the gimbal lock!
There are a couple of solutions to escape a gimbal lock. The first and cheapest one is to keep yourself away from that point – not really a realistic option especially when you are looking to simulate aerobatic maneuvers. The second and much preferred solution is to transfer yourself out of the Euler angles into the dark side of quaternions. Quaternions are another way of rotating an Euclidean vector in a more compact way and without singularities. They are composed from a scalar and a vector part where practically the vector part describes the rotation axis and he scalar part the angle of rotation.
The penalty you have to pay to transit to the quaternion formulation of the kinematic equations, beside the conversion of your solver code and the developing of the understanding behind it, is the addition of one extra equation, as now instead of 3 you have 4 equations.
Math are great… you just need to get used to them :-)