In 3d math primer they have two ways of converting euler angles to a quaternion, depending if we want a inertial-to-object or object-to-inertial quaternion. However in wikipedia they use a different conversion, but I don't yet understand the relation with the ones in 3d math primer. Does anyone has experience in this area that they can shed some light?

Conversion between quaternions and Euler angles - Wikipedia, the free encyclopedia

[3d math primer euler to quaternion equations in Google books]
3D math primer for graphics and game ... - Google Books

Thank you very much