Universal approach to derivation of quaternion rotation formulas

This paper introduces and defines the quaternion with a brief insight into its properties and algebra. The main part of this paper is devoted to the derivation of basic equations of the vector rotation around each rotational x, y, z axis. Then, the equations of generalized quaternion rotation and express the general rotation operator is derived. Finally the utilization of equations is demonstrated on a simple example. For purposes of simplicity the quaternions theory is demonstrated around the z-axis by γ angle. For the purpose of this paper, the fact that the subspace of vector quaternions may be regarded as being equivalent to the ordinary is used.


Introduction
The development of quaternions is attributed to W. R. Hamilton in 1843.
The great mathematician Sir W. R. Hamilton had been interested in complex numbers in the form a + b i, where numbers a, b are real and the unit i is imaginary. The rank of complex numbers in the plane is 2. Some mathematicians sought other mathematical systems over the complex numbers the rank more than 2. Sir Hamilton for over 10 years tried to extend concepts of complex numbers in the plane in order to define a complex volume by searching for the second imaginary axis. And on 16 th October 1843 he invented the so-called hyper-complex numbers of the rank 4 with 3 imaginary units needed.

The algebra of quaternions 2.1 Definition of quaternions
The definition of the real quaternion is expressed in the form where q 1 , q 2 , q 3 , q 4 are real numbers and i, j, k of q are the imaginary units of quaternions, which satisfy the equalities Set of all quaternions are denoted H. The quaternion, q ∈ H is defined as a pair (S (q), V(q)), where S (q) = q 1 ∈ R is the scalar part of quaternion q and V(q) = q 2 i + q 3 j + q 4 k, is the vector part of the quaternion. q = S (q) + V(q). * e-mail: chuda@utb.cz

Addition of quaternions
The addition rule for two quaternions is component-wise addition. This rule preserves the associativity and the commutativity properties of addition:

Multiplication of quaternions
The multiplication rule for the quaternions is the same as for the polynomials, extended by the multiplicative properties of the elements i, j, k given above. We have: The foregoing term reveals that the commutativity cannot be preserved. The associativity and the distributive property over addition are preserved.

Conjugates of quaternions
Consistent with the complex numbers, the definition of the conjugate operation on a given quaternion q is As with the complex numbers, note that both (q + q) and (q·q) are the real numbers. Moreover, defining the absolute value or the norm the equation is to be , Then evidently (q · q) = (q · q) = |q 2 |. The conjugate operation is distributive over addition.

Unit quaternion
The subspace of the unit quaternions, satisfying the condition |q| = 1, have some important properties. A trivially hold And a very useful form is where S(q)=(1, 0, 0, 0) is the scalar part of the unit quaternion, V(q)=(0, q 2 i, q 3 j, q 4 k) is the vector part of the unit quaternion and θ is the real number.

Inverse quaternions
We define the inverse quaternion in the following form: where |q| = q 1 2 + q 2 2 + q 3 2 + q 4 2 is absolute value of the quaternion and q = q 1 − q 2 i − q 3 j − q 4 k is the conjugate quaternion. This expression was introduced by the equation q · q −1 = q −1 · q = 1.

Vector properties of quaternions
The quaternion q = q 1 + q 2 i + q 3 j + q 4 k can be interpreted as the scalar part q 1 ∈ R and the vector part where the elements i, j and k are given the added geometric interpretation as the unit vectors along the x, y, z axes. Therefore, the subspace of the real quaternions may be regarded as being equivalent to the real numbers and subspace of the vector quaternions may be regarded as being equivalent to the ordinary vectors This attribute is further used in our calculations.

Point as quaternion
If the point P = (x, y, z) is represented as the position vector, it can be represented as the quaternion

Product of vector quaternions
The product of two vector quaternions has an interesting property where "." is an operator of the real part of the quaternion and " × " is an operator of the vector parts of the quaternions.

Rotation quaternion
The quaternion, which represents the rotation of the θ around the axis n = (n 1 , n 2 , n 3 ) is given by (12) where q is the unit quaternion, also n is the unit vector of the unit quaternion q. For any unit quaternion q = cos θ + n·sin θ and for any vector p ∈ R 3 he action of the operator may be interpreted geometrically as the rotation of the vector p through the angle 2θ around the q as the axis of the rotation.

Quaternion rotation around the z-axis by γ
The rotation axis represents the unit quaternion n = 0 i + 0 j + 1 k while the rotation operator is given by Using the rotation operator onto any vector p = x i + y j + z k, p ∈ R 3 : Equation of the rotation operator R q (p) z :

Quaternion rotation around the y-axis by β
The rotation axis represents the unit quaternion n = 0 i + 1 j + 0 k while the rotation operator is given by Using the rotation operator onto any vector p = x i + y j + z k, p ∈ R 3 : Equation of the rotation operator R q (p) y :

Quaternion rotation around the x-axis by α
The rotation axis represents the unit quaternion n = 1 i + 0 j + 0 k while the rotation operator is given by Using the rotation operator onto any vector p = x i + y j + z k, p ∈ R 3 : Equation of the rotation operator R q (p) x :

Operator of composition
Let q I and q II be two unit quaternions (7). The operator R q (p) I is first applied to the vector p. Then we apply the operator R q (p) II and obtain the operator R q (p) I, II . Equivalently, the composition R q I • R q II of the two operators can be applied: R q (R q (p) I ) = q II · (q I p q I ) · q II = = (q II q I ) · p · (q I q II ) = (17) = (q II q I ) · p · (q II q I ) = = R q (p) I, II .
Because q I and q II are the unit quaternions, same as the product q II · q I . Hence the above equation (17)  the rotation operator defining quaternion is the product of the two quaternions q I and q II . The following equation describes the operator R q (p) z y x for three unit quaternions q z , q y and q x . These quaternions represent the unit quaternions rotations around the belonging axes x, y and z, respectively, for the general Compound quaternion: Conjugated compound quaternion: The compound and the conjugated compound quaternions is put into the relationship for the R q (p) z y x ; and after the substitution (19) for a, b, c and d, following is obtained: Then the general operator of the quaternion rotation is in the form:

Advantages and disadvantages of quaternions
In previous sections, one of two principal rotational methods were introduced: one of them is the rotation defined by the quaternions and the other one (not presented in this paper) is defined by the Euler angles represented by the rotation matrices, method, that is well known. In this section, we will describe advantages and disadvantages of these methods. First, the time quaternions are not so easy to be represented mathematically -seem to be complicated. The representation of the rotations by the quaternions has several advantages over the other possible representation by the Euler angles. The parametrization of the rotations using the quaternions involve only the angle and the axis of the rotation. In the theory of the quaternions, q and -q correspond to the same rotation. Other advantage of this approach is that the quaternion rotation is not influenced by the choice of the coordinate system. Further, the Gimbal lock problem does not appear in the quaternion representation. Overleaf, the Euler angles are easy to understand and use, compared to the quaternions and matrices, so can be a good choice for a user interface. Efficient, easy to use with only three components, any rotation can be represented. On the other hand, the most discussed disadvantage is the Gimbal lock and uniqueness for the Euler angles calculations, which miss the inverse rotation in the three-dimensional space. In conclusion, the quaternions offer the best choice for representation of rotations. Now, an example for a better understanding of this problematic is depicted. For the purpose of simplicity, the theory of the quaternions is demonstrated, but only around the z-axis by γ angle. The calculations are performed with a respect to the presented theory and the mathematical notation. Let have two points, for example, B (200; 0; 0) and C (100; 100; 0) of space. We want to rotate them by γ = 10, 02895 degrees around the z-axis. New coordinates, using the theory of quaternions, are found in the Figure 2.