Quaternion fun... Is there a more efficient way to do this?
I'm modeling an object's rotation using a quaternion (A). Occasionally, I would like to re-orient the object with a new yaw, but keep the object's current pitch and roll.
Right now I accomplish this as follows:
-calculate the yaw of the object's quaternion (A) (euler yaw value)
-create a new quaternion (B) with the inverse of the yaw value
-multiply the object's quaternion (A) by this new quaternion (B) so the yaw of the resulting quaternion (C) is now 0, but the yaw and pitch are the same as the object's quaternion (A)
-create a quaternion (D) using the NEW yaw value
-multiply the 0 degree yaw quaternion (C) by the NEW quaternion (D)
That seems incredibly inefficient to me and I'm sure there is a better way.... but I am rather new to quaternions. I would appreciate any advice!
I feel like there should be some way for me to create a quaternion with the NEW yaw value, then use it to directly replace the object's quaternion z, and adjust the w value?