# About the derivation of a composite quaternion

This problem has been bothering me for several days, hence I decided to ask you for help.

I am reading the book "Quaternions and Rotation Sequence" written by Jack B. Kuipers. In section 6.4, the author derives a formula of a composite rotation quaternion. One of the steps of this derivation is difficult for me to understand.

I would like to briefly describe the derivation process as follow:

Consider a tracking problem as in this picture.

(I am sorry I have to use links instead of posting pictures directly because this is the first time I post a question here so I am not eligible to do so yet)

In the picture, XYZ is a global, reference frame. 2 successive rotations are performed: The first one is a rotation about the Z axis through an angle alpha, transforming frame XYZ into a new frame x1y1z1. The second one is a rotation about the y1 axis through an angle beta, transforming frame x1y1z1 into a new frame x2y2z2.

The goal is to find a single composite rotation quaternion which is equivalent to the two rotations above.

The author does this as follow. The first rotation can be represented by the following quaternion p:

p = cos(alpha/2) + k*sin(alpha/2) (1)

In this formula, k is a standard basis vector (we have vectors i, j, k in R3 corresponding to the axes x, y, z respectively).

The second rotation can be represented by the following quaternion q:

q = cos(beta/2) + j*sin(beta/2) (2)

The composite quaternion we are looking for is the product of these 2 quaternions: qp. The formula of this product is in this picture.

In order to derive this final formula, the author uses 2 assumptions about the standard basis vectors i, j, k, which are: k.j = 0 and k x j = -i. And this is where I dont understand.

We all know that, for a set of 3 mutually orthogonal vectors i, j, k, these 2 assumptions above are correct. However, vector k in (1) and vector j in (2) don't belong to the same coordinate frame. In other words, k in (1) corresponds to Z in frame XYZ, and j in (2) corresponds to y1 in x1y1z1. And these are 2 different, distinguish frames, so I think the second assumption used by the author is incorrect.

It seems like you're getting pretty tangled up between quaternions and vectors. My advice is to just consider $i,j,k$ primarily as quaternions, and secondarily as part of a 3-space basis. You should say "I'm representing the coordinate axes with quaternions."

The magic is that when you model 3-space with pure quaternions like this, the quaternions multiplication automatically encodes rotations.

I'm guessing you have the standard definition of $\Bbb H$: $i^2=j^2=k^2=-1$ And $ij=k$, $jk=i$, $ki=j$. Those rules combine to prove $ji=-k;kj=-i;ik=-j$.

The author may have motivated quaternions multiplication rules with the dot and cross product.

Just multiply the two quaternions you have adhering to the quaternions multiplication rules, and you get the composite.

There is never more than one frame of reference: the one provided by $i,j,k$ representing the coordinate axes.

In your case, here would be the computation:

$$(\cos(\alpha/2)+k\sin(\alpha/2))(\cos(\beta/2)+j\sin(\beta/2))\\ =\cos(\alpha/2)\cos(\beta/2)+j\cos(\alpha/2)\sin(\beta/2)+k\sin(\alpha/2)\cos(\beta/2)+kj\sin(\alpha/2)\sin(\beta/2)$$

Changing $kj=-i$ and reordering, we're here:

$$\cos(\alpha/2)\cos(\beta/2)-i\sin(\alpha/2)\sin(\beta/2)+j\cos(\alpha/2)\sin(\beta/2)+k\sin(\alpha/2)\cos(\beta/2)$$

Now the length of the pure quaternion part $s=-i\sin(\alpha/2)\sin(\beta/2)+j\cos(\alpha/2)\sin(\beta/2)+k\sin(\alpha/2)\cos(\beta/2)$ is $\sqrt{\sin^2(\beta/2)+\sin^2(\alpha/2)\cos^2(\beta/2)}=\ell$, so let's normalize this vector by writing $s=\ell(s/\ell)=\ell u$ so that $u$ is a pure unit quaternion.

We are now looking at $pq=\cos(\alpha/2)\cos(\beta/2)+ u\sqrt{\sin^2(\beta/2)+\sin^2(\alpha/2)\cos^2(\beta/2)}$. An easy computation confirms that $(\sin^2(\beta/2))^2 + (\sqrt{\sin^2(\beta/2)+\sin^2(\alpha/2)\cos^2(\beta/2)})^2=1$, showing that the two coefficients are coordinates of a point on the unit circle, and so they are respectively $\cos(\theta/2)$ and $\sin(\theta/2)$ for some angle $\theta$.

Thus we've recovered the composition $qp=\cos(\theta/2)+u\sin(\theta/2)$. It is basic trigonometry to recover $\theta$ from $\alpha$ and $\beta$, and the axis of the rotation is in the direction of $u$.

• Thanks for your answer. Equation (1) in my post is correct only if k corresponds to Z in frame XYZ. Likewise, (2) is correct only if j corresponds to y1 in x1y1z1. It is clear that XYZ and x1y1z1 are two different frames. – user3286500 Feb 19 '14 at 16:33
• Dear @user3286500 : OK, I won't say any more about the two-frames thing since you are apparently in a line of thought I'm not following. All I know is that you can perform all the rotations you want with quaternions with a single frame. Maybe in your application switching frames between rotations makes sense. If you performed $q$ then $p$, but did $p$ with a new frame, your new $p'$ would just be a conjugate $p'=x^{-1}px$, which would again be a unit quaternion, and you could perform the analysis the same way as above. – rschwieb Feb 19 '14 at 16:39
• Dear @user3286500 At any rate, it doesn't make any sense to represent quaternion rotations in different frames and then multiply them. They need to be in the same frame for their product to be related to the composition of the mappings. But like I'm saying above, a machine with pitch/yaw/roll instructions could recalibrate the frame and rotation matrices at each step, and essentially be passing between these representations. – rschwieb Feb 19 '14 at 16:44