Improper Quaternion value derived from the difference of Euler Angles

anglequaternionsrotations

A Quaternion (x,y,z,w) can be derived from Euler angles (x,y,z). Of course, these values need to be perfectly accurate or the Quaternion formula i^2 = j^2 = k^2 = ijk = −1 might be off, which can cause inaccurate rotations.

I have no problem deriving a quaternion from the Euler angles derived from another quaternion, since the Euler angles have been properly derived from quaternion values. However, when subtracting 2 Euler Angle vectors (x,y,z) - (x,y,z) and then deriving a quaternion from that difference vector, I'm getting the wrong quaternion values. I don't think messing with Euler angles is the right approach.

I have 2 quaternions (Q1 and Q2).

I have the Euler angles of both Q1 and Q2 (P1 and P2).

I want to get Q3 from the difference between P1 and P2.

Instead of subtracting P2 from P1 to derive a new quaternion, should I get Q3 from the difference between Q1 and Q2?

Is there a way to get Q3 without using Euler angles?

Best Answer

You have two quaternions, $q_1$ and $q_2$. What is the signficance of those quaternions to you; what do you want them for?

You want to derive a third quaternion, $q_3.$ What is its signficance; what do you want it for?

Often people use quaternions to represent rotations in three-dimensional space. The fact that you mention Euler angles suggests that this is what you want the quaternions for.

What do you think the "difference" between two rotations means? The difference between two numbers, $a$ and $b,$ is the amount you have to add to $b$ so that the sum will be $a.$ A kind of "difference" between two rotations $R_1$ and $R_2$ arises if you have performed the rotation $R_2,$ and you want to know what further rotation to perform so that the final result will be the same as if you had just done the rotation $R_1$ by itself. That is $R_2$ "plus" the "difference" should equal $R_1,$ except that we do not usually say "plus" when we are combining rotations. More typically we would say "followed by."

In two dimensions, where you can only rotate around an axis perpendicular to the plane of your figures, you can get away with just subtracting one rotation angle from another to get the "difference" between the two rotations. In three dimensions this does not generally work. Subtracting one vector of Euler angles from another is generally a nonsense operation. It is only useful as an approximation, and only when the angles are small.

If you're using quaternions to keep track of your rotations, however, you're in luck, because the result of doing the rotation of quaternion $q_2$ and then doing the rotation $q_3$ is $q_2 q_3,$ that is, $q_2$ multiplied by $q_3$ (or it might be $q_3 q_2$ depending on how you are using the quaternions to do your rotations; multiplication of quaternions is not commutative).

So it seems likely (if you are making this very common use of quaternions) that what you really want to find is the quaternion $q_3$ such that $$ q_2 q_3 = q_1.$$

To find $q_3$ you just need to find the multiplicative inverse of $q_2,$ which is called $q_2^{-1},$ and multiply as follows: $$ q_2^{-1} q_1 = q_2^{-1} (q_2 q_3) = (q_2^{-1} q_2) q_3 = q_3. $$

In short, $$ q_3 = q_2^{-1} q_1. $$