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:

ij = k ji = -k jk = i kj = -i ki = j 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:



(a 1 + b 1 i + c 1 j + d 1 k) (a 2 + b 2 i + c 2 j + d 2 k)

= a 1 (a 2 + b 2 i + c 2 j + d 2 k)

+ b 1 i(a 2 + b 2 i + c 2 j + d 2 k)

+ c 1 j(a 2 + b 2 i + c 2 j + d 2 k)

+ d 1 j(a 2 + b 2 i + c 2 j + d 2 k)

= a 1 a 2 + a 1 b 2 i + a 1 c 2 j + a 1 d 2 k

+ b 1 a 2 i + b 1 b 2 i2 + b 1 c 2 ij + b 1 d 2 ik

+ c 1 a 2 j + c 1 b 2 ji + c 1 c 2 j2 + c 1 d 2 jk

+ d 1 a 2 k + d 1 b 2 ki + d 1 c 2 kj + d 1 d 2 k2

= a 1 a 2 + a 1 b 2 i + a 1 c 2 j + a 1 d 2 k

+ b 1 a 2 i - b 1 b 2 + b 1 c 2 k - b 1 d 2 j

+ c 1 a 2 j - c 1 b 2 k - c 1 c 2 + c 1 d 2 i

+ d 1 a 2 k + d 1 b 2 j - d 1 c 2 i - d 1 d 2

= (a 1 a 2 - b 1 b 2 - c 1 c 2 - d 1 d 2 )

+ (a 1 b 2 + b 1 a 2 + c 1 d 2 - d 1 c 2 )i

+ (a 1 c 2 - b 1 d 2 + c 1 a 2 + d 1 b 2 )j

+ (a 1 d 2 + b 1 c 2 - c 1 b 2 + d 1 a 2 )k



Share this: Twitter

Facebook

Like this: Like Loading... Related