Here's enough links on the subject to make your head explode:
http://mathworld.wolfram.com/EulerAngles.html
http://mathworld.wolfram.com/EulerParameters.html
http://www.euclideanspace.com/maths/geometry/rotations/euler/
http://mathworld.wolfram.com/RotationMatrix.html
And if you are REALLY sick & twisted, you can try to understand ABB's method of using Quaternions