Omni Calculator logo

Quaternion Calculator

Created by Maciej Kowalski, PhD candidate
Reviewed by Anna Szczepanek, PhD and Steven Wooding
Last updated: Jan 18, 2024


Welcome to Omni's quaternion calculator, where we'll deal with this mysterious extension of complex numbers: the quaternions. In short, we represent them using four real values, each corresponding to one of the basic unity quaternions: 11, i\text i, j\text j, and k\text k. To some, they may seem like an artificial creation to make math even more tricky than it already is. To others, they are a useful tool in 3D geometry: mainly to study quaternion rotation. Unfortunately, this doesn't kill the "tricky" part, and, e.g., quaternion multiplication is not a straightforward operation.

But let's not get ahead of ourselves! We begin with where every math topic begins: with an introduction. In our case, it's the quaternion definition.

The quaternion definition

Quaternions are an extension of complex numbers. They were first introduced by Sir William Hamilton, who used them to describe several properties of the three-dimensional space (for more, see the dedicated section).

However, nowadays, most often, we introduce them from the algebraic point of view. Let's take a look at the formal quaternion definition.

💡 Quaternions are expressions of the form q=a+bi+cj+dkq = a + b \,\text i + c \,\text j + d \, \text k, where aa, bb, cc, and dd are arbitrary real numbers and i\text i, j\text j, and k\text k are base elements sometimes called the basic unity quaternions.

By the above quaternion definition, we see that the space is spanned by four base elements: 11, i\text i, j\text j, and k\text k. The three letters don't stand for any particular value: they simply denote independent base vectors. Nevertheless, if i\text i seems familiar, it well should! In fact, if the coefficients of j\text j and k\text k (i.e., cc and dd in the above quaternion definition) are both zero, then we obtain the (well-known) complex numbers! As such, we indeed obtain their extension.

More or less, Hamilton's idea was to have one expression whose individual parts (i.e., the base elements' coefficients) describe the distinct directions in a three-dimensional space. From there, he only needed to introduce operations between these new thingies. On the one hand, we'd like them to satisfy some properties and form a nice algebraic structure. On the other, the operations should be usable and have real-life explanations. After all, quaternions originated from geometry — a very real-life area of mathematics.

Now that we know what a quaternion is, we can go further. The subsequent sections describe the basic rules governing these numbers. Note how Omni's quaternion calculator lets you find all values and objects we mention. For more information on how to use the tool, see the last section.

Adding and subtracting quaternions

This one's easy. Recall from the above section that quaternions are spanned by four base elements: 11, i\text i, j\text j, and k\text k. As such, if we want to add or subtract two such expressions, we do it the same way as in any vector space: move from one base element to the other and add or subtract the respective coefficients of the two quaternions. And since these coefficients are simply real numbers, it boils down to the very basics of mathematics which we learned in primary school.

(a+bi+cj+di)+(e+fi+gj+hk)=(a+e)+(b+f)i+(c+g)j+(d+h)k(a+bi+cj+di)(e+fi+gj+hk)=(ae)+(bf)i+(cg)j+(dh)k\footnotesize \begin{split} & (a + b\,\text i + c\,\text j + d\,\text i) + (e + f\,\text i + g\,\text j + h\,\text k) = \\ &(a + e) + (b + f)\,\text i + (c + g)\,\text j + (d + h)\,\text k \\[1.5em] & (a + b\,\text i + c\,\text j + d\,\text i) - (e + f\,\text i + g\,\text j + h\,\text k) = \\ &(a - e) + (b - f)\,\text i + (c - g)\,\text j + (d - h)\,\text k \end{split}

Plain sailing, wouldn't you say? Such addition satisfies all the reasonable properties: it's associative, commutative, and every quaternion qq has its opposite q-q such that q+(q)=(q)+q=0q + (-q) = (-q) + q = 0.

Unfortunately, the story is a bit more difficult for multiplication and even more so for division.

Quaternion multiplication and division

In real and complex numbers, we got used to the distributive property of multiplication over addition, so we'd like to have a similar law here. After all, quaternions are sums of four elements: the real part and the i\text i, j\text j, and k\text k parts. In other words, we want to have:

(a+bi+cj+dk)(e+fi+gj+hk)=a(e+fi+gj+hk)+bi(e+fi+gj+hk)+cj(e+fi+gj+hk)+dk(e+fi+gj+hk)\footnotesize \begin{split} &(a + b\,\text i + c\,\text j + d\,\text k) \cdot (e + f\,\text i + g\,\text j + h\,\text k) \\ &= a \cdot (e + f\,\text i + g\,\text j + h\,\text k) \\ &+ b\,\text i \cdot (e + f\,\text i + g\,\text j + h\,\text k) \\ &+ c\,\text j \cdot (e + f\,\text i + g\,\text j + h\,\text k) \\ &+ d\,\text k \cdot (e + f\,\text i + g\,\text j + h\,\text k) \\ \end{split}

And indeed, it is so. However, we now have to explain how quaternity multiplication works on the individual parts, i.e., on the basic unity quaternions. The following table contains the answer:

·1

·i

·j

·k

1

i

j

k

i

-1

k

-j

j

-k

-1

i

k

j

-i

-1

For completeness, let's write the individual products below:

1i=i1=i1j=j1=j1k=k1=ki2=j2=k2=1ij=k,jk=i,ki=jji=k,kj=i,ik=j\footnotesize \begin{split} &1 \cdot \text i = \text i \cdot 1 = \text i \\&1 \cdot \text j = \text j \cdot 1 = \text j \\ &1 \cdot \text k = \text k \cdot 1 = \text k \\ &\text i ^2 = \text j ^2 = \text k ^2 = -1 \\ &\text i \cdot \text j = \text k, \text j \cdot \text k = \text i, \text k \cdot \text i = \text j \\ &\text j \cdot \text i = -\text k, \text k \cdot \text j = -\text i, \text i \cdot \text k = -\text j \end{split}

In particular, we see that quaternion multiplication is not commutative. However, it is associative, which means the quaternion space is not a field (unlike, e.g., the real or complex numbers). Instead, it's a division ring since every non-zero quaternion has an inverse, as we'll see in the next section.

Coming back to the formula for the product of two quaternions, we can now use the rules given above to write:

(a+bi+cj+dk)(e+fi+gj+hk)=aebfcgdh+(af+be+chdg)i+(agbh+ce+df)j+(ah+bgcf+de)k\footnotesize \begin{split} &(a + b \, \text i + c \,\text j + d \,\text k) \cdot (e + f \,\text i + g \,\text j + h \,k) \\ &= a \,e - b \,f - c \,g - d \,h \\ &+ (a \,f + b \,e + c \,h - d \,g) \cdot \text i \\ &+ (a \,g - b \,h + c \,e + d \,f) \cdot\text j \\ &+ (a \,h + b \,g - c \,f + d \,e) \cdot\text k \end{split}

The operation is often called the Hamilton product in honor of its creator.

Recall from the first section that the idea behind the quaternion definition was for the 44-tuples to represent the three-dimensional space. A keen eye may observe that if we multiply two quaternions whose real parts are zero (i.e., a=e=0a = e = 0 above), then we get precisely the same formula as that of the cross product of two three-dimensional vectors with i\text i, j\text j, and k\text k corresponding to the elementary basis (1,0,0)(1,0,0), (0,1,0)(0,1,0), and (0,0,1)(0,0,1), respectively.

As for dividing quaternions, the matter is even more tricky. As you may know, algebraic structures don't have the operation of division, per se. The expression x/yx / y is simply an abbreviation of xy1x \cdot y ^{-1}. What is more, in real or complex numbers, we have x/y=xy1=y1xx / y = x \cdot y ^{-1} = y^{-1} \cdot x.

On the other hand, we've already mentioned that quaternion multiplication is not commutative, so in general, xy1x \cdot y^{-1} is not the same as y1xy^{-1} \cdot x. Therefore, Omni's quaternion calculator returns both possibilities for the two operations, i.e., xyx \cdot y and yxy \cdot x for multiplication, and xy1x \cdot y^{-1} and y1xy^{-1} \cdot x for division.

Either way, division requires finding y1y^{-1}, i.e., the multiplicative inverse of a quaternion. And how do we do that?

The magnitude, conjugate, inverse, and matrix representation

The magnitude (or norm), conjugate, inverse, and matrix representation are all assigned to a single quaternion. Below, we explain them one by one.

1. The magnitude (norm) of a quaternion

If the name rings a bell, and you feel there was something similar connected with vectors, you're on the right track. As mentioned in the first section, quaternions are simply 44-tuples of real numbers: same as vectors of a four-dimensional Euclidean space. Those vectors all had their magnitude, which basically described their length. So why don't we repeat the reasoning here?

Recall that the magnitude of a vector (in whichever dimension) is the square root of the sum of its coordinates' squares. Analogously, the magnitude (or norm) of a quaternion is:

a+bi+cj+dk=(a²+b²+c²+d²)\footnotesize \begin{split} &\left\| a + b \cdot \text i + c \cdot \text j + d \cdot \text k \right\| \\ &= \sqrt{(a² + b² + c² + d²)} \end{split}

Note how, by definition, the value is always a non-negative real number. What is more, it's equal to zero if and only if the quaternion is zero, i.e., 0+0i+0j+0k0 + 0 \cdot \text i + 0 \cdot \text j + 0 \cdot \text k.

Lastly, observe that if we divide a quaternion by its norm (i.e., divide each of its coefficients), we'll obtain a new quaternion whose magnitude is 11. This simple fact will become quite useful very soon.

2. The conjugate of a quaternion

Recall how the conjugate of a complex number gave the number with the same real part but the opposite imaginary part. This time, we're dealing with expressions of the form a+bi+cj+dka + b \cdot \text i + c \cdot \text j + d \cdot \text k that have one real part (i.e., aa) and three non-real ones (i.e., bb, cc, and dd). Nevertheless, the concept stays the same: we keep the first unchanged and flip the signs in the others.

To be precise, the quaternion conjugate formula states that the conjugate of a+bi+cj+dka + b \cdot \text i + c \cdot \text j + d \cdot \text k is abicjdka - b \cdot \text i - c \cdot \text j - d \cdot \text k.

We denote the conjugate of a quaternion qq by q\overline q (as above), but some sources also use qtq^t, q~\tilde q, or qq^*.

Also, observe that if we multiply a quaternion by its conjugate in whichever order, we'll obtain a difference of squares:

qq=(a+bi+cj+dk)(abicjdk)= a2(bi+cj+dk)2\footnotesize \begin{split} q \cdot \overline q = &\left (a + b \, \text i + c \,\text j + d \, \text k \right) \\ \cdot &\left(a - b \, \text i - c \, \text j - d \, \text k \right) \\ = &\ a^2 - \left (b \, \text i + c \, \text j + d \, \text k \right )^2 \end{split}

If we expand it according to the rules from the above section, we'll get:

qq=qq=a2+b2+c2+d2=q2\footnotesize \begin{split} q \cdot \overline q &= \overline q \cdot q \\ &=a^2 + b^2 + c^2 + d^2 \\ &= \left\| q \right\| ^2 \end{split}

Again, a simple fact that will prove very useful.

3. The inverse of a quaternion

Let's begin with the obvious: only non-zero quaternions have an inverse. Secondly, even with quaternion multiplication not being commutative, every non-zero qq has its inverse q1q^{-1} such that qq1=q1q=1q \cdot q^{-1} = q^{-1} \cdot q = 1, where 1=1+0i+0j+0k1 = 1 + 0 \cdot \text i + 0 \cdot \text j + 0 \cdot \text k.

To find the reciprocal, recall that for every quaternion qq, we have qq=qq=q2q \cdot \overline q = \overline q \cdot q = \left\| q \right\| ^2. For a non-zero qq, this gives q(qq2)=(qq2)q=1q \cdot \left( \frac{\overline q}{ \left\| q \right\| ^2}\right) = \left( \frac{\overline q}{ \left\| q \right\| ^2}\right) \cdot q =1, which means that:

q1=qq2\footnotesize q^{-1} = \cfrac{\overline q}{ \left\| q \right\| ^2}

(Note how in the above section, we mentioned some issues with dividing quaternions. However, here, we divide by a positive real number, i.e., divide each of the quaternions coefficients. In other words, everything is fine.)

4. Matrix representation

Complex numbers are pairs of real numbers, and quaternions are 44-tuples of real numbers. And just as we can represent the prior as 2×22 \times 2 matrices, we can have the latter as 4×44 \times 4 ones. The matrix representation basically takes the quaternion's coefficients and puts them in the right places with the right signs (which come from the relations between unity quaternions). To be precise, we can write q=a+bi+cj+dkq = a + b \, \text i + c \, \text j + d \, \text k as:

[abcdbadccdabdcba]\footnotesize \begin{bmatrix} a & - b &-c & -d \\ b & a & -d & c \\ c & d & a & -b \\ d & -c & b & a \end{bmatrix}

In fact, alternatively, we can also use an equivalent 2×22 \times 2 matrix representation with complex entries:

[a+bic+dic+diabi]\footnotesize \begin{bmatrix} a +b \, \text i & c + d \,\text i\\ -c +d \,\text i & a - b \, \text i \end{bmatrix}

To motivate the concept, let us mention a couple of its properties: the magnitude q \left\| q \right\| is equal to the square root of the matrix' determinant, and the conjugate q\overline q corresponds to the conjugate transpose.

Alright, we've learned the basic operations, including quaternions, but so far, we've only seen formulas that may seem useless by themselves. Now, it's time for some practical uses! We'll get back to geometry, learn to convert a quaternion to a rotation matrix, and see how it all works in the three-dimensional space.

🙋 If you'd like to refresh your knowledge of matrices' properties and operations, then you might want to take a look at our matrix determinant calculator, matrix transpose calculator, or the matrix multiplication calculator.

3D geometry: quaternion rotation

The three-dimensional Euclidean space consists of points (x,y,z)(x, y, z) with arbitrary real numbers as coordinates. If we see it as a vector space, it's spanned by three elements: (1,0,0)(1, 0, 0), (0,1,0)(0, 1, 0), and (0,0,1)(0, 0, 1), which we call the elementary basis. On the other hand, there are four basic unity quaternions: 11, i\text i, j\text j, and k\text k. However, if we think of the non-real ones as analogous to the elementary euclidean vectors, we can use them for quaternion rotation.

To have rotation, we need an axis around which we rotate and an angle. The prior will simply be a straight line, but for calculations, we don't really need any line equations. In fact, a single non-zero vector will suffice: it uniquely defines a line by setting its direction.

Clearly, we can define a line using many different vectors as long as they are scaled versions of one another. Therefore, for our purposes, we'll stick to unit vectors (i.e., those of length 11). You can transform any non-zero vector v\vec v into a unit one by dividing it (i.e., dividing all its coordinates) by its length: v/v\vec v / \left | \vec v \right |. Obviously, we could alter the formulas to allow other vectors, but it's far simpler to write them with this simple assumption. Nevertheless, note that Omni's quaternion calculator allows non-unit ones: it simply converts them itself.

You can read more about vectors at our vector calculator or the unit vector calculator.

Now, let's cover two topics connecting quaternions to rotation, one by one.

1. Rotation around an axis

Suppose a unit vector va=(xa, ya, za)\vec v_\text a = (x_\text a, \ y_\text a, \ z_\text a) defines a line in a three-dimensional space.

"Using quaternions for rotation around an axis.

Then, we can represent the rotation around the line by an angle θ\theta by the quaternion:

q=cos(θ/2)+(xai+yaj+zak)sin(θ/2)=cos(θ/2)+(xasin(θ/2))i+(yasin(θ/2))j+(zasin(θ/2))k\footnotesize \begin{split} q = &\cos(θ/2) \, + \\ &(x_\text a \, \text i + y_\text a \, \text j + z_\text a \,\text k) \sin(θ/2) \\[1em] = &\cos(θ/2) + (x_\text a \sin(θ/2)) \,\text i \, + \\ &(y_\text a \sin(θ/2)) \,\text j + (z_\text a \sin(θ/2)) \,\text k \end{split}

Alternatively, we can recall that a three-dimensional space consists of triples of real numbers. Therefore, we can choose to write such triples as matrices with three rows and one column. Then, if we write the qq above as q=a+bi+cj+dkq = a + b \cdot \text i + c \cdot \text j + d \cdot \text k, we can represent the operation with a 3×33 \times 3 matrix, i.e., we can change a quaternion to a rotation matrix given by the following formula (note how this is a very different concept than the matrix representation in the above section):

[12(c2+d2)2(bcad)2(bd+ac)2(bc+ad)12(b2+d2)2(cdab)2(bdac)2(cd+ab)12(b2+c2)]\scriptsize \begin{bmatrix} 1 - 2(c^2 + d^2) & 2(bc -ad) & 2(bd + ac)\\ 2(bc + ad) & 1- 2(b^2 +d^2) & 2(cd - ab) \\ 2(bd - ac) & 2(cd +ab) & 1 - 2(b^2 + c^2) \end{bmatrix}

2. Vector rotation

Point 1. tells us how to "store" the data and the idea of rotating around an axis. Point 2. tells us what we get when we apply the rotation to a given vector v=(x,y,z)\vec v = (x, \, y, \, z).

Using quaternions for vector rotation.

The first option is to use the rotation matrix RR above and multiply it by v\vec v (represented as a one-column matrix). Then, the vector v=R×v\vec v' = R \times \vec v is the result of rotating v\vec v around the axis given by va=(xa,ya,za)v_\text a = (x_\text a, \, y_\text a, \, z_\text a) by an angle θθ.

Alternatively, we can use quaternions and quaternion multiplication. However, before we begin, we need to understand v\vec v as a quaternion: after all, right now, it's simply a triple of real numbers.

Define a quaternion qv=0+xi+yj+zkq_\text v = 0 + x \, \text i + y \, \text j + z \, \text k. In this language, we the rotated vector v\vec v' from conjugating qvq_\text v by the rotation quaternion qq from point 1. To be precise, if we set qv=qqvq1q_\text v' = q \cdot q_\text v \cdot q^{-1}, then the result will take the form qv=0+xi+yj+zkq_\text v' = 0 + x' \, \text i + y' \, \text j + z' \, \text k, and from there we read off the vector: v=(x,y,z)\vec v' = (x', \, y', \, z'). In fact, in this case, the rotation quaternion qq is unitary (i.e., has magnitude 11), so q1=qq^{-1} = \overline q, meaning we could have used the conjugation instead of inverse above.

That concludes the theoretical part. Let's now make good use of the knowledge of what a quaternion is and all the formulas and take on an example or two.

Example: using the quaternion calculator

The above sections took us through all the functionalities of Omni's quaternion calculator. Arguably, there are quite a few, so let's try out a couple to get a taste. We'll find:

  1. The result of quaternion multiplication of q1=2i+3j+kq_1 = 2 - \text i + 3 \, \text j + \text k and q2=54i+kq_2 = 5 - 4 \, \text i + \text k, and
  2. The quaternion of rotation corresponding to the line given by the vector va=(1,0,1)\vec v_\text a = (1, 0, -1) and the angle θ=60°θ = 60°.

Obviously, we'll apply the formulas we've learned. However, before we do that, we let the quaternion calculator do the talking and work out the solution for us.

1. To multiply two quaternions using our tool, we begin by telling the calculator what we want from it. In our case, this means choosing "product" from the list in the variable field "I want to find the…" That will trigger two sections underneath, each dedicated to one of the quaternions. Note how at the top of them, we can see the symbolic representation that is used below: q1=a+bi+cj+dkq_1 = a + b \, \text i + c \, \text j + d \, \text k and q2=e+fi+gj+hkq_2 = e + f \, \text i + g \, \text j + h \text \, k. Looking back at the example, we input:

a=2, b=1, c=3, d=1e=5, f=4, g=0, h=1\small \begin{split} a &= 2, \ b=-1, \ c=3, \ d =1 \\ e&=5, \ f=-4, \ g=0, \ h=1 \end{split}

(Note how we have b=1b = -1, d=1d = 1, and h=1h = 1 even though there were no numbers in the corresponding places in q1q_1 and q2q_2 above. That is because, by convention, we don't write 11s in front of variables. Also, observe that we input g=0g = 0 since q2q_2 has no summand with the unity quaternion j\text j: that means its coefficient is, in fact, 00.)

Once we write the last entry, the quaternion calculator will spit out the answer underneath.

2. Again, we begin by stating what we need. This time, we choose "quaternion of rotation" under "I want to find the…" This will trigger two sections: one for the coordinates of the vector defining the rotation axis and one for the angle. The prior is written symbolically as va=(xa,ya,za)\vec v_\text a = (x_\text a, \, y_\text a, \, z_\text a), and the latter simply by θ\theta. Looking back at the example, we input:

xa=1, ya=0, za=1, θ=60°\small x_\text a = 1, \ y_\text a = 0, \ z_\text a = -1, \ \theta = 60°

(Note how the tool lets you change the angle unit if needed.) The moment we give the last value, the quaternion calculator presents the answer underneath. Note how apart from the rotation quaternion, it also converts the quaternion to a rotation matrix.

Alright, we've played around a bit; now it's time to get our hands dirty. Surely, we won't be as fast as the calculator, but let's go through the calculations nevertheless.

1. Here, we simply follow the quaternion multiplication rules described in the dedicated section, i.e., use the distributive property of multiplication over addition, and compute the products of basic unity quaternions.

q1q2= (2i+3j+k)(54i+k)= 2(54i+k)i(54i+k)+3j(54i+k)+k(54i+k)= 108i+2k5i4+j+15j+12k+3i+5k4j1= 510i+12j+19k\footnotesize \begin{split} \!q_1\! \cdot\! q_2 = &\ (2 - \text i + 3 \, \text j + \text k)\! \cdot\! (5 - 4 \, \text i + \text k) \\[1em] = &\ 2\! \cdot\! (5 - 4 \, \text i + \text k) - \text i\! \cdot\! (5 - 4 \, \text i + \text k) \\ &+ 3 \text j\! \cdot\! (5 - 4 \, \text i + \text k)\\ &+ \text k\! \cdot\! (5 - 4 \, \text i +\text k) \\[1em] = &\ 10 - 8 \, \text i + 2 \, \text k - 5 \, \text i - 4 + \text j\\ &+ 15 \, \text j + 12 \, \text k + 3 \, \text i + 5 \, \text k\\ &- 4 \, \text j - 1 \\[1em] = &\ 5 - 10 \, \text i + 12 \, \text j + 19 \, \text k \end{split}

2. To find the quaternion of rotation, we begin by finding the unitary equivalent of the vector vv. For that, we start with its length:

v=12+02+(1)2=1+0+1=2\footnotesize \begin{split} |\vec v| &= \sqrt{1^2 + 0^2 + \left(-1 \right)^2} \\ &= \sqrt{1 + 0 + 1} = \sqrt{2} \end{split}

and use the appropriate formula:

v/v=(1/2,0/2,1/2)=(0.52,0,0.52)\footnotesize \begin{split} \vec v / |\vec v| &= (1 / \sqrt 2, \, 0 / \sqrt 2, \, -1 / \sqrt 2) \\ &= (0.5\sqrt 2, \, 0, \, -0.5\sqrt 2) \end{split}

Now, it's enough to use the formula from the dedicated section:

q=cos(60°/2)+(0.52i+0j0.52k)sin(60°/2)=0.53+(0.52i0.52k)1/2=0.53+0.252i0.252k\footnotesize \begin{split} q &= \cos(60°/ 2)\\ &\quad+ \left(0.5\sqrt{2} \, \text i + 0 \cdot \text j - 0.5\sqrt{2} \,\text k\right)\\ &\quad\cdot \sin(60° / 2) \\ &= 0.5\sqrt{3} + \left(0.5\sqrt{2} \,\text i - 0.5\sqrt{2} \,\text k\right) \cdot 1/2 \\ &= 0.5\sqrt{3} + 0.25\sqrt{2} \, \text i - 0.25\sqrt{2} \, \text k \end{split}

Lastly, if we choose to convert the quaternion to a rotation matrix, the same section provides the formula to do so:

[12(02+(2/4)2)2(2/403/2(2/4))2(2/4(2/4)+3/20)2(2/40+3/2(2/4))12((2/4)2+(2/4)2)2(0(2/4)3/22/4)2(2/4(2/4)3/20)2(0(2/4)+3/22/4)12((2/4)2+02)]\tiny \begin{bmatrix} 1 - 2 \left(0^2 + \left(-\sqrt{2}/4\right)^2\right) & 2 \left(\sqrt{2}/4 \cdot 0 - \sqrt{3}/2 \left(-\sqrt{2}/4\right)\right) & 2 \left( \sqrt{2}/4 \left(-\sqrt{2}/4\right) + \sqrt{3}/2 \cdot 0\right) \\ 2 \left(\sqrt{2}/4 \cdot 0 + \sqrt{3}/2 \left (-\sqrt{2}/4\right)\right) & 1 - 2\left(\left(\sqrt{2}/4\right)^2 + \left(-\sqrt{2}/4\right)^2\right) & 2\left(0 \left(-\sqrt{2}/4\right) - \sqrt{3}/2 \cdot \sqrt{2}/4\right) \\ 2\left(\sqrt{2}/4 \left(-\sqrt{2}/4\right) - \sqrt{3}/2 \cdot 0\right) & 2\left(0 \left(-\sqrt{2}/4\right) + \sqrt{3}/2 \cdot \sqrt{2}/4\right) & 1 - 2\left(\left(\sqrt{2}/4\right)^2 + 0^2\right) \end{bmatrix}

which is:

[0.756/40.256/40.56/40.256/40.75]\footnotesize \begin{bmatrix} 0.75 & \sqrt 6/4 & -0.25\\ -\sqrt 6/4 & 0.5 & -\sqrt 6/4\\ -0.25 & \sqrt 6/4 & 0.75 \end{bmatrix}

Phew, that was some work, wouldn't you say? And the sine and cosine were fairly simple, so it can be even longer in general. Oh, it's a good thing we have Omni's quaternion calculator to spare us the hassle!

FAQ

How do I use quaternions for rotation?

To use quaternions for rotation, you need to:

  1. Identify the vector defining the axis of rotation.

  2. If needed, find its unit equivalent.

  3. The quaternion of rotation is q = cos(θ/2) + (x_a × i + y_a × j + z_a × k) × sin(θ/2), where:

    • v_a = (x_a, y_a, z_a) is the unit vector defining the axis; and

    • θ is the angle by which you rotate.

  4. If needed, rotate v using the formula q_v' = q × q_v × q⁻¹, where:

    • v = (x, y, z) is the vector you rotate;

    • q is as in step 3;

    • q⁻¹ is the multiplicative inverse of q;

    • q_v = x × i + y × j + z × k;

    • if q_v' = 0 + x' × i + y' × j + z' × k, then v' = (x', y', z'); and

    • v' is the result of rotating v.

How do I multiply quaternions?

To multiply quaternions, you need to:

  1. Use the distributive property of multiplication over addition.

  2. Multiply basic unity quaternions according to the rules:

    • 1 × i = i × 1 = i, 1 × j = j × 1 = j,1 × k = k × 1 = k;

    • i² = j² = k² = -1;

    • i × j = k, j × k = i, k × i = j; and

    • j × i = -k, k × j = -i, i × k = -j.

  3. Simplify by combining common summands.

  4. Enjoy your quaternion product.

Are all rotations expressible as unit quaternions?

Yes, we can express any rotation around an axis in a three-dimensional space by a unit quaternion. By default, the formulas are for axes going through the origin, but you can always compose the rotation with a translation to suit your purposes.

Are the quaternions a field?

No. Quaternion multiplication is not commutative, which is a must-have for a structure to be a field. However, all other field properties are satisfied, so, in the end, quaternions form a division ring.

Are the quaternions commutative?

No, or, to be precise, quaternion multiplication isn't commutative. On the other hand, quaternion addition does commute.

Maciej Kowalski, PhD candidate
I want to find the
sum
.
q₁ = a + bi + cj + dk
Real part (a)
The i coefficient (b)
The j coefficient (c)
The k coefficient (d)
q₂ = e + fi + hj + hk
Real part (e)
The i coefficient (f)
The j coefficient (g)
The k coefficient (h)
Check out 40 similar algebra calculators 🔡
Absolute value equationAbsolute value inequalitiesAdding and subtracting polynomials… 37 more
People also viewed…

Car heat

The hot car calculator shows how fast a car's interior heats up during a summer day.

Ideal egg boiling

Quantum physicist's take on boiling the perfect egg. Includes times for quarter and half-boiled eggs.

Phase shift

The phase shift calculator is here to find the amplitude, period, phase shift, and vertical shift of an arbitrarily changed sine or cosine function.

String girdling

The string girdling Earth calculator can help you determine the extra string length needed to achieve a desired gap or the resulting gap achieved by splicing a given string length.
Copyright by Omni Calculator sp. z o.o.
Privacy, Cookies & Terms of Service