A Tutorial on Euler Angles and Quaternions Moti Ben-Ari Department of Science Teaching Weimann Institute of Science http://www.weimann.ac.il/sci-tea/benari/ Version.0.1 c 01 17 b Moti Ben-Ari. This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. To view a cop of this license, visit http://creativecommons.org/licenses/ b-sa/3.0/ or send a letter to Creative Commons, Castro Street, Suite 900, Mountain View, California, 901, USA.
Chapter 1 Introduction You sitting in an airplane at night, watching a movie displaed on the screen attached to the seat in front of ou. The airplane gentl banks to the left. You ma feel the slight acceleration, but ou won t see an change in the position of the movie screen. Both ou and the screen are in the same frame of reference, so unless ou stand up or make another move, the position and orientation of the screen relative to our position and orientation won t change. The same is not true with respect to our position and orientation relative to the frame of reference of the earth. The airplane is moving forward at a ver high speed and the bank changes our orientation with respect to the earth. The transformation of coordinates (position and orientation) from one frame of reference is a fundamental operation in several areas: flight control of aircraft and rockets, movement of manipulators in robotics, and computer graphics. This tutorial introduces the mathematics of rotations using two formalisms: (1) Euler angles are the angles of rotation of a three-dimensional coordinate frame. A rotation of Euler angles is represented as a matri of trigonometric functions of the angles. () Quaternions are an algebraic structure that etends the familiar concept of comple numbers. While quaternions are much less intuitive than angles, rotations defined b quaternions can be computed more efficientl and with more stabilit, and therefore are widel used. The tutorial assumes an elementar knowledge of trigonometr and matrices. The computations will be given in great detail for two reasons. First, so that ou can be convinced of the correctness of the formulas, and, second, so that ou can learn how to do them ourselves, in case ou come across a contet that uses different definitions or notation. For a comprehensive presentation of quaternions using vector algebra, see: John Vince. Quaternions for Computer Graphics, 011, Springer. 1
Chapter Rotations in two dimensions We start b discussing rotations in two dimensions; the concepts and formulas should be familiar and a review will facilitate learning about rotations in three dimensions..1 Cartesian and polar coordinates A vector or a position (the tip of the vector) in a two-dimensional space can be given either in cartesian coordinates (, ) or in polar coordinates (r, φ), relative to a frame of reference: φ r The formulas for transforming one representation to another are: r cos φ r sin φ r + φ tan 1.. Rotating a vector Suppose now that the vector is rotated b the angle θ: r θ φ r
The new vector s polar coordinates are (r, φ + θ) and its cartesian coordinates can be computed using the trigonometric identities for the sum of two angles: r cos(φ + θ) r(cos φ cos θ sin φ sin θ) (r cos φ) cos θ (r sin φ) sin θ cos θ sin θ, r sin(φ + θ) r(sin φ cos θ + cos φ sin θ) (r sin φ) cos θ + (r cos φ) sin θ cos θ + sin θ sin θ + cos θ. The transformation of the position (, ) to (, ) caused b a rotation through the angle θ can be epressed in matri notation as: Eample [ [ cos θ sin θ Let r 1 and let both θ and φ be 30 so that: sin θ cos θ [ r cos φ cos φ cos θ cos 30 3/ r sin φ sin φ sin θ sin 30 1/. We can now compute the values of and : [ [ [ [ 3/ 1/ 3/ 1/ 3/ 1/ The result makes sense since φ + θ 60. ( 3/) (1/) 1/ 3/ + 1/ 3/. [ 1/. 3/.3 A geometric derivation of the rotation matri The rotation matri can be derived geometricall. Rather than look at the vector, let us look at its and components and rotate them (counterclockwise) b θ (Figure.1). The - and - components are rotated b the angle θ so that the OAB becomes OA B. Construct two right triangles: (1) Drop the perpendicular from A to the -ais to form the right triangle OA C; (b) Construct a line through A parallel to the -ais and a line through B parallel to the -ais. The intersect at C to form the right triangle B A C. Since A C is parallel to CO, C A O A OC θ. OA B is a right angle and A B C is a right triangle so A B C θ. The sides of the two right triangles are labeled with 3
B (, ) θ cos θ B (, ) C sin θ 90 θ A sin θ O θ cos θ C A Figure.1: Geometric derivation of the rotation matri their lengths obtained b trigonometr. It is now eas to see that is the length of OC minus the length of A C and that is the length of CA plus the length of C B : cos θ sin θ sin θ + cos θ.. Rotating the frame of reference The effect of rotating a vector b θ is the same as the effect obtained b rotation of the frame of reference. The left diagram below shows a vector in the frame of reference A. The right diagram shows the same vector after frame A is rotated θ relative to a new frame B. ( A, A ), ( B, B ) A r ( A, A ) A B r A φ A φ θ B Given the coordinates ( A, A ) of the points in the frame A: A r cos φ A r sin φ,
what are its coordinates ( B, B ) in the frame B? The geometr of this diagram is the same as the geometr of the diagram in Section., so we can use the same equation: Eample [ B B [ cos θ sin θ sin θ cos θ [ A A. (.1) Consider the point ( A, A ) ( 3/, 1/) in frame A. What are the coordinates of the point in frame B? As before, the computation gives: [ B B [ 3/ 1/ [ 1/ 3/ 3/ 1/ [ 1/. 3/.5 Multiple rotations Rotate the coordinate frame B b ψ relative to a new frame C. ( A, A ), ( B, B ), ( C, C ) A B C r B A φ θ ψ C If we know ( B, B ), we can multipl it b the rotation matri for ψ to obtain ( C, C ). Let us denote the rotation matri from frame A to frame B b R B A and the rotation matri from frame B to frame C b R C B. Given pa, the coordinates of a point in frame A, its coordinates in frame B are p B R B A pa, and p C, its coordinates in frame C, are p C R C B pb. Combining the two equations we have: p C R C B pb R C B RB A pa. Let R C A RC B RB A. This is the rotation matri from A to C, so we can obtain the coordinates p C directl from p A b: p C R C A pa. Eample Let ψ 30 so R C B RB A. Then: [ C C [ 3/ 1/ [ [ 1/ 1/ 0. 3/ 3/ 1 5
From the drawing we see the vector lies on the C -ais which corresponds to the coordinates (0, 1). Let us now compute: R C A RC B RB A [ 3/ 1/ [ 1/ 3/ 3/ 1/ [ 1/ 1/ 3/. 3/ 3/ 1/ The computation p C R C A pa is: [ [ C 1/ [ 3/ 3/ 3/ 1/ 1/ C [ 0 1, the same result obtained in the two-stage computation. Eample Consider the vector (1, 0) ling on the -ais of frame A. Rotate A b 15 to frame B and then rotate frame B b 30 to frame C. Hopefull, the coordinates of the vector in frame C will be ( /, /), because the vector makes an angle of 5 with the -ais of frame C. The values of the trigonometric functions for 15 are: 6 + 6 cos 15, sin 15. First rotate b 15 : [ B Now rotate b 30 : [ C C B [ 3 1 [ 6+ 6 1 3 6 6+ [ 6+ 6 If we multipl the two rotation matrices: [ 6+ 6 6 6+ [ 3 1 [ 1 0 1 3 the result is the rotation matri for a rotation b 5. [ 18+ 8 18+ 8 [ [ 6+ 6. [ If we multipl the two matrices in the opposite order, we get the same result: [ [ 3 1 6+ 6 [ 1 3 6 6+. This shows that rotating b 15 and then b 30 gives the same result as rotating b 30 and then b 15. This is not surprising because we are familiar with the commutativit of turning knobs clockwise and counterclockwise. Unfortunatel, we will not be so luck when we discuss three-dimensional rotations. 6,.
Chapter 3 Rotations in three dimensions The concept of coordinate transformations in three-dimensions is the same as in two dimensions, however, the mathematics are more complicated. Furthermore, man of us find it difficult to visualie eplanations of three-dimensional motion when all we are shown is two-dimensional representations of three-dimensional objects. The great eighteenth-centur mathematician Leonhard Euler proved that an arbitrar three-dimensional rotation can be obtained b three individual rotations around the aes. In his honor, the angles of the rotations are called Euler angles. 3.1 Rotations around the three aes A two-dimensional - coordinate frame can be considered to be part of the threedimensional coordinate frame b adding a -ais perpendicular to the - and -aes. Here is a two-dimensional representation of the three-dimensional coordinate frame: up in left right out down The -ais is drawn left and right on the paper and the -ais is drawn up and down on the paper. The diagonal line represents the -ais, which is perpendicular to the other two aes and therefore its positive direction is out of the paper and its negative direction is into the paper. The standard -- coordinate frame has the positive directions of its aes pointing in the directions (right, up, out) as shown in the left diagram: 7
Rotate the coordinate frame counterclockwise around the -ais, so the -ais which remains unchanged (right diagram). The new orientation of the frame is (up, left, out). Consider now a rotation of 90 around the -ais: This causes the -ais to jump out of the page and the -ais to fall down onto the page, resulting in the orientation (right, out, down). Finall, consider a rotation of 90 around the -ais (left diagram): The -ais drops below the paper and the -ais falls right onto the paper. The new position of the frame is (in, up, right). 3. The right hand rule The -ais must be perpendicular to the - and -aes, but there are two orientations for this line: one in which the positive direction of the ais is out of the paper and another where the positive direction of the ais is into the paper. It doesn t matter which one we choose as long as the choice is consistent. The conventional choice is the right hand rule. Curl the fingers of our right hand so that the go b the shortest path from the one ais to another ais. Your thumb now points in the positive direction of the third ais. For the familiar - and -aes on paper, curl our fingers on the short 90 path from the -ais to the -ais (not on the long 70 path from the -ais to the -ais). When ou do so our thumb points out of the paper and this is taken as the positive direction of the -ais. The following diagram shows the right-hand coordinate sstem displaed with each of the three aes pointing out of the paper: 8
The three rotations are: Rotate from to around, Rotate from to around, Rotate from to around. 3.3 Matrices for three-dimensional rotations A three-dimensional rotation matri will be a 3 3 matri because each point p in a frame has three coordinates p, p, p that must be moved. Consider first a rotation around the -ais. The and coordinates are rotated as in two dimensions and the coordinate remains unchanged. Therefore, the matri is: cos θ sin θ 0 sin θ cos θ 0. 0 0 1 For a rotation about the -ais, the coordinate is unchanged and the and coordinates are transformed as if the were the and coordinates of a rotation around the -ais: 1 0 0 0 cos θ sin θ. 0 sin θ cos θ For a rotation about the -ais, the coordinate is unchanged and the and coordinates are transformed as if the were the and coordinates of a rotation around the -ais: cos θ 0 sin θ 0 1 0 sin θ 0 cos θ It ma seem strange that the signs of sin θ have changed. To convince ourself that this matri is correct, redraw the diagram in Section. and perform the computations, substituting for and for.. 9
3. Multiple rotations Here is an eample of three successive rotations of a coordiante frame: first, 90 around the -ais, then 90 around the -ais and finall 90 around the -ais: This is called a Euler angle rotation. The final orientation is (in, up, right). There is one caveat to composing rotations: three-dimensional rotations do not commute. Let us demonstrate this b a simple sequence of two rotations. Consider a rotation of 90 around the -ais, followed b a rotation of 90 around the -ais: The result can be epressed as (up, out, right). Now consider the commuted operation: a rotation of 90 around the -ais, followed b a rotation of 90 around the -ais: The result can be epressed as (out, left, down) which is not the same as the previous orientation. There are three aes so there should be 3 3 7 sequences of Euler angles. However, there is no point in rotating around the same ais twice in succession because the same result can be obtained b rotating once b the sum of the angles, so there are onl 3 1 different Euler angle sequences:. 10
3.5 Euler angles for transforming a vector Let us return to the sequence of Euler angle rotations at the beginning of Section 3.. Consider the vector (or point) (1, 1, 1) in the final frame: (1, 1, 1) What are its coordinates in the previous frame that was rotated around the -ais to become this frame? Rotating the previous frame (not the vector), we find that the point s coordinates are (1, 1, 1): (1, 1, 1) What are its coordinates in the previous frame that was rotated around the -ais to become this frame? Rotating the previous frame around the -ais gives (1, 1, 1): (1, 1, 1) Finall, what are its coordinates in the previous frame that was rotated around the -ais to become this frame? Rotating the previous frame around the -ais gives the coordinates in the original frame (1, 1, 1): (1, 1, 1) These coordinates can be computed from the rotation matrices for the rotations around the three aes. First around the -ais: 1 1 0 0 1 1 0 0 1 1, 1 0 1 0 1 11
then around the -ais: and finall around the -ais: 1 1 1 0 0 1 0 1 0 1 0 0 1 0 1 0 1 1 0 0 1 0 0 1 1 1 1 1 1 1,. 3.6 One matri for three rotations Instead of performing the three multiplications of a vector b a matri, we can multipl the matrices for the three Euler angles together. The result is the matri for the complete rotation: 0 1 0 0 0 1 1 0 0 0 1 0 0 1 0 0 0 1 1 0 0 0 0 1 0 1 0 1 0 0 0 0 1 0 1 0 1 0 0 0 0 1 0 0 1 1 0 0 0 1 0 1 0 0 The vector (1, 1, 1) can now be multiplied b this matri and we obtain the epected value: 1 0 0 1 1 1 0 1 0 1. 1 1 0 0 1. 3.7 The matri for an arbitrar rotation The previous section showed an eample of a matri that rotates a vector around the aes b 90 each. The matri for arbitrar rotations around these aes is obtained b multipling the matrices for each ais using arbitrar angles: a rotation of ψ around the -ais, a rotation of θ around the ais and a rotation of φ around the -ais. The resulting matri is computed as follows. First multipl the rotation around the -ais b the rotation around the -ais: R (θ) R (φ) cos θ 0 sin θ 0 1 0 sin θ 0 cos θ 1 0 0 0 cos φ sin φ 0 sin φ cos φ cos θ sin θ sin φ sin θ cos φ 0 cos φ sin φ sin θ Then, multipl the result b the rotation around the -ais: R (ψ)(θ)(φ) R (ψ) (R (θ) R (φ) ) cos ψ sin ψ 0 sin ψ cos ψ 0 0 0 1 1 cos θ sin φ cos θ cos φ cos θ sin θ sin φ sin θ cos φ 0 cos φ sin φ sin θ cos θ sin φ cos θ cos φ..
R (ψ)(θ)(φ) R (ψ) (R (θ) R (φ) ) cos ψ cos θ cos ψ sin θ sin φ cos ψ sin θ cos φ+ sin ψ cos φ sin ψ sin φ sin ψ cos θ sin ψ sin θ sin φ+ sin ψ sin θ cos φ cos ψ cos φ cos ψ sin φ sin θ cos θ sin φ cos θ cos φ. For the rotation R (90)(90)(90), we can evaluate the matri to obtain the matri we computed from the individual rotations: 0 0 1 0 1 0. 1 0 0 13
Chapter Quaternions.1 Comple numbers A comple number is a pair written formall as a + bi, where a, b are real numbers and i is a new smbol. Arithmetic is performed as if comple numbers were formal polnomials with indeterminate i and then simplified using the identif i 1: (a + bi) + (c + di) (a + c) + (b + d)i (a + bi) (c + di) ac + adi + bci + bdi (ac bd) + (ad + bc)i. Comple numbers can represent vectors and points in the plane. The number + i is identified with the vector from (0, 0) to the point (, ). Comple multiplication can be used to rotate a vector. B Euler s formula: so: e iθ (cos θ + i sin θ), e iθ ( + i) (cos θ + i sin θ)( + i) ( cos θ sin θ) + i( sin θ + cos θ), which is the two-dimensional rotation of (, ) b θ: [ [ cos θ sin θ sin θ cos θ [. In 183, the mathematician William R. Hamilton discovered that three-dimensional rotations can be described b a generaliation of comple numbers called quaternions.. The algebra of quaternions A quaternion is a -tuple written formall as q 0 + q 1 i + q j + q 3 k, where q i are real numbers and the smbols i, j, k satisf the following identities: i j k 1 ij k, ji k jk i, kj i ki j, ik j. Multiplication of these smbols i, j, k are not commutative. To remember the sign of a multiplication, consider the smbols to be arranged cclicall: 1
i k j If two smbols to be multiplied are adjacent clockwise, the sign is plus, whereas if the are adjacent counterclockwise, the sign is minus. Arithmetic is performed formall and the results are simplified using the identities. Here are the formulas for adding and multipling two quaternions: (q 0 + q 1 i + q j + q 3 k) + (p 0 + p 1 i + p j + p 3 k) (q 0 + p 0 ) + (q 1 + p 1 )i + (q + p )j + (q 3 + p 3 )k (q 0 + q 1 i + q j + q 3 k) (p 0 + p 1 i + p j + p 3 k) (q 0 p 0 + q 1 p 1 i + q p j + q 3 p 3 k ) + (q 0 p 1 i + q 1 p 0 i + q p 3 jk + q 3 p kj) + (q 0 p j + q p 0 j + q 1 p 3 ik + q 3 p 1 ki) + (q 0 p 3 k + q 3 p 0 k + q 1 p ij + q p 1 ji) (q 0 p 0 q 1 p 1 q p q 3 p 3 ) + (q 0 p 1 + q 1 p 0 + q p 3 q 3 p )i + (q 0 p + q p 0 q 1 p 3 + q 3 p 1 )j + (q 0 p 3 + q 3 p 0 + q 1 p q p 1 )k..3 The conjugate and absolute value of a comple number Comple numbers form a field, because multiplication is commutative and ever nonero comple number has an inverse: (a + bi)(a bi) a b i a + b (a + bi)(a bi) a + b 1 (a + bi) 1 a bi a + b. For a comple number a + bi, define its conjugate as a bi and its norm as a + b. Then its inverse can be written as: 1.. The conjugate and norm of a quaternion The corresponding definitions for quaternions are as follows. 15
Given q q 0 + q 1 i + q j + q 3 k, its conjugate is: and its norm is: q q 0 q 1 i q j q 3 k, q Ever nonero quaternion has an inverse: q 0 + q 1 + q + q 3. q q (q 0 + q 1 i + q j + q 3 k)(q 0 q 1 i q j q 3 k) (q 0 q 0 q 1 q 1 i q q j q 3 q 3 k ) + ( q 0 q 1 + q 1 q 0 q q 3 + q 3 q )i + ( q 0 q + q q 0 + q 1 q 3 q 3 q 1 )j + ( q 0 q 3 + q 3 q 0 q 1 q + q q 1 )k q 0 + q 1 + q + q 3. q 1 q q. Quaternions do not form a field because multiplication is not commutative..5 Quaternions for rotations A vector in three-dimensional space can be epressed as a pure quaternion, a quaternion with no real part: q 0 + i + j + k. A rotation is epressed b a quaternion q R with the additional requirement that its norm q R be equal to 1. A rotation from one coordinate frame A to another B is given b the conjugation operation: q B q R q A q R. This operation will result in a quaternion q B which is also a vector since it has no real part: q R q A q R (q 0 + q 1 i + q j + q 3 k)(i + j + k)(q 0 q 1 i q j q 3 k) ((q 0 + q 1 q q 3) + (q 1 q q 0 q 3 ) + (q 0 q + q 1 q 3 ))i + ((q 0 q 3 + q 1 q ) + (q 0 q 1 + q q 3) + (q q 3 q 0 q 1 ))j + ((q 1 q 3 q 0 q ) + (q 0 q 1 + q q 3 ) + (q 0 q 1 q + q 3))k. The detailed multiplication is given in Appendi A. This computation does not require the computation of trigonometric functions, onl the addition and multiplication of real numbers..6 From a quaternion to a rotation matri We need to compute the quaternion of a rotation from Euler angles and rotation matrices and conversel from quaternions back to angles and matrices. 16
Epressing the formula for q R q A q R as a matri gives: M q 0 + q 1 q q 3 (q 1 q q 0 q 3 ) (q 0 q + q 1 q 3 ) (q 0 q 3 + q 1 q ) q 0 q 1 + q q 3 (q q 3 q 0 q 1 ). (q 1 q 3 q 0 q ) (q 0 q 1 + q q 3 ) q 0 q 1 q + q 3 The matri can be simplified since the norm of a rotation quaternion is 1: q q 0 + q 1 + q + q 3 1, from which we have the following equations: q q 3 q 0 + q 1 1 q 1 q 3 q 0 + q 1 q 1 q q 0 + q 3 1. After simplification the matri becomes: q 0 + q 1 0.5 q 1q q 0 q 3 q 0 q + q 1 q 3 M q 0 q 3 + q 1 q q 0 + q 0.5 q q 3 q 0 q 1. q 1 q 3 q 0 q q 0 q 1 + q q 3 q 0 + q 3 0.5.7 From a matri of angles to a quaternion Given a rotation matri M, we can compute the quaternion that represents the same rotation. First compute the trace, the sum of the elements on the main diagonal of the matri: Trace(M) M 11 + M + M 33 (3q 0 + q 1 + q + q 3 1.5) (3q 0 + (1 q 0) 1.5) (q 0 0.5) q 0 1. We can solve this equation for q 0 : Trace(M) + 1 q 0. Once we have q 0, we can obtain q 1 from M 11 : ( Trace(M) + 1 M 11 (q 0 + q 1 0.5) q 1 M11 + 1 Trace(M). 17 + q 1 0.5 ).
Similarl, q and q 3 can be computed from M and M 33 : q q 3 M M33 + 1 Trace(M). + 1 Trace(M)..8 From Euler angles to a quaternion Given a rotation b an angle, the corresponding quaternion can be computed. Consider the rotation ψ around the -ais: M ψ cos ψ sin ψ 0 sin ψ cos ψ 0. 0 0 1 From the formulas in the previous section and using that Trace(M) cos ψ + 1: q 0 cos ψ + 1 + 1 1 + cos ψ cos ψ, q 1 q cos ψ + 1 ( cos ψ + 1) 0, q 3 1 1 ( cos ψ + 1) 1 cos ψ + sin ψ. Therefore: q ψ cos ψ + k sin ψ. Similarl, we can compute the quaternions corresponding to rotations around the - and -aes: q θ cos θ + j sin θ, q φ cos φ + i sin φ..9 Eample Consider a rotation of +90 around the -ais. It takes the point (1, 0, 0) to (0, 1, 0). The rotation matri is: cos 90 sin 90 0 0 1 0 sin 90 cos 90 0 1 0 0. 0 0 1 0 0 1 18
Using the formulas in Section.7 and computing Trace(M) 0 + 0 + 1 1, we have: q 0 q 1 q q 3 Trace(M) + 1 1 + 1 1 M11 + 1 Trace(M) 0 + 0 0 M + 1 Trace(M) 0 + 0 0 M33 + 1 Trace(M) 1 + 0 1 Therefore: q R k. We can obtain the same result directl from the formula in Section.8:. q R cos 5 + k sin 5 + k. The point (1, 0, 0) is 0 + i + 0j + 0k as a quaternion so we compute the rotation as: q R i q R ( + k) i ( k) ( i + ki) ( k) ( i + j) ( k) 1 (i + j ik jk) 1 (i + j + j i) j. This is the point (0, 1, 0) as epected. 19
Appendi A Multiplication of three quaternions We compute the multiplication of quarternions to change a coordinate frame: q R q A q R (q 0 + q 1 i + q j + q 3 k)(i + j + k)(q 0 q 1 i q j q 3 k). Multipl the first two factors: (q 0 + q 1 i + q j + q 3 k)(i + j + k) q 0 i + q 0 j + q 0 k + q 1 i + q 1 ij + q 1 ik + q ji + q j + q jk + q 3 ki + q 3 kj + q 3 k q 1 q q 3 + q 0 i + q i q 3 i + q 0 j q 1 j + q 3 j + q 0 k + q 1 k q k. Now mulitpl on the right b (q 0 q 1 i q j q 3 k). The real part Multipl the first row b q 0, the second b q 1 i, the third b q j and the fourth b q 3 k: The coefficient of i q 0 q 1 q 0 q q 0 q 3 +q 0 q 1 + q 1 q q 1 q 3 +q 0 q q 1 q + q q 3 +q 0 q 3 + q 1 q 3 q q 3 0. Multipl the second row b q 0 the first b q 1 i, the fourth b q j (since kj i) and the third b q 3 k (since jk i): +q 0 q 0 + q 0 q q 0 q 3 +q 1 q 1 + q 1 q + q 1 q 3 +q 0 q + q 1 q q q q 0 q 3 + q 1 q 3 q 3 q 3. Collecting terms gives: (q 0 + q 1 q q 3 )+ (q 1 q q 0 q 3 )+ (q 0 q + q 1 q 3 ). 0
The coefficient of j Multipl the third row b q 0, the fourth b q 1 i (since ki j), the first b q j and the second b q 3 k (since ik j): +q 0 q 0 q 0 q 1 + q 0 q 3 q 0 q 1 q 1 q 1 + q 1 q +q 1 q + q q + q q 3 +q 0 q 3 + q q 3 q 3 q 3. Collecting terms gives: (q 1 q + q 0 q 3 )+ (q 0 q 1 + q q 3 )+ (q q 3 q 0 q 1 ). The coefficient of k Multipl the fourth row b q 0, the third b q 1 i (since ji k), the second b q j (since ij k and the first b q 3 k: +q 0 q 0 + q 0 q 1 q 0 q +q 0 q 1 q 1 q 1 + q 1 q 3 q 0 q q q + q q 3 +q 1 q 3 + q q 3 + q 3 q 3. Collecting terms gives: (q 1 q 3 q 0 q )+ (q q 3 + q 0 q 1 )+ (q 0 q 1 q + q 3 ). Collect the results in one quaternion ((q 0 + q 1 q q 3 ) + (q 1q q 0 q 3 ) + (q 0 q + q 1 q 3 ))i+ ((q 0 q 3 + q 1 q ) + (q 0 q 1 + q q 3 ) + (q q 3 q 0 q 1 ))j+ ((q 1 q 3 q 0 q ) + (q 0 q 1 + q q 3 ) + (q 0 q 1 q + q 3 ))k. 1