Quaternion
Preface
Let’s now face another central argument to solve the problem to find the attitude of an aircraft in a clean, consistent, reliable way on a digital computer. To follow this post is essential some basic knowledge of complex number (see “Complex numbers” post)
Quaternion, this amazing mathematical entity
Hamilton in 1843 introduced this new mathematical entity: here we don’t want to enter into specific mathematical important issues, like the consistency and the completeness of the theory. We assume its validity and we want only understand its meaning and its use.
The definition I like is my own interpretation of this entity. Let’s make this observation: let’s assume that a three dimensional vector is an extension of one dimensional representation of a real number. The quaternion has the same meaning, for complex number: they are a three dimensional extension of the imagery part of a complex number, that is:
where i, j, k are three unitary pure imaginary number (in analogy with i, j, k versors of a real three dimensional reference system).
q0 is called the real or scalar part of the quaternion, while
Furthermore i, j, k obey to the following rules:
but they are non commutative respect to multiplication. In fact:
The conjugate of quaternion 1) is
Using the shown quaternion properties
which is called the length or norm of the quaternion
Now we know almost all we need for using quaternions: one additional rules will be demonstrated later concerning the derivative of a quaternion.
Let’s now consider a vector V in the real world whose components are X, Y, Z. Let’s now “transport” our vector from the “real world”, in the “quaternion world”. In this new world our vector assume the form of a pure imaginary quaternion, that is
Let’s now examine the operation
where q is a versor (
Equation 2) can be written as:
Adopting the just learned quaternion rules, relation 3) becomes:
Relation 4) can be written as:
which simply represents a coordinate transformation.
It is extraordinary important to note that relation 5) is identical to relation 3) of the post “Euler parameters”, when we pose:
This means that operation 2) is equivalent to the rotation of the reference system around a vector represented by the imaginary (or vector) part of the quaternion, of an angle μ.
Furthermore, as anticipated in the post “Euler parameters”, it establishes an equivalence between the Euler parameters and the component of the quaternion representing the identical rotation.
Double rotations
The matter of two successive rotations may be easily handled. Consider the following transformation just seen above:
and apply to
Let’s call
Expression 8) takes the form
It’s easy to demonstrate that both q3 and q4 are versors and that
This means that two subsequent rotation, the first described by quaternion q1, the second described by quaternion q2, is equivalent to a rotation described by quaternion q3 = q1 q2. This rule will be useful in the next paragraph
Quaternion differentiation
In this part we face the problem of quaternion differentiation which plays a fundamental role to find our solution. In the following I use a less formal mathematical approach, maybe not loved by mathematicians, but very effective for an engineer like me. Furthermore I’ve never seen in literature a similar approach. Let’s define the derivative of a quaternion as the limit of the incremental ratio when the increment going to zero, i.e.
Rotation represented by quaternion q(t+Δt) can be thought as a rotation until time t, and a subsequent infinitesimal rotation during time Δt, that we call
Let’s consider now the quaternion
We recall that
Being
Relation 13) becomes
where
using 14), definition 12) becomes
but
From 15) let’s calculate dϵ/dt
being the derivative of the angle of rotation around the axis of rotation equal to the angular velocity. Recalling that
where we have used the classical aeronautical notation to identify the three angular velocities of roll, pitch and yaw around the X, Y, Z aircraft axis (P, Q, R).
Finally, adopting a synthetic notation
where
is the pure imaginary quaternion representing the overall angular velocity around the rotation axis
Relation 18) represents the key to calculate the quaternion components. Solving the differential equation 18) we know the
We now need to open a parenthesis over relation 18). In all text related to quaternions the derivative of a quaternion respect to time can assume the following expression:
but in this case the considered rotation is related to a point around an axis of rotation identified by the quaternion, remaining in the same reference system, while expression 18) represent the rotation of the reference system around an axis of rotation identified by the quaternion, which is the case study we are interested on, as explained in the post “Euler parameters”.
Developing relation 18) we obtain:
if we adopt a matrix notation we can write 19) as
Equation 20) is the key mathematical relation that allows us, once solved, to determine the component of the quaternion when P, Q and R angular velocities are known. In the post LL_algo we focalize our effort in solving differential equation 20) with an optimize algorithm with the paramount characteristic to be immune from the “gimbal lock” problem.
Quaternion-Euler Angles relation
One more notion we will need in solving equation 20), is the definition of the initial value of the quaternion, giving the initial values of the Euler angles of the aircraft.
Let’s suppose that the initial attitude of the Aircraft is defined by the angles ψ, ϑ and φ.
Let’s start with ψ. We learned in the post “Euler Angles”, that ψ is the first rotation around the Z axis. Let’s try now to apply what we learned in this post about quaternions: how to express this rotation in terms of quaternions?
First af all we know the axis of rotation, the Z axis: this means that ɑ and β in 6) are
Repeating the same reasoning for , ϑ and φ we reach to the following :
The 3 quaternions above can be written as:
In this post we have already learned how to face the issue of multiple rotation (see relation 9)). Applying the same concept, we can say that the resulting quaternion qr which takes into account the 3 rotations expressed by 23), 24) and 25) is
substituting 23), 24), and 25) in 26)
The result of this operation (taking into account all the rules related to multiplication among i, j and k, as discussed at the beginning of this post) is:
which can be written in quaternion notation as
Relation 27) will be used to initialize quaternion values once the 3 attitude angles are known
Comments