My systems consists of a coordinate frame and a quaternion in this system represents a roll (about x), pitch (about y) and yaw (about z) in the form of four values (qx, qy, qz, qw).
How can I separate this quaternion, into three independent quaternions, such that one represents the roll, the other represent pitch and the third represents yaw rotations?
Thank you.
It sounds like you should extract the Euler angles, then create 3 new quaternions and then re-combine them in the right order to arrive at the original quaternion again.
This PDF has formulas for converting between Euler and Quaternion manually. The formulas work in YPR format, rather than your RPY. Can you use them?
Here they are implemented in C:
/* euler_2_quaternion_ZYX */
quat->w = cos(az / 2.0f) * cos(ay / 2.0f) * cos(ax / 2.0f) + sin(az / 2.0f) * sin(ay / 2.0f) * sin(ax / 2.0f);
quat->x = cos(az / 2.0f) * cos(ay / 2.0f) * sin(ax / 2.0f) - sin(az / 2.0f) * sin(ay / 2.0f) * cos(ax / 2.0f);
quat->y = cos(az / 2.0f) * sin(ay / 2.0f) * cos(ax / 2.0f) + sin(az / 2.0f) * cos(ay / 2.0f) * sin(ax / 2.0f);
quat->z = sin(az / 2.0f) * cos(ay / 2.0f) * cos(ax / 2.0f) - cos(az / 2.0f) * sin(ay / 2.0f) * sin(ax / 2.0f);
/* quaternion_2_euler_ZYX */
float qx, qy, qz, qw;
qw = quat->w;
qx = quat->x;
qy = quat->y;
qz = quat->z;
*az = atan2(qy * qz + qw * qx, 0.5f - ((qx * qx) + (qy * qy)));
*ay = asin(-2.0f * ((qx * qz) - (qw * qy)));
*ax = atan2(((qx * qy) + (qw * qz)), 0.5f - ((qy * qy) + (qz * qz)));