You can remove part of the yaw of the quaternion by calculating the part of yaw and then applying it back. Suppose your quaternions are quat(w,x,y,z) == w + xi + yj + zk) , and yaw is defined around the Z axis (123 or 213 Euler from this article ).
Note that in these frames the rotation on yaw around the Z axis is represented by the quaternion quat(cos(yaw/2), 0, 0, sin(yaw/2)) .
By decomposing quaternions into Euler angles, we have a yaw as:
yaw = atan2(-2*x*y + 2*w*z, +w*w +x*x -y*y -z*z); // 123 angles (page 24) yaw = atan2(-2*x*y + 2*w*z, +w*w -x*x +y*y -z*z); // 213 angles (page 28)
From which it can be obtained that
quat quat_2yaw = quat(w*w +x*x -y*y -z*z, 0, 0, -2*x*y + 2*w*z).normalize(); // 123 angles quat quat_2yaw = quat(w*w -x*x +y*y -z*z, 0, 0, -2*x*y + 2*w*z).normalize(); // 213 angles
An easy way to halve the quaternion angle is to add it to the identical quaternion and normalize it:
quat quat_yaw = (1 + quat_2yaw).normalize();
To answer your initial question - we want to take the jerk from q1 and replace it with q2 . We can do this as follows:
q2 = get_quat_yaw(q1) * get_quat_yaw(q2).conj() * q2;
source share