I’ve written a few helpful external objects for [tag]MaxMSPJitter[/tag] for dealing with [tag]3D[/tag] rotations.
They allow you to rotate objects without worrying about Gimbal lock, a condition where your rotating object spirals in a robotic manner instead of freely rotating in 3D space. Source code in C is included.
Download the LFO Quaternion Objects here