I'm using the following code to produce a quaternion from XYZ Euler-Angles in radians:
c1 = Math.cos( x / 2 )
c2 = Math.cos( y / 2 )
c3 = Math.cos( z / 2 )
s1 = Math.sin( x / 2 )
s2 = Math.sin( y / 2 )
s3 = Math.sin( z / 2 )
quaternion = [
c1 * c2 * c3 - s1 * s2 * s3,
s1 * c2 * c3 + c1 * s2 * s3,
c1 * s2 * c3 - s1 * c2 * s3,
c1 * c2 * s3 + s1 * s2 * c3,
]
from: http://www.euclideanspace.com/maths/geometry/rotations/conversions/eulerToQuaternion/index.htm
This produces a quaternion that first rotates around the z, then y, then finally the x-axis - Z-Y-X. Is it possible to alter this formula so that it rotates around the axes in a different order? What I'm looking for is the opposite, so X-Y-Z.