an algorithm for quaternion–based 3d rotation

12
Int. J. Appl. Math. Comput. Sci., 2020, Vol. 30, No. 1, 149–160 DOI: 10.34768/amcs-2020-0012 AN ALGORITHM FOR QUATERNION–BASED 3D ROTATION ALEKSANDR CARIOW a ,GALINA CARIOWA a ,DOROTA MAJORKOWSKA-MECH a, a Faculty of Computer Science and Information Technology West Pomeranian University of Technology in Szczecin ul. ˙ Zolnierska 49, 71-210 Szczecin, Poland e-mail: [email protected] In this work a new algorithm for quaternion-based spatial rotation is presented which reduces the number of underlying real multiplications. The performing of a quaternion-based rotation using a rotation matrix takes 15 ordinary multiplications, 6 trivial multiplications by 2 (left-shifts), 21 additions, and 4 squarings of real numbers, while the proposed algorithm can compute the same result in only 14 real multiplications (or multipliers—in a hardware implementation case), 43 additions, 4 right-shifts (multiplications by 1/4), and 3 left-shifts (multiplications by 2). Keywords: quaternions, space rotation, design of algorithms. 1. Introduction Currently, quaternions (Kantor and Solodovnikov, 1989) are widely used for data processing in various fields of science and engineering including navigation (Fenwick, 1992), orbital mechanics of satellites (Kuipers, 1999; Andreis and Canuto, 2004), robotics and computer vision (Hu et al., 2006; Çakir and Bütün, 2010; Wareham et al., 2005; Terzakis et al., 2014), autonomous vehicles (Roberts et al., 2006; Fresk and Nikolakopoulos, 2013), digital signal and image processing (Bülow and Sommer, 2001; Sangwine and Bihan, 2007; Alfsmann et al., 2007; Pei et al., 2001; 2011; Ell, 1993; Witten and Shragge, 2006; Bayro-Corrochano, 2006), 3D game programming and computer graphics (Pletinckx, 1989; Nüchter, 2009; Angel and Shreiner, 2012; Abbena et al., 2006; Mukundan, 2002; Markley, 2008; Shuster and Natanson, 1993; Vince, 2011; Lengyel, 2011; Hanson, 2006), wireless communications (Wysocki et al., 2006), public-key cryptography (Malekian et al., 2011), crystallographic texture analysis (Kunze and Schaeben, 2004), etc. The most important property of quaternions is the fact that every unit quaternion represents a rotation of objects in three dimensions (3D). This plays an essential role in applying quaternions to perform 3D rotations in various machine vision applications (Rousseau et al., Corresponding author 2002; Terzakis et al., 2014; Kanade, 1987). Using unit quaternions is a most natural, elegant, and practical way to describe rotation in three-dimensional vector spaces (Çakir and Bütün, 2010; Funda et al., 1990; Huynh, 2009). However, the direct applying of quaternions to rotation in three dimensions requires a relatively large amount of computation. For that reason this operation is usually implemented via multiplication of a vector by the so-called “rotation matrix”, which is simply calculated based on the coefficients of the quaternion (Markley, 2008; Shuster and Natanson, 1993). Nevertheless, even this way requires a relatively large amount of computations. In some applications, reducing the number of multiplications is especially important. In this article we will show a new algorithm that requires fewer multiplications than the one that uses a rotation matrix. The paper is organized in the following way. Section 2 describes a rotation in 3D space and introduces a rotation matrix. Section 3 introduces quaternions and describes a rotation in 3D space using quaternions. It also explains a representation of quaternions as 4×4 matrices and clarifies the description of rotation in such a representation. Section 4 details the transformation and the derivations of the final algorithm that turns the vector into the rotation outcome. Section 5 compares the computational complexity of the presented algorithm with other methods of description of rotation in 3D space. © 2020 A. Cariow et al. This is an open access article distributed under the Creative Commons Attribution-NonCommercial-NoDerivs license (http://creativecommons.org/licenses/by-nc-nd/3.0/).

Upload: others

Post on 16-Oct-2021

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: AN ALGORITHM FOR QUATERNION–BASED 3D ROTATION

Int. J. Appl. Math. Comput. Sci., 2020, Vol. 30, No. 1, 149–160DOI: 10.34768/amcs-2020-0012

AN ALGORITHM FOR QUATERNION–BASED 3D ROTATION

ALEKSANDR CARIOW a, GALINA CARIOWA a, DOROTA MAJORKOWSKA-MECH a,∗

aFaculty of Computer Science and Information TechnologyWest Pomeranian University of Technology in Szczecin

ul. Zołnierska 49, 71-210 Szczecin, Polande-mail: [email protected]

In this work a new algorithm for quaternion-based spatial rotation is presented which reduces the number of underlying realmultiplications. The performing of a quaternion-based rotation using a rotation matrix takes 15 ordinary multiplications,6 trivial multiplications by 2 (left-shifts), 21 additions, and 4 squarings of real numbers, while the proposed algorithm cancompute the same result in only 14 real multiplications (or multipliers—in a hardware implementation case), 43 additions,4 right-shifts (multiplications by 1/4), and 3 left-shifts (multiplications by 2).

Keywords: quaternions, space rotation, design of algorithms.

1. Introduction

Currently, quaternions (Kantor and Solodovnikov, 1989)are widely used for data processing in various fields ofscience and engineering including navigation (Fenwick,1992), orbital mechanics of satellites (Kuipers, 1999;Andreis and Canuto, 2004), robotics and computer vision(Hu et al., 2006; Çakir and Bütün, 2010; Warehamet al., 2005; Terzakis et al., 2014), autonomous vehicles(Roberts et al., 2006; Fresk and Nikolakopoulos, 2013),digital signal and image processing (Bülow and Sommer,2001; Sangwine and Bihan, 2007; Alfsmann et al.,2007; Pei et al., 2001; 2011; Ell, 1993; Witten andShragge, 2006; Bayro-Corrochano, 2006), 3D gameprogramming and computer graphics (Pletinckx, 1989;Nüchter, 2009; Angel and Shreiner, 2012; Abbenaet al., 2006; Mukundan, 2002; Markley, 2008; Shusterand Natanson, 1993; Vince, 2011; Lengyel, 2011;Hanson, 2006), wireless communications (Wysocki et al.,2006), public-key cryptography (Malekian et al., 2011),crystallographic texture analysis (Kunze and Schaeben,2004), etc.

The most important property of quaternions is thefact that every unit quaternion represents a rotation ofobjects in three dimensions (3D). This plays an essentialrole in applying quaternions to perform 3D rotationsin various machine vision applications (Rousseau et al.,

∗Corresponding author

2002; Terzakis et al., 2014; Kanade, 1987). Using unitquaternions is a most natural, elegant, and practical wayto describe rotation in three-dimensional vector spaces(Çakir and Bütün, 2010; Funda et al., 1990; Huynh,2009). However, the direct applying of quaternionsto rotation in three dimensions requires a relativelylarge amount of computation. For that reason thisoperation is usually implemented via multiplication ofa vector by the so-called “rotation matrix”, whichis simply calculated based on the coefficients of thequaternion (Markley, 2008; Shuster and Natanson, 1993).Nevertheless, even this way requires a relatively largeamount of computations. In some applications, reducingthe number of multiplications is especially important. Inthis article we will show a new algorithm that requiresfewer multiplications than the one that uses a rotationmatrix.

The paper is organized in the following way.Section 2 describes a rotation in 3D space and introducesa rotation matrix. Section 3 introduces quaternions anddescribes a rotation in 3D space using quaternions. Italso explains a representation of quaternions as 4×4matrices and clarifies the description of rotation in sucha representation. Section 4 details the transformationand the derivations of the final algorithm that turns thevector into the rotation outcome. Section 5 comparesthe computational complexity of the presented algorithmwith other methods of description of rotation in 3D space.

© 2020 A. Cariow et al. This is an open access article distributed under the Creative Commons Attribution-NonCommercial-NoDerivs license (http://creativecommons.org/licenses/by-nc-nd/3.0/).

Page 2: AN ALGORITHM FOR QUATERNION–BASED 3D ROTATION

150 A. Cariow et al.

The last section summarizes the introduced solution anddescribes possible applications of the presented algorithm.

2. Rotations in three-dimensional space andthe rotation matrix

Rotation is a concept coming from geometry and it isalso a basic kind of motion in physics. Any rotation isa motion of a certain space that preserves at least onepoint. It can describe, for example, the motion of a rigidbody around a fixed point. A rotation is different fromother types of motion: translations, which have no fixedpoints, and reflections, each of them having an entiretwo-dimensional flat of fixed points in three-dimensionalspace. In geometry, Euler’s rotation theorem states that,in 3D, any displacement of a rigid body such that a pointon the rigid body remains fixed is equivalent to a singlerotation about some axis that runs through the fixed point.It also means that the composition of two rotations is alsoa rotation.

Generally rotations are not commutative. The axis ofrotation is known as an Euler axis, typically representedby a unit vector n. Let P be chosen point of a rigid body,which rotates according to the right hand rule by the angleϕ about the rotation axis, represented by the unit vector n.Let a reference frame be connected with a point O, whichlies on the rotation axis. In this reference frame, pointP isrepresented by the vector x, as shown in Fig. 1. When we

O

S

Q

P

R.

.

n

x

y

Fig. 1. Illustration of rotation of the vector x by the angle ϕaround the rotation axis represented by the unit vectorn, according to the right hand rule.

rotate the point P about the rotation axis, we get the pointQ—an image of P , which is represented by the vector y.Let the point R be an orthogonal projection of the pointP onto the rotation axis and the point S be an orthogonalprojection of the point Q onto the vector r which starts atpoint R and ends at point P . The vectors

−→RP and

−−→RQ are

equal in length |RP | = |RQ| = r. It is easy to see that

−−→OQ =

−−→OR +

−→RS +

−→SQ. (1)

The first vector can be written in the following way:

−−→OR = n|OR| = n(n · x),

where · denotes the operator of the classical dot product.The second vector which occurs in Eqn. (1) may bepresented as

−→RS =

−→RP

|RP | |RS|

=

−−→OP −−−→

OR

rr cosϕ

= [x− n(n · x)] cosϕ.

The last component in Eqn. (1) is perpendicular to theplane defined by the vectors

−−→OR and

−−→OP , so its direction

is defined by the vector n × x, where × denotes theoperator of the classical cross product. Its length is|SQ| = |RQ| sinϕ = r sinϕ. Hence, we can write

−→SQ =

n× x

|n× x|r sinϕ = (n× x) sinϕ.

Using the above relationships, after some basictransformation, Eqn. (1) may be presented in thefollowing way:

y = x cosϕ+ n(n · x)(1− cosϕ) + (n× x) sinϕ, (2)

which is well known as the rotation formula (Goldstein,1980) or Rodrigues’ rotation formula.

If we chose a Cartesian coordinate system with theorigin at the point O and a standard base, then Eqn. (2)would be as follows:

⎡⎣y1y2y3

⎤⎦ =

⎡⎣r11 r12 r13r21 r22 r23r31 r32 r33

⎤⎦⎡⎣x1

x2

x3

⎤⎦ , (3)

Page 3: AN ALGORITHM FOR QUATERNION–BASED 3D ROTATION

An algorithm for quaternion-based 3D rotation 151

where y = [y1, y2, y3]T, x = [x1, x2, x3]

T,

r11 = cosϕ+ n21(1 − cosϕ),

r12 = n1n2(1− cosϕ)− n3 sinϕ,

r13 = n1n3(1− cosϕ) + n2 sinϕ,

r21 = n1n2(1− cosϕ) + n3 sinϕ,

r22 = cosϕ+ n22(1 − cosϕ),

r23 = n2n3(1− cosϕ)− n1 sinϕ,

r31 = n1n3(1− cosϕ)− n2 sinϕ,

r32 = n2n3(1− cosϕ) + n1 sinϕ,

r33 = cosϕ+ n23(1 − cosϕ),

and n = [n1, n2, n3]T.

The matrix which occurs in (3) is known as therotation matrix. This provides an algebraic descriptionof rotations, and is used extensively for computations ingeometry, physics, and computer graphics.

A general rotation can be composed out of particularrotations along some specified (coordinate) axes, as isdone, for example, in Euler-angle parametrization.

3. Quaternions and their connection withrotations

A quaternion is a hypercomplex number which can bepresented as a four-element vector or as a sum (Kantorand Solodovnikov, 1989):

q =

⎡⎢⎢⎣

q1q2q3q4

⎤⎥⎥⎦ = q1i+ q2j + q3k + q4,

where {ql}, l = 1, . . . , 4, are real numbers, while i, j,k are imaginary units whose products are defined by thefollowing equations:

ij = k, jk = i, ki = j, ji = −k,

kj = −i, ik = −j, ijk = −1.

Addition and multiplication of quaternions aredefined exactly analogously to complex additionand multiplication, but it must be remembered thatmultiplication is not commutative. A quaternion hasa real part q4 and an imaginary part q1i + q2j + q3k.The latter has three components and, thus, can be usedas a vector quantity. For this reason, the real part issometimes referred to as the scalar part of the quaternionand the whole quaternion may be represented by thesum of its vector and scalar parts. A quaternion with azero real or scalar part is called a pure quaternion. Sinceq1i + q2j + q3k is a three-dimensional vector, clearlythere is a one-to-one correspondence between vectorsin 3D space and the quaternion sub-space consisting of

pure quaternions. The modulus (norm) and conjugate ofa quaternion follow the definitions for complex numbers,

|q| =√q21 + q22 + q23 + q24 ,

q∗ = −q1i− q2j − q3k + q4.

A quaternion with a unit modulus is called a unitquaternion. The conjugate of a quaternion is obtained,like the complex conjugate, by negating the imaginaryor vector part. For every non-zero quaternion, an inversequaternion is given by

q−1 =q∗

|q|2 .

Similarly to complex numbers, the quaternion hasalso trigonometric form,

q = |q|(n sinα+ cosα),

where n = n1i + n2j + n3k is a unit pure quaternion.From this representation it follows that every quaternionis connected with a unit vector n, which may be treatedas a vector in 3D space and an angle, so it has the sameparameters as rotations.

Quaternions are widely used to describe rotations in3D space. Compared with rotation matrices, they aremore compact, more numerically stable, and may be moreefficient. Compared with Euler angles, they are simpler tocompose and avoid the problem of gimbal lock.

We can interpret the rotation of the vector x =[x1, x2, x3]

T by the angle ϕ about the axis represented bythe unit vector n = [n1, n2, n3]

T using the quaternionproduct as follows (Mukundan, 2002; Markley, 2008;Shuster and Natanson, 1993):

y = qxq−1, (4)

where q = in1 sinϕ2 + jn2 sin

ϕ2 + kn3 sin

ϕ2 + cos ϕ

2 isa unit quaternion, while x = x1i + x2j + x3k and y =y1i+ y2j+ y3k are quaternion counterparts of the vectorsx and y. Since the quaternion q is a unit quaternion, theinverse q−1 = q∗. A full justification of (4) can be foundin many online sources (e.g., Jia, 2015; Vicci, 2001).

If we calculate the product of quaternions q =q1i + q2j + q3k + q4, x = x1i + x2j + x3k andq∗ = −q1i − q2j − q3k + q4, according to the formula(4), without taking into account the relation between thequaternions q and q∗, we must perform 12 multiplicationsand 8 additions of real numbers when determining theproduct qx (since x is determined by only 3 real numbers),and 12 multiplications and 9 additions of real numberswhen determining the product (qx)q∗ (since y has only 3real components). The total number of multiplications andadditions of real numbers in the calculation of quaterniony will be equal to 24 and 17, respectively.

Page 4: AN ALGORITHM FOR QUATERNION–BASED 3D ROTATION

152 A. Cariow et al.

If we take into account the relation betweenquaternions q and q∗, and do the quaternion multiplicationaccording to Eqn. (4), then we obtain

y = y1i+ y2j + y3k

=[(q21 − q22 − q23 + q24)x1

+ 2(q1q2 − q3q4)x2

+ 2(q1q3 + q2q4)x3

]i

+[2(q1q2 + q3q4)x1

+ (−q21 + q22 − q23 + q24)x2

+ 2(−q1q4 + q2q3)x3

]j

+[2(q1q3 − q2q4)x1

+ 2(q1q4 + q2q3)x2

+ (−q21 − q22 + q23 + q24)x3

]k.

(5)

While we calculate the quaternion y, 6 conventionalmultiplications, 4 operations of squaring, 6 trivialmultiplications by 2 (shifts), and 15 additions are requiredto calculate the expressions in parentheses. Thenmultiplying these results by the components x1, x2 andx3 of quaternion x require further 9 multiplications, andin the end obtaining the sums in square brackets requireanother 6 additions. Thus, 15 multiplications, 4 squaringoperations, 6 multiplications by 2 (which we do not count)and 21 additions are required to rotate the vector in 3Dspace. Then the implementation of such computationsrequires 15 + 4 = 19 multipliers.

From now on we will write subscripts to emphasisethe sizes of vectors and matrices. Using the matrix-vectornotation, Eqn. (5) can be written as follows:

y4 = Q4Q∗4x4, (6)

where

Q4 =

⎡⎢⎢⎣

q4 −q3 q2 q1q3 q4 −q1 q2−q2 q1 q4 q3−q1 −q2 −q3 q4

⎤⎥⎥⎦ ,

Q∗4 =

⎡⎢⎢⎣

q4 −q3 q2 −q1q3 q4 −q1 −q2−q2 q1 q4 −q3q1 q2 q3 q4

⎤⎥⎥⎦ ,

x4 = [x1, x2, x3, 0]T and y4 = [y1, y2, y3, 0]

T are inputand output vectors, respectively. In this context, Q4 isa well-known matrix representation of the quaternion qand “conjugation” of a matrix, marked with an asterisk, isnot a matrix representation of a conjugate quaternion butmeans the change of the signs of the fourth row and thefourth column entries of this matrix (the entry which is inthe fourth row and in the fourth column will change thesign twice, i.e., it will not change).

To show that Eqn. (5) can be written equivalently as(6), we calculate the product of the matrices Q4 and Q∗

4

in the expression (6),

⎡⎢⎢⎣y1y2y30

⎤⎥⎥⎦ =

⎡⎢⎢⎣

q4 −q3 q2 q1q3 q4 −q1 q2−q2 q1 q4 q3−q1 −q2 −q3 q4

⎤⎥⎥⎦

·

⎡⎢⎢⎣

q4 −q3 q2 −q1q3 q4 −q1 −q2−q2 q1 q4 −q3q1 q2 q3 q4

⎤⎥⎥⎦

⎡⎢⎢⎣x1

x2

x3

0

⎤⎥⎥⎦

=

⎡⎢⎢⎣

r11 r12 r13 0r21 r22 r23 0r31 r32 r33 00 0 0 r44

⎤⎥⎥⎦

⎡⎢⎢⎣

x1

x2

x3

0

⎤⎥⎥⎦ ,

where

r11 = q21 − q22 − q23 + q24 ,

r12 = 2(q1q2 − q3q4),

r13 = 2(q1q3 + q2q4),

r21 = 2(q1q2 + q3q4),

r22 = −q21 + q22 − q23 + q24 ,

r23 = 2(q2q3 − q1q4),

r31 = 2(q1q3 − q2q4),

r32 = 2(q2q3 + q1q4),

r33 = −q21 − q22 + q23 + q24 ,

r44 = q21 + q22 + q23 + q24 .

Then we can write⎡⎣

y1y2y3

⎤⎦ =

⎡⎣

r11 r12 r13r21 r22 r23r31 r32 r33

⎤⎦⎡⎣

x1

x2

x3

⎤⎦ . (7)

It is an exact equivalent of Eqn. (5) in vector-matrixnotation.

It can be directly checked that the matrix in theexpression (7) is equal to the rotation matrix from Eqn. (2)when we use the relations q1 = n1 sin

ϕ2 , q2 = n2 sin

ϕ2 ,

q3 = n3 sinϕ2 , q4 = cos ϕ

2 . That is why we use the samesymbols for the entries of the rotation matrix.

It is easy to see that the calculation of the entriesof the rotation matrix, which occurs in (7), requires 6conventional multiplications, 4 operations of squaring,6 trivial multiplications by 2 (shifts), and 15 additions.Multiplication of a vector by this matrix requires 9 moremultiplications and 6 additions. Thus, 15 multiplications,4 squaring operations, 6 multiplications by 2, and 21additions are required to rotate the vector in space.It should be noted that squares are a special case ofmultiplication where both operands are identical. For

Page 5: AN ALGORITHM FOR QUATERNION–BASED 3D ROTATION

An algorithm for quaternion-based 3D rotation 153

this reason, digital circuits designers often use embeddedgeneral-purpose multipliers to implement the squaringunits by connecting a multiplier’s inputs together. Thena completely parallel hardware implementation of suchcomputations requires 15 + 4 = 19 multipliers. Themultiplier is the most critical unit, so reducing the numberof multipliers plays a significant role. We will show howthis can be done.

Since the starting point of the described algorithmof rotation in 3D space is Eqn. (6), we will discusshow this description can be applied to the sequence ofrotations. It is well known that a vector connected to apure quaternion x undergoing two rotations, representedby the unit quaternions p and q, respectively, will havethe same outcome as undergoing a single rotation. Thisrotation is related to the quaternion qp, because the resultof these rotations is equal to

q(pxp∗)q∗ = (qp)x(p∗q∗) = (qp)x(qp)∗. (8)

In this equation, we used the facts that quaternionmultiplication is associative and has the followingproperty:

(qp)∗ = p∗q∗. (9)

Thus, if we want to find the result of many rotations,it is enough to calculate the product of quaternionscorresponding to these rotations, but in reverse order.

In the matrix-vector notation of rotation in 3D space,as in Eqn. (6), if the quaternions p = p1i+p2j+p3k+p4and q = q1i + q2j + q3k + q4 correspond to the matricesP4 and Q4, respectively, where

P4 =

⎡⎢⎢⎣

p4 −p3 p2 p1p3 p4 −p1 p2−p2 p1 p4 p3−p1 −p2 −p3 p4

⎤⎥⎥⎦ ,

Q4 =

⎡⎢⎢⎣

q4 −q3 q2 q1q3 q4 −q1 q2−q2 q1 q4 q3−q1 −q2 −q3 q4

⎤⎥⎥⎦ ,

then, according to (6), the result of composition of rotationwill be described by the vector

Q4Q∗4(P4P

∗4x4). (10)

It is easy to directly check that

Q∗4P4 = P4Q

∗4 (11)

and, unlike the case of the quaternions,

(Q4P4)∗ = Q∗

4P∗4. (12)

These two properties allow us to represent theexpression (10) in the following form:

(Q4P4)(Q4P4)∗x4. (13)

It should be noted that the product Q4P4 is thematrix equivalent of the quaternion product qp. Thus,similarly as in the case of quaternion notation, to findthe result of many rotations, it is enough to calculate theproduct of matrices being the matrix representation of thecorresponding quaternions, but in reverse order. It mightseem that calculating the product of two 4×4 matricesrequires more operations on real numbers than calculatingthe product of two quaternions. However, among the 16entries in each such matrix, only 4 entries differ (e.g.,entries of a selected row or column), and the remainingentries repeat these values. Therefore, to perform aset of consecutive rotations using matrix-vector products,the same number of operations with real numbers isrequired as in the case of using conventional quaternionmultiplication.

4. Synthesis of a rationalized algorithm forquaternion-based 3D rotation

The idea is that both matrices Q4 and Q∗4 in the

expression (6) can be decomposed as an algebraic sumof a symmetric Toeplitz matrix and another matrixwhich has many zero entries. The Toeplitz matrix isshift-structured, and a number of algorithms exist for fastmatrix-vector multiplication. For instance, the matrixcan be diagonalized using the fast Hadamard transform(FHT), and thus matrix-vector products can be computedefficiently.

Let us multiply the last column of Q∗4 by (−1). The

effect of this multiplication is equivalent to changing thelast coordinate of the vector through which the matrix Q∗

4

is multiplied to the opposite. This treatment is undertakenso that the obtained matrix can be written as an algebraicsum of the block-symmetric Toeplitz-type matrix andsome sparse matrix, i.e., a matrix containing only a smallnumber of nonzero entries. We can easily see that suchtransformation leads to minimization of the computationalcomplexity of the final algorithm. We will denote byz4 = [z1, z2, z3, z4]

T the product Q∗4x4, which occurs in

Eqn. (6). Then we can rewrite z4 in the following form:

z4 = Q∗4x4 = (Q4 − 2Q4)x4, (14)

where

Q4 =

⎡⎢⎢⎣

q4 q3 q2 q1q3 q4 q1 q2q2 q1 q4 q3q1 q2 q3 q4

⎤⎥⎥⎦ ,

Q4 =

⎡⎢⎢⎣

0 q3 0 00 0 q1 0q2 0 0 00 0 0 q4

⎤⎥⎥⎦ ,

and x4 = [x1, x2, x3,−x4]T. In this case the

matrix-vector product Q4x4 (with the Toeplitz-type

Page 6: AN ALGORITHM FOR QUATERNION–BASED 3D ROTATION

154 A. Cariow et al.

matrix) can now be calculated using one of thewell-known fast algorithms. Indeed, it is not hard to seethat the matrix has the following structure:

Q4 =

[A2 B2

B2 A2

],

where

A2 =

[q4 q3q3 q4

], B2 =

[q2 q1q1 q2

].

The matrix possessing such a structure can beeffectively factorized (Cariow, 2014), and we cancalculate the product of Q4x4 with the followingdecomposition:

Q4x4 ={(H2 ⊗ I2)

1

2[(A2 +B2)

⊕ (A2 −B2)] (H2 ⊗ I2)}x4, (15)

where

A2 +B2 =

[q4 + q2 q3 + q1q3 + q1 q4 + q2

],

A2 −B2 =

[q4 − q2 q3 − q1q3 − q1 q4 − q2

],

H2 =

[1 11 −1

]

is the second-order Hadamard matrix, IN is the identitymatrix of orderN , and “⊗” and “⊕” denote the Kroneckerproduct and the direct sum of two matrices, respectively(Steeb and Hardy, 2011).

It is easy to see that the matrices A2+B2 and A2−B2

possess a structure that provides “good” factorization, too.Therefore, we can write as previously:

A2 +B2 = H2

{1

4

[(q4 + q2 + q3 + q1

)

⊕ (q4 + q2 − q3 − q1

)]}H2,

A2 −B2 = H2

{1

4

[(q4 − q2 + q3 − q1

)

⊕ (q4 − q2 − q3 + q1

)]}H2.

Combining partial decompositions in a single procedure,we can rewrite (15) as follows:

Q4x4 = W(0)4 W

(1)4 D4W

(1)4 W

(0)4 I4x4, (16)

where

W(0)4 = H2 ⊗ I2 =

⎡⎢⎢⎣

1 0 1 00 1 0 11 0 −1 00 1 0 −1

⎤⎥⎥⎦ ,

W(1)4 = I2 ⊗H2 =

⎡⎢⎢⎣

1 1 0 01 −1 0 00 0 1 10 0 1 −1

⎤⎥⎥⎦,

D4 = diag (s1, s2, s3, s4) ,

I4 =

⎡⎢⎢⎣

1 0 0 00 1 0 00 0 1 00 0 0 −1

⎤⎥⎥⎦ .

The diagonal entries of the matrix D4 are as follows:

s1 =1

4(q4 + q2 + q3 + q1) ,

s2 =1

2(q4 + q2−q3−q1) ,

s3 =1

4(q4 − q2 + q3 − q1) ,

s4 =1

2(q4 − q2 − q3 + q1) .

It is easy to check that the entries of the matrix D4 can becalculated using the following matrix-vector procedure,which reduces the number of underlying real additions:

d4 =1

4W

(1)4 W

(0)4 J4q4, (17)

where

d4 = [s1, s2, s3, s4]T,

J4 =

⎡⎢⎢⎣0 0 0 10 0 1 00 1 0 01 0 0 0

⎤⎥⎥⎦

is the exchange matrix, and

q4 = [q1, q2, q3, q4]T.

Unfortunately, the computational complexity of theproduct 2Q4x4, which occurs in Eqn. (14), cannot bereduced and this product is calculated directly, withoutany tricks. Combining the calculations for both productsQ4x4 and 2Q4x4 in a single procedure, we finally obtain

z4 = Q∗4x4

= Σ4×8W(0)8 W

(1)8 D8W

(1)8 W

(0)8 P

(0)8×4x4, (18)

Page 7: AN ALGORITHM FOR QUATERNION–BASED 3D ROTATION

An algorithm for quaternion-based 3D rotation 155

where

Σ4×8 = (11×2 ⊗ I4)

=

⎡⎢⎢⎣

1 0 0 0 −1 0 0 00 1 0 0 0 −1 0 00 0 1 0 0 0 −1 00 0 0 1 0 0 0 −1

⎤⎥⎥⎦ ,

11×2 = [1,−1],

W(0)8 = (H2 ⊗ I2)⊕ I4

=

⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣

1 0 1 00 1 0 11 0 −1 00 1 0 −1

04

04

1 0 0 00 1 0 00 0 1 00 0 0 1

⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦

,

W(1)8 = (I2⊗H2)⊕ I4

=

⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣

1 11 −1

02

021 11 −1

04

04

1 0 0 00 1 0 00 0 1 00 0 0 1

⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦

,

D8 = diag(s1, s2, s3, s4, s5, s6, s7, s8),

s5 = 2q3, s6 = 2q1, s7 = 2q2, s8 = 2q4,

and s1, s2, s3, s4 are the diagonal entries of matrix D4,

W(0)8 = (H2⊗I2)⊕P

(0)4

=

⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣

1 0 1 00 1 0 11 0 −1 00 1 0 −1

04

04

0 1 0 00 0 1 01 0 0 00 0 0 1

⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦

,

P(0)4 =

⎡⎢⎢⎣

0 1 0 00 0 1 01 0 0 00 0 0 1

⎤⎥⎥⎦ ,

P(0)8×4 = 12×1 ⊗ I4=

⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣

1 0 0 00 1 0 00 0 1 00 0 0 −11 0 0 00 1 0 00 0 1 00 0 0 −1

⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦

,

12×1 = [1, 1]T.

It is not hard to see that the entries of the matrixD8 can be calculated using the following matrix-vectorprocedure:

d8 = D(0)8 W

(1)8 W

(0)8 P

(1)8×4J4q4, (19)

where

d8 = [s1, s2, s3, s4, s5, s6, s7, s8]T,

D(0)8 = diag

(1

4,1

4,1

4,1

4, 2, 2, 2, 2

),

W(0)8 = (H2⊗I2)⊕P

(1)4

=

⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣

1 0 1 00 1 0 11 0 −1 00 1 0 −1

04

04

0 1 0 00 0 0 10 0 1 01 0 0 0

⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦

,

P(1)4 =

⎡⎢⎢⎣

0 1 0 00 0 0 10 0 1 01 0 0 0

⎤⎥⎥⎦ ,

P(1)8×4 = 12×1 ⊗ I4 =

⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣

1 0 0 00 1 0 00 0 1 00 0 0 11 0 0 00 1 0 00 0 1 00 0 0 1

⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦

.

Now we will go back to Eqn. (6). First, wehave shown how to calculate the product Q∗

4x4 = z4.Subsequently, we will focus on calculation of the productQ4z4. We multiply the last row of Q4 by (−1). Then itis not hard to see that the matrix-vector product Q4z4 canbe represented in the following form:

y4 = Q4z4 = I4(Q4 − 2Q4)z4. (20)

Page 8: AN ALGORITHM FOR QUATERNION–BASED 3D ROTATION

156 A. Cariow et al.

It is easy to see that we are again dealing with the samematrices. Thus, in this case all the previous steps related tothe synthesis of the algorithm for calculating the productz4 = Q∗

4x4 can be repeated for calculating the productQ4z4, too. Thus, we can describe the final procedure forcomputing the vector y4 as follows:

y4 = I4Σ4×8W(0)8 W

(1)8 D8W

(1)8 W

(0)8 P

(1)8×4

·Σ4×8W(0)8 W

(1)8 D8W

(1)8 W

(0)8 P

(0)8×4x4. (21)

Realization of computations via (21) requires 16multiplications and 48 additions of real numbers.However, taking into account that x4 = 0 and y4 = 0,the number of operations can be further reduced. Then theexpression (21) can be rewritten in the following refinedform:

y3 = Σ3×7W(0)7 W

(1)7 D7W

(1)7 W

(0)7 P

(1)7×4

·Σ4×7W(0)7 W

(1)7 D7W

(1)7 W

(0)7 P

(0)7×3x3, (22)

where

Σ3×7 =

⎡⎣

1 0 0 0 −1 0 00 1 0 1 0 −1 00 0 1 0 0 0 −1

⎤⎦,

W(0)7 =

⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣

1 0 1 00 1 0 01 0 −1 00 0 0 1

04×3

03×4

1 0 00 1 00 0 1

⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦,

W(1)7 = (I2⊗H2)⊕ I3

=

⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣

1 11 −1

02

021 11 −1

04×3

03×4

1 0 00 1 00 0 1

⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦,

D7 = diag(s1, s2, s3, s4, s5, s6, s7),

W(0)7 =

⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣

1 0 1 00 1 0 01 0 −1 00 0 0 1

04×3

03×4

0 1 00 0 11 0 0

⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦,

P(1)7×4 =

⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣

1 0 0 00 1 0 00 0 1 00 0 0 11 0 0 00 1 0 00 0 1 0

⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦,

Σ4×7 =

⎡⎢⎢⎣

1 0 0 0 −1 0 00 1 0 0 0 −1 00 0 1 0 0 0 −10 0 0 1 0 0 0

⎤⎥⎥⎦,

W(0)7 = (H2 ⊗ I2)⊕ I3

=

⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣

1 0 1 00 1 0 11 0 −1 00 1 0 −1

04×3

03×4

1 0 00 1 00 0 1

⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦,

W(0)7 =

⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣

1 0 1 00 1 0 01 0 −1 00 0 0 1

04×3

03×4

0 1 00 0 11 0 0

⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦,

P(0)7×3 =

⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣

1 0 00 1 00 0 10 1 01 0 00 1 00 0 1

⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦.

In turn, the entries of the matrix D7 = diag(d7) canbe calculated using the following improved matrix-vectorprocedure:

d7 = D(1)7 W

(1)7 W

(2)7 P

(2)7×4J4q4, (23)

whered7 = [s1, s2, s3, s4, s5, s6, s7]

T,

D(1)7 = diag

(1

4,1

4,1

4,1

4, 2, 2, 2

),

W(2)7 =

⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣

1 0 1 00 1 0 11 0 −1 00 1 0 −1

04×3

03×4

1 0 00 0 10 1 0

⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦,

Page 9: AN ALGORITHM FOR QUATERNION–BASED 3D ROTATION

An algorithm for quaternion-based 3D rotation 157

P(2)7×4 =

⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣

1 0 0 00 1 0 00 0 1 00 0 0 10 1 0 00 0 1 00 0 0 1

⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦.

Figure 2 shows a data flow diagram of therationalized algorithm for quaternion-based 3D rotationand Fig. 3 shows a data flow diagram of the process forcalculating entries of the matrix D7 in accordance withthe procedure (23). In this paper, data flow diagramsare oriented from left to right. Straight lines in thefigures denote the operations of data transfer. Pointswhere lines converge denote summation. The dottedlines indicate the subtraction operation. We use theusual lines without arrows intentionally, so as not toclutter the picture. The circles in these figures showthe operation of multiplication by a number (variableor constant) inscribed inside a circle. In turn, therectangles indicate the matrix-vector multiplications withthe Hadamard matrices of order 2.

5. Performance evaluation

Let us now consider the data flow diagrams, presentedin Figs. 2 and 3. One can observe that realization ofcomputations in accordance with (22) and (23) requiresonly 14 multiplications, 43 additions, 4 right-shifts(multiplications by 1/4), and 3 left-shifts (multiplicationsby 2).

Table 1 presents a comparison of the number ofmultiplications and additions of real numbers, which arenecessary for calculating the rotated vector in 3D space,using the quaternion multiplication, the rotation matrixand the proposed algorithm.

As we can see, the implementation of our algorithmrequires fewer multiplications than the implementation ofcalculations based on the rotation matrix-vector product.Reducing the number of multiplications is especiallyimportant in the design of specialized VLSI fully parallelprocessors because minimizing the number of necessarymultipliers also reduces the power dissipation and lowersthe cost implementation of the entire system beingimplemented. This is because a hardware multiplier ismore complicated unit than an adder and occupies much

Table 1. Number of multiplications and additions of real num-bers needed to calculate the rotated vector.

type of quaternion rotation proposedoperation multiplication matrix algorithm

× 24 19 14+ 17 21 43

more of the chip area than the adder. It is provedthat the hardware complexity of an embedded multipliergrows quadratically with the operand size, while thehardware complexity of a binary adder increases linearlywith the operand size. Thus, we want to note that ouralgorithm is mainly focused on a fully parallel hardwareimplementation. In the case of software implementationon modern computers, when multiplication and additioncan take about the same time, the proposed algorithm doesnot give a gain in speed.

6. Conclusion

We presented a new algorithm for quaternion-basedspatial rotation. During the synthesis of the discussedalgorithm we use the fact that the quaternion-basedspatial rotation may be represented as the matrix-vectorproduct y4 = Q4Q

∗4x4. The matrices participating in

the product have unique structural properties that allowperforming its advantageous decompositions. Namely,these decompositions lead to reducing the multiplicativecomplexity of computations. If we compare theeffectiveness of the discussed two approaches, we canconclude the following. The algorithm using the rotationmatrix is more efficient when the set of points (vectors)of a solid body performs the same rotation, because inthis case the rotation matrix is calculated only once andis the same for all points (vectors) of this body. Butif we are dealing with a set of bodies or objects whichcould be treated as ideal particles and rotate at differentangles or around different axes, the rotation matrix mustbe calculated for each element separately and then thealgorithm using this matrix loses in comparison with ouralgorithm. In particular, such a case occurs when weare dealing with a swarm of unmanned aerial vehicles,each of which performs an independent movement andis controlled from a common center (Alfeo et al., 2018;Choutri et al., 2018; Avellar et al., 2015; Joordensand Jamshidi, 2009). Another effective application ofour approach is quaternion-based information security(Czaplewski et al., 2014; Dzwonkowski et al., 2015;Czaplewski and Rykaczewski, 2015). Thus, in some casesthe presented algorithm may appear to be more applicableand convenient from the implementation point of view.

ReferencesAbbena, E., Salamon, S. and Gray, A. (2006). Modern Differen-

tial Geometry of Curves and Surfaces with Mathematica,3rd Edition, Chapman & Hall/CRC, Boca Raton, FL.

Alfeo, A., Cimino, M., Francesco, N.D., Lazzeri, A., Lega, M.and Vaglini, G. (2018). Swarm coordination of mini-UAVsfor target search using imperfect sensors, Intelligent Deci-sion Technologies 12(2): 149–162.

Alfsmann, D., Göckler, H.G., Sangwine, S.J. and Ell,T.A. (2007). Hypercomplex algebras in digital signal

Page 10: AN ALGORITHM FOR QUATERNION–BASED 3D ROTATION

158 A. Cariow et al.

3

2

1

x

x

x

7

6

5

4

3

2

1

s

s

s

s

s

s

s2H

2H

2H2H

2H2H 2H

7

6

5

4

3

2

1

s

s

s

s

s

s

s2H

2H

2H

2H

2H

3

2

1

y

y

y

Fig. 2. Data flow diagram for a rationalized quaternion-based 3D rotation algorithm.

4

3

2

1

q

q

q

q

2

2

2

41

41

41

41

7

6

5

4

3

2

1

s

s

s

s

s

s

s

2H

2H

2H

Fig. 3. Data flow diagram describing the process of calculating entries of the matrix D7.

processing: Benefits and drawbacks (tutorial), EURASIP15th European Signal Processing Conference (EUSIPCO2007), Poznan, Poland, pp. 1322–1326.

Andreis, D. and Canuto, E.S. (2004). Orbit dynamics andkinematics with full quaternions, Proceedings of the2004 American Control Conference, Boston, MA, USA,pp. 3660–3665.

Angel, E. and Shreiner, D. (2012). Interactive Computer Graph-ics: A Top-Down Approach with Shader-Based OpenGL,6th Edition, Pearson, Harlow.

Avellar, G., Pimenta, G.P.L. and Iscold, P. (2015). Multi-UAVrouting for area coverage and remote sensing withminimum time, Sensors 15(11): 27783–27803.

Bayro-Corrochano, E. (2006). The theory and use of thequaternion wavelet transform, Journal of MathematicalImaging and Vision 24(1): 19–35.

Bülow, T. and Sommer, G. (2001). Hypercomplexsignals—a novel extension of the analytic signal to themultidimensional case, IEEE Transactions on Signal Pro-cessing 49(11): 2844–2852.

Çakir, M. and Bütün, E. (2010). Constrained trajectoryplanning for cooperative work with behavior based geneticalgorithm, in A. Ponce de Leon F. de Carvalho et al.

(Eds), Computing and Artificial Intelligence, Advancesin Intelligent and Soft Computing, Vol. 79, Springer,Berlin/Heidelberg, pp. 497–508.

Cariow, C. (2014). Strategies for the synthesis of fast algorithmsfor the computation of the matrix-vector products, Journalof Signal Processing Theory and Applications 3(1): 1–19.

Choutri, K., Lagha, M., Dala, L. and Lipatov, M. (2018).Quadrotors UAVs swarming control under leader-followersformation, 22nd International Conference on System The-ory, Control and Computing (ICSTCC), Sinaia, Romania,pp. 794–799.

Czaplewski, B., Dzwonkowski, M. and Rykaczewski, R. (2014).Digital fingerprinting based on quaternion encryptionscheme for gray-tone images, Journal of Telecommunica-tions and Information Technologies 2: 3–11.

Czaplewski, B. and Rykaczewski, R. (2015). Receiver-sidefingerprinting method for color images based on a seriesof quaternion rotations, Przeglad Telekomunikacyjny +Wiadomosci Telekomunikacyjne (8–9): 1127–1134.

Dzwonkowski, M., Papaj, M. and Rykaczewski, R. (2015). Anew quaternion-based encryption method for DICOMimages, IEEE Transactions on Image Processing24(11): 4614–4622.

Page 11: AN ALGORITHM FOR QUATERNION–BASED 3D ROTATION

An algorithm for quaternion-based 3D rotation 159

Ell, T.A. (1993). Quaternion-Fourier transforms for analysisof two-dimensional linear time-invariant partial differentialsystems, Proceedings of the 32nd IEEE Conference onDecision and Control, San Antonio, TX, USA, Vol. 2,pp. 1830–1841.

Fenwick, E.H. (1992). Quaternions and the art of navigation, In-ternational Journal of Mathematical Education in Scienceand Technology 23(2): 273–279.

Fresk, E. and Nikolakopoulos, G. (2013). Full quaternion basedattitude control for a quadrotor, European Control Confer-ence (ECC), Zürich, Switzerland, pp. 3864–3869.

Funda, J., Taylor, R. and Paul, R. (1990). On homogeneoustransforms, quaternions, and computational efficiency,IEEE Transactions on Robotics and Automation6(3): 382–388.

Goldstein, H. (1980). Finite rotations, Classical Mechanics, 2ndEdn, Addison-Wesley, Reading, MA, pp. 164–166.

Hanson, A.J. (2006). Visualizing Quaternions, Series inInteractive 3D Technology, Morgan Kaufmann Publishers,San Francisco, CA.

Hu, C., Meng, M. Q.-H., Mandal, M. and Liu, P.X. (2006).Robot rotation decomposition using quaternions, Proceed-ings of the 2006 International Conference on Mechatronicsand Automation, Luoyang, Henan, China, pp. 1158–1163.

Huynh, D. (2009). Metrics for 3D rotations: Comparisonand analysis, Journal of Mathematical Imaging and Vision35(2): 155–164.

Jia, Y.-B. (2015). Quaternions and rotations, LectureNotes, Iowa State University, Ames, IO, http://web.cs.iastate.edu/~cs577/handouts/quaternion.pdf.

Joordens, M. and Jamshidi, M. (2009). Underwater swarmrobotics consensus control, 2009 IEEE International Con-ference on Systems, Man and Cybernetics, San Antonio,TX, USA, pp. 3163–3168.

Kanade, T. (1987). Three-Dimensional Machine Vision,Springer International Series in Engineering and ComputerScience, Vol. 21, Kluwer Academic Publishers, Norwell,MA.

Kantor, I.L. and Solodovnikov, A.S. (1989). HypercomplexNumbers, Springer-Verlag, New York, NY.

Kuipers, J.B. (1999). Quaternions and Rotation Sequences: APrimer with Applications to Orbits, Aerospace, and VirtualReality, Princeton University Press, Princeton, NJ.

Kunze, K. and Schaeben, H. (2004). The Bingham distributionof quaternions and its spherical radon transform in textureanalysis, Mathematical Geology 36(8): 917–943.

Lengyel, E. (2011). Mathematics for 3D Game Programmingand Computer Graphics, 3rd Edition, Course TechnologyCengage Learning PTR, Boston, MA.

Malekian, E., Zakerolhosseini, A. and Mashatan, A. (2011).QTRU: Quaternionic version of the NTRU public-keycryptosystems, ISC International Journal of InformationSecurity 3(1): 29–42.

Markley, F.L. (2008). Unit quaternion from rotationmatrix, Journal of Guidance, Control, and Dynamics31(2): 440–442.

Mukundan, R. (2002). Quaternions: From classical mechanicsto computer graphics, and beyond, Proceedings of the 7thAsian Technology Conference in Mathematics, Melaka,Malaysia, pp. 97–106.

Nüchter, D. (2009). Robotic Mapping, Springer Tractsin Advanced Robotics, Vol. 52, Springer-Verlag,Berlin/Heidelberg, pp. 35–76.

Pei, S.-C., Ding, J.-J. and Chang, J. (2001). Color patternrecognition by quaternion correlation, Proceedings of the2001 International Conference on Image Processing, Thes-saloniki, Greece, Vol. 1, pp. 894–897.

Pei, S.-C., Ding, J.-J. and Chang, J.-H. (2011). Efficientimplementation of quaternion Fourier transform,convolution, and correlation by 2-d complex FFT, IEEETransactions on Signal Processing 49(11): 2783–2797.

Pletinckx, D. (1989). Quaternion calculus as a basic tool incomputer graphics, The Visual Computer 5(2): 2–13.

Roberts, G.N., Sutton, R. and Ye, M. (2006). Advances in Un-manned Marine Vehicles, Institution of Engineering andTechnology, Stevenage.

Rousseau, P., Desrochers, A. and Krouglicof, N. (2002).Machine vision system for the automatic identificationof robot kinematic parameters, IEEE Transactions onRobotics and Automation 17(6): 972–978.

Sangwine, S.J. and Bihan, N.L. (2007). Hypercomplex analyticsignals: Extension of the analytic signal concept tocomplex signals, EURASIP 15th European Signal Pro-cessing Conference (EUSIPCO 2007), Poznan, Poland,pp. 621–624.

Shuster, M.D. and Natanson, G.A. (1993). Quaternioncomputation from a geometric point of view, The Journalof Astronautical Sciences 41(4): 545–556.

Steeb, W.-H. and Hardy, Y. (2011). Matrix Calculus and Kro-necker Product: A Practical Approach to Linear and Mul-tilinear Algebra, 2nd Edition, World Scientific PublishingCompany, Singapore.

Terzakis, G., Culverhouse, P., Bugmann, G., Sharma, S. andSutton, R. (2014). On quaternion based parameterizationof orientation in computer vision and robotics, Journal ofEngineering Science and Technology Review 7(1): 82–93.

Vicci, L. (2001). Quaternions and rotations in 3-space: Thealgebra and its geometric interpretation, Technical Re-port TR01-014, University of North Carolina at ChapelHill, Chapel Hill, NC, http://www.cs.unc.edu/techreports/01-014.pdf.

Vince, J. (2011). Quaternions for Computer Graphics, 1st Edi-tion, Springer, London.

Wareham, R., Cameron, J. and Lasenby, J. (2005). Applicationsof conformal geometric algebra in computer vision andgraphics, in H. Li et al. (Eds), Computer Algebra andGeometric Algebra with Applications, Springer-Verlag,Berlin/Heidelberg, pp. 329–349.

Page 12: AN ALGORITHM FOR QUATERNION–BASED 3D ROTATION

160 A. Cariow et al.

Witten, B. and Shragge, J. (2006). Quaternion-based signalprocessing, Proceedings of the New Orleans Annual Meet-ing, New Orleans, LA, USA, pp. 2862–2865.

Wysocki, B.J., Wysocki, T.A. and Seberry, J. (2006).Modeling dual polarization wireless fading channels usingquaternions, Joint IST Workshop on Mobile Future and theSymposium on Trends in Communications SympoTIC’06,Bratislava, Slovakia, pp. 68–71.

Aleksandr Cariow received his PhD and DScdegrees in computer science from LITMO Uni-versity in St. Petersburg, Russia, in 1984 and2001, respectively. In 1999, he joined the Facultyof Computer Science and Information Technol-ogy, West Pomeranian University of Technologyin Szczecin, Poland, where he currently works inthe Department of Computer Architectures andTelecommunications. His research interests in-clude digital signal processing algorithms, VLSI

architectures, and data processing parallelization.

Galina Cariowa received the MSc degree inmathematics from Moldavian State University,Chisinau, in 1978 and the PhD degree in com-puter science from the West Pomeranian Univer-sity of Technology in Szczecin, Poland, in 2007.She is currently working as an assistant professorat the Department of Computer Architectures andTelecommunications there. Her scientific inter-ests include numerical linear algebra and digitalsignal processing algorithms, VLSI architectures,

and data processing parallelization.

Dorota Majorkowska-Mech received the MScdegree in physics in 1994 and the MSc degreein mathematics in 1996 from the University ofSzczecin. In 2008 she obtained the PhD degreein computer science from the West PomeranianUniversity of Technology in Szczecin, where shecurrently works in the Department of ComputerArchitectures and Telecommunications. She isinterested in algorithms of discrete orthogonaltransforms.

Received: 21 March 2019Revised: 22 July 2019Re-revised: 10 October 2019Accepted: 18 October 2019