# Relative rotation between quaternions

Say I have a quaternion q which describes how to get from frame 0 to frame 1, and a quaternion r which describes how to get from frame 0 to frame 2. To get the "quaternion difference" between q and r, I do

$$q_{d} = q^{-1} r$$ This is however in frame 1. How do I get the quaternion difference in frame 0?

• What does 'frame' mean here in this context? – Berci Dec 22 '13 at 21:57
• say we have a world frame of reference, in this frame q represents a rotation around x of 90 degrees. So the quaternion rotation is frame specific. I guess this is what I meant to say. – user113514 Dec 22 '13 at 22:22
• How do you mean '$q^{-1}r$ is in frame $1$ and not in frame 0'? Aren't all quaternions present in each frame? (I still don't clearly get what frames really want to be..) – Berci Dec 22 '13 at 22:52
• Yes, but the same rotation looks different in different frames. So the quaternions corresponding to a rotation about world x would look like (w,x,y,z) [cos(t), sin(t), 0, 0]. But in an arbitrary frame the y and z components need not be 0. – user113514 Dec 23 '13 at 2:39
• By frame, I meant coordinate frame [a set of three orthogonal axes]. I guess my question is given q and r defined in a coordinate frame, what coordinate frame is $q^{-1} r$ defined in? Is that clear? – user113514 Dec 25 '13 at 2:57

You are confusing quaternions with vectors in physical space. As the comments say, there is no such thing as having a quaternion "in" a certain frame anymore than there is such a thing as having a rotation matrix in a certain frame--both of these transform between frames and their components depend only on the relative rotation of the starting and ending frames. If $q:0\rightarrow 1$ and $r:0\rightarrow 2$ and my guess is you are looking for some third quaternion $p:1\rightarrow 2$ then since $r = pq$ you have $p = q^{-1}r = q^{*}r$ (since all rotations are unit quaternions). Note that for given $q$ and $r$ this is totally unambiguous since $q^{-1}r \neq rq^{-1}$ or any other weird permutation of $q$, $r$ and the inverse map: $q^{-1}r$ and only $q^{-1}r$ delivers the quaternion you are looking for.