I have the following problem: A quaternion (q1) from a motion capturing device needs to be corrected by the yaw angle (and only yaw!) from another orientation quaternion (q2) derived by a second tracked object, so that the pitch and roll of q1 is the same as before but q1 has the yaw of q2.
The working solution is converting the quats to matrices, then I do the calculations to extract the rotation angle and then I do the heading correction. But this results in a "flipping" when directly in direction of a certain axis (e.g. after 0° - 359°). Also tried other conversions which are not convenient.
Is there any possibility to do the math directly on the quaternions without conversions to matrices or euler angles (i.e. so I can set the corrected quaternion as quaternion for the tracked object)?
As said - the correction should include only the rotation around the up-axis (yaw). I have not many programming possibilities regarding math classes (VSL Script from Virtools is unfortunately pretty limited in this direction). Anyone has some advice?