Question:
How do you nullify (zero out) rotation around an arbitrary axis in a Quaternion?
Example:
Let's say you have an object with quaternion orientation $A$. You also have a rotation quaternion $B$. You can calculate a new quaternion orientation $C=BA$.
Let's say the new orientation $C$, if done with axis-angle rotations, is equivalent to a 45 degree rotation around the arrow's local y-axis, followed by a 45 degree rotation around the arrow's local x-axis (which was moved due to the rotation around the y-axis).
In other words, imagine our 3D coordinate frame as a cube. Now imagine the initial orientation $A$ as an arrow in the center of our cube, facing in the negative-z direction. It's pointing at the center of the face of the cube whose normal is in the negative-z direction (with all normals pointing out of the cube).
Now, if we rotate this arrow 45 degrees around its local y-axis, it would be pointing at an edge of the cube. If we rotate it again, this time around its local x-axis, it would then be pointing at a corner of the cube.
The rotations described above can be encoded in a single Quaternion. A specific example of my question is, how can we alter that Quaternion so that it zeros out the rotation around, say, the x-axis, leaving only the rotation around the y-axis (meaning, in the end it would be pointing at an edge of the cube, not the corner)?
My full question is, how can we alter a Quaternion so that it zeros out the rotation around an arbitrary axis?
Remember of course that in general we would not know how the Quaternion was made, meaning we wouldn't know that it represents $a$ degrees around the x-axis, $b$ degrees around the y-axis, and $c$ degrees around the z-axis.