Although a much bigger thing to tackle, it sometimes yields the most sure-shot way to get consistnet and unbreakable results:

http://en.wikipedia.org/wiki/Quaternion

Quaternions can be used to represent rotation without ugly grimbal lock- the downside is they are more complex and more process intense. You could easily store all of your angle information using quaternions and do your operations there, then convert the quaternion to a euler angle.

Just two cents


I no longer post on these forums, keep in touch with me via:
Linkedin.com
My MSDN blog