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?
For this task euler angles are the best thing to use, as their advantage (the only advantage at all) lies in the separation into individual roations around orthogonal axes. So convert both quaternions to an euler angle convention that fits your needs and just substitute q1's yaw angle by q2's.
Of course you need to use a matching euler angle convention, one where the other rotations don't depend on the yaw angle (so the yaw rotation is applied first when transforming a point?), so that you can just change the angle without influencing the other axes. When converting the resulting euler angle triple back to a quaternion, you should get a unique representation again, or am I missing something?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With