Let’s say I have a rectangle object. I have access to the objects rotation. I have have two axisAngle quaternions for yaw and pitch. How can i apply the rotations independently of each other to the objects rotation?
Let’s define variables:
- Quat objRot = object’s rotation ie. a rectangle
- Quat yawRot = axisAngle rotation (world up)
- Quat pitchRot = axisAngle rotation (world right)
Composing yawRot and pitchRot and applying them locally to objRot introduces roll due to composition ie:
Quat totalRot = objRot * yawRot * pitchRot
Apply pitch locally and yaw globally would allow a more better rotation. However, the global yaw rotation would rotate the pitched object about the world Y axis effectively causing the rectangle to lean instead of having its original direction change. Switching pitch and yaw will give a similar experience.
For example, I pitch it locally towards the camera until the rectangle is facing down. After I apply the yaw globally, it would lean left and right at an angle from the pitched rotation. You can imagine a paper on a desk and you spinning it like a disk from the middle. Instead I want the objects local yaw to change such that when the object is facing down, the entire left or right side either rises or falls about the forward axis. Here is the computation:
Quat totalRot = yawRot * objRot * pitchRot
I have tried some weird things such as:
Quat totalRot = (yawRot * objRot.Inverted) * (objRot * pitchRot)
This effectively enables the degrees of rotation on the correct axis, but the original objRot is not honored and it’s facing a different way. Any yaw and pitch deltas work on the objects axis.
How would I achieve such an effect?