Quaternions are an Extension of Complex Numbers

Quaternions are two things: an extension of the complex numbers and a handy way of representing rotations in computer graphics.  I’m only covering the first one here.  This actually wasn’t covered at GDC, probably because you don’t actually have to understand quaternions to look up the algorithms for using them. I like being complete.

i2 = -1

i is the square root of negative one. They teach that in algebra 1 (or maybe it’s algebra 2). Complex numbers are numbers that have i in them; they look like a + bi, as if i were a variable. (3i) * (4i) = 12i2 = -12.

Quaternions are complex numbers except that they have 3 magic letters instead of 1; the familiar i, as well as j and k. Imaginative, I know.

In quaternions i isn’t the square root of negative one. It’s a square root of negative one. So are j and k.

i2 = j2 = k2 = -1

There are a couple more rules for Quats, but really not that many:

 

  1. ij = k
  2. ji = -k
  3. jk = i
  4. kj = -i
  5. ki = j
  6. ik = -j

 
 
Notice that ij != ji. Multiplication is not commutative (in fact it’s anti-commutative; ab = -ba. These rules are enough to multiply two quats, via one big distribution:


(a1 + b1i + c1j + d1k) (a2 + b2i + c2j + d2k)

= a1(a2 + b2i + c2j + d2k)
+ b1i(a2 + b2i + c2j + d2k)
+ c1j(a2 + b2i + c2j + d2k)
+ d1j(a2 + b2i + c2j + d2k)

= a1a2 + a1b2i + a1c2j + a1d2k
+ b1a2i + b1b2i2 + b1c2ij + b1d2ik
+ c1a2j + c1b2ji + c1c2j2 + c1d2jk
+ d1a2k + d1b2ki + d1c2kj + d1d2k2

= a1a2 + a1b2i + a1c2j + a1d2k
+ b1a2i - b1b2 + b1c2k - b1d2j
+ c1a2j - c1b2k - c1c2 + c1d2i
+ d1a2k + d1b2j - d1c2i - d1d2

= (a1a2 - b1b2 - c1c2 - d1d2)
+ (a1b2 + b1a2 + c1d2 - d1c2)i
+ (a1c2 - b1d2+ c1a2 + d1b2)j
+ (a1d2 + b1c2 - c1b2 + d1a2)k

Advertisements

3 Responses to Quaternions are an Extension of Complex Numbers

  1. […] Quaternions are an Extension of Complex Numbers Quaternions are two things: an extension of the complex numbers and a handy way of representing rotations in computer […] […]

  2. Adam M. Smith says:

    If you think that it cool, consider setting your sights a little higher. In geometric alegbra that i^2 = -1 thing goes from an interesting quirk to a deep statement about geometry (of more than just the complex plane). The general idea is that some physicists took Hamilton’s quaterions and did them right, for all spaces, regardless of dimension and signature, unifying geometry and algebra once and for all. The result, surprisingly, is actually useful in the real world — well, at least to programmers who may do something with a vector once and a while. You don’t usually hear about mathematical controversy, but some people really hate geometric algebra and prefer their unintuitive but familiar traditions while other people want to teach it to kids because, not counting time spend unlearning the old ways, it is much simpler — and it scales.

    I haven’t found the perfect introduction yet, but the book Geometric Algebra for Computer Science is pretty nifty to have in hand — the first chapter is online here: http://geometricalgebra.org/downloads/ga4cs_chapter1.pdf. I think another group is working on a game-oriented GA book, but it isn’t out yet.

  3. Robert Otani says:

    Heh. In grad school, I worked briefly with David Hestenes and dabbled in Geometric Algebra while trying to come up with a thesis… just before I dropped out…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: