Quaternions introduction
Why quaternions?
The quaternion notation is the least intuitive solution, but it has several advantages that make it very commonly used in many fields that deal with orientation in 3D space. First, however, the basic operations in the domain of quaternions as well as the assumptions made in the following chapters will be described. The main advantages will be seen in the next chapters, but this part is to give some awareness about quaternions properties used in the next operations. Although it is not necessary to understand quaternions up smallest detail, in my opinion, it is really pleasant to know how some mathematics, used in projects works. Also, I hope that this presentation of quaternions (of course not complete and probably fully correct in math rigor) will be more approachable for non-mathematicians.
What are quaternions?
Quaternions are just extensions of complex numbers.They have Real part - and Imaginary part - but instead of 1, there are 3 imaginary symbols ( ). If the real part is zero then such a quaternion calls a pure quaternion. If the imaginary part is zero it is just a real number.
Multiplication and addition in the quaternion domain is performed identically to multiplication polynomials with 3 variables (i, j, k), where the relations between imaginary units are following:
Quaternions multiplication is noncommutative but separable for addition. Commutative is multiplication by a scalar. Each quaternion whose norm is different from 0 has its inverse:
In addition, we define the conjugation of a quaternion - a quaternion with opposite signs in the imaginary part. This is usually indicated by an asterisk or a horizontal line above the quaternion. On this blog we will use the notation :
It is worth noting that the conjugation of a quaternions multiplication is equal to reverse multiplication of conjugations of these quaternions:
The norm of a quaternion is defined analogically to a norm of a 4D vector:
Similarly scalar product/dot product:
As in the case of normal vectors, for quaternions it is possible to determine the cosine of the angle between them:
And the inverse of a quaternion can be determined as:
Methods of division can also be defined, but due to the non-transitive nature of multiplication, a distinction is made between right and left division:
By analogy with the complex numbers, quaternions can be written in the trigonometric form:
Expotential function can be defined in a few ways but using one of them we can write:
in place of will be paste vector and an angle :
treating the vector as a pure quaternion, to calculate it can be shown that:
the formulas for can be recognized in the above sums. Therefore, it can be written:
The trigonometric form of the quaternion obtained in this way corresponds to that known from equation ( ), where the quaternion is the unit quaternion.
The unit quaternions ( ) can be identified with rotation (this will be shown in the next section). This is particularly interesting from the point of view of determining the orientation of the drone in space. In addition, the awareness of the unity of the quaternion norm allows to simplify many notations, which greatly increases readability. Therefore, from this point on, it is assumed that all quaternions used below satisfy the condition .
The simplifications resulting from this assumption are as follows:
The interpretation of the division ( ) is the determination of the quaternion of rotation between quaternions describing 2 orientations in space (from the orientation described by one can arrive at the orientation - see post Quaternions as rotations in 3D space).
Due to the numerical errors that occur, the norm of a quaternion may differ from unity. Therefore, to preserve the properties of unit quaternions, normalization must be performed. Its performance does not differ in any way from the normalization of a 4D vector:
Those are the main operations and properties of quaternions which will be used in the following posts. I hope it is not so scary and as more often we will be using it, more natural it will become.
Comments
Post a Comment