Quaternions (Advanced Methods in Computer Graphics) Part 3

Quaternion Rotations

We will now try to represent the rotational transformation in Fig. 5.6 by a unit quaternion Q = (q0,w), where the vector component w of the quaternion is along the axis of rotation. Therefore we have

tmpc2f9-231_thumb[2]_thumb

We saw earlier that a vector p can be transformed into another vector p’ using a unit quaternion Q and the result of this transformation is given by Eq. 5.27. In the previous section, we considered an angle-axis transformation of a vector p given by Eq. 5.32. We find a striking similarity between the two equations, which suggests that the quaternion transformation in Eq. 5.27 is indeed an angle-axis transformation. Equating the corresponding terms in both the equations, we find that

tmpc2f9-232_thumb[2]_thumb


From the above equations, we can see that k = sin(1/2), and q0 = cos(1/2). Therefore the unit quaternion that represents the rotation in Fig. 5.6 is given by

tmpc2f9-233_thumb[2]_thumb

This result is fundamental to the theory of generalized rotations, as it provides a direct mechanism for converting angle-axis representations of three-dimensional rotations into unit quaternions. From this equation, we can also derive the relationship between the components of any unit quaternion Q = (q0, q1, q2, q3) and the parameters of rotation it represents. The angle of rotation is given by

tmpc2f9-234_thumb[2]_thumb

and the unit vector along the axis of rotation (l, m, n) can be obtained as

tmpc2f9-235_thumb[2]_thumb

Replacing 1/2 with 1 in Eq. 5.44, we can summarize our discussion above as follows:

Any unit quaternion Q can be expressed in the form Q = (cos1, u sin1), and it represents a rotation by an angle 21 about a unit vector u passing through the origin.

Quaternion Transformation Matrix

From the above discussion, we can conclude that if Q is a unit quaternion, then Eq. 5.27 gives a rotational transformation of a vector p = (x, y, z, 0). This transformation equation could also be written in the conventional matrix form as shown below:

tmpc2f9-236_thumb[2]_thumb

The same transformation matrix can be applied to transform a point P = (x, y, z, 1) to another point P’ = (x!, y, z, 1) using the quaternion Q. The quaternion transformation matrix in Eq. 5.47 is orthogonal, meaning that its inverse is the same as its transpose. The matrix also has some very useful properties. If we equate this matrix to a general 4 x 4 matrix given in Eq. 5.39, we can find that the following relationships hold among the matrix elements:

tmpc2f9-237_thumb[2][2]

The above equations are useful for extracting the quaternion elements from a given 4 x 4 rotational transformation matrix:

tmpc2f9-238_thumb[2][2]

We will choose only the positive value of the square-root for computing q0. A negative value for q0 will change the sign of all remaining components and yield the quaternion — Q in place of Q. Shortly (Eq. 5.57) we will see that both Q and —Q represent the same rotation, and therefore we can safely impose the constraint that the sign of q0 is positive, and compute the remaining components from it. Note also that the above equations are valid only when q0 ^ 0. If q0 = 0, then the angle of rotation 1 = ±180°, and the matrix in Eq. 5.47 becomes a symmetric matrix. For this special case, the remaining quaternion elements can be derived as follows:

tmpc2f9-239_thumb[2][2]

If a point (or a vector) P is first transformed by a quaternion Q1 and then by a quaternion Q2, the resulting point (or vector) P’ is obtained by applying the transformation formula twice:

tmpc2f9-240_thumb[2][2]

The above equation shows that the composite rotation is given by the quaternion product Q2Q1. Generalising this result, a series of rotational transformations performed using unit quaternions Q1, Q2, …Qk in that order, is equivalent to a single rotational transformation produced by the combined product quaternion (Qk… Q2Q1).

Quaternions and Euler Angles

In this section, we explore the relationship between unit quaternions and Euler angles. Using Eq. 5.44, we can represent elementary rotations about X, Y, and Z axes by angles f, $, 6 respectively, as follows:

tmpc2f9-241_thumb[2][2]

A sequence of Euler angle rotations f f, $, 6 g is equivalent to the quaternion product QZQY QX. We will denote this product by QE. Using the quaternion multiplication rule in Eq. 5.10, we can easily express the components of QE in terms of the Euler angles. For convenience, the four quaternion components are arranged as a column vector in the equation below.

tmpc2f9-242_thumb[2][2]

Conversely, given a unit quaternion Q = (q0, q1, q2, q3), we can compute the equivalent Euler angle representation by comparing the elements of the quaternion transformation matrix and the Euler angle transformation matrix. As an example, by equating the corresponding elements from only the first column and the third row of the matrices in Eqs. 5.47 and 5.30, we get the following expressions for the Euler angles , ¢, 6 in terms of quaternion components:

tmpc2f9-243_thumb[2][2]

There are many other ways in which the above parameters can be obtained by comparing the remaining elements of the two matrices. However, each derivation has its own set of singularities that need to be handled as special cases. For example, the unit quaternion

tmpc2f9-244_thumb[2][2]

presents a singularity for , with both the numerator and the denominator of the first equation in Eq. 5.56 becoming zero.

Negative Quaternion

In this section, we consider another geometrical property of quaternions, taking QZ (Eq. 5.54) as an example. Figure 5.7 shows the plot of the first and the fourth nonzero components of QZ as the rotation angle 6 is varied over two cycles from 0° to 720°.

Plot showing the variation of quaternion components with rotation angle

Fig. 5.7 Plot showing the variation of quaternion components with rotation angle

Figure 5.7 shows that one cycle in quaternion space takes two revolutions in the Cartesian coordinate space. This means that two rotations by angles 6 and 360 + 6 that are geometrically equivalent, can have different quaternion representations. If a unit quaternion Q is given by Eq. 5.44, then replacing 8 with 360 + 8 we get,

tmpc2f9-246_thumb[2][2]

The above equation shows that both Q and —Q represent the same rotational transformation. In the next section, we will consider the problem of interpolating between two orientations (which we had briefly touched on while introducing Euler angles), and then use some of the properties of quaternion rotations discussed above to define quaternion based interpolation methods.

Next post:

Previous post: