Everything You Need to Know to Know About Quaternions

 

            You’ve heard of the complex numbers, which act as extensions of the real numbers that let us take square roots of negative numbers. 

            But have you heard of quaternions?

A snake saying, "No."

            Quaternions are an extension of the complex numbers. It creates three units: i, j, and k. These basic quaternions have a few simple rules, generally combined together as:

i^2=j^2=k^2=ijk=-1.

            From that, we can derive1i^2=ijk from the equation given, and dividing both sides by i we get i=jk. (We can do this because the i is in the front on both sides. In other cases this is not allowed, as we will see in a moment.) We can continue in a similar fashion to derive the rest of the following table. a multiplication table for basic quaternions: 

\timesijk
i-1k-j
j-k-1i
kj-i-1
To use this table, multiply the left number by the top number, such that ij=k.
A snake wondering why i*j is not equal to j*i

            Ah, you noticed that, did you? That’s because the basic quaternions are noncommutative, which in practice means ij=k, but ji=-k. Anyway, enough with the basic quaternions. Let’s learn about real (haha) quaternions.

            Vocab time! Quaternions are combinations of the basic quaternions and real numbers, and they’re of the form q=a+bi+cj+dk. Their conjugates are denoted by q^* and are equal to q^*=a-bi-cj-dk. If you multiply a quaternion by its conjugate and take the square root, you get its norm, which is also equal to \sqrt{a^2+b^2+c^2+d^2}. A quaternion of norm one is called a unit quaternion or versor.

            Now that we’re done with that, we can—

A snake wondering what the point of quaternions is

—look at applications of quaternions. The main use of quaternions is, of course, modeling rotations in 3D space, which all self-respecting software designers should know.

Two intertwined pythons saying, "Of course"

            So how does this work? First, let us explore using complex numbers to model rotations in 2D space. Say you have a point (2,3) and you want to rotate it 30 degrees.

A point

First, convert the coordinate plane into a complex plane.


            Next,
the clever part: You multiply the resulting complex number (2+3i) by \cos30+i\sin30. (This is the position of a 30-degree angle on a unit circle.) This turns into \frac{\sqrt{3}}{2}+\frac{1}{2}i. Multiplying by the original complex number/point, you get:

(2+3i)(\frac{\sqrt{3}}{2}+\frac{1}{2}i)=\sqrt{3}+i+\frac{3\sqrt{3}}{2}i-\frac{3}{2} \approx0.23+3.6i

 

           which is, when translated into the coordinate point (0.23,3.6), our rotated point.


        Quaternions allow us to turn this model into three dimensions. I’m not going to go into a full-depth explanation, but how it works is you use each of the basic quaternions as an axis of rotation, a versor being a specific 3D angle on a unit sphere. You use a set of equations to map the point onto its rotated image.

            I know what you’re thinking now. You’re thinking,

A snake thinking, "How do I rotate in 4D?"

            There are a separate set of things for that. Those are octonions, and the so-called unit octonions are denoted by e_0 through e_7. There are even sedenions for 5D rotations. However, as a rule of thumb, the more you go along the “-nion” axis, the less useful the “-nions” get, and sedenions are for most purposes useless.

            Well, that’s everything you need to know to know about quaternions! I hope you enjoyed reading about this, and I will come back soon. Bye!

Sources/Footnotes

  • 1
    i^2=ijk from the equation given, and dividing both sides by i we get i=jk. (We can do this because the i is in the front on both sides. In other cases this is not allowed, as we will see in a moment.) We can continue in a similar fashion to derive the rest of the following table.

Leave a Reply

Your email address will not be published. Required fields are marked *