# How quaternions work, a reference

edited
Quaternions seem to have been popping up in conversation a lot recently - they dominated a good hour of discussion at the post-meetup 2 weeks ago, and people keep mentioning them on twitter. So I went searching for good reference material, seeing as my usual explanation "quaternions are recipes for rotation matrices", while useful, was feeling like it was on slightly shaky foundations and only helped if it came with a list of stuff you shouldn't try to do with a quaternion, instead of a prescriptive understanding of why those things don't work in the first place...

Anyway, here's the best reference I could find:
http://www.essentialmath.com/GDC2013/GDC13_quaternions_final.pdf

You need a bit of grounding in vector math and understanding matrices helps, but is not essential. Not only did this help me understand why quaternions are related to complex numbers (it's because of their unique method of multiplication, hah) but they're just stealing a representation method, not giving a crap about root -1. This also helped me understand why our basis vectors are usually called i, j and k (complex numbers start at i by convention and we're using complex representations to get around problems with division producing unknowable terms otherwise) AND it confirmed that my "recipe for rotation matrices" working definition was almost right.

I also now understand why I was having those problems with my fractional rotation code in DD: Assuming that the w term was going to be different sizes AND that quaternions would share the same axis (which would mean w would be the only term to change, hence comparable) is daft because of the way quaternions are constructed. Also, Euler's representation of rotation is damn smart, we're just dumb because we'd rather use his name on Euler angle representations instead ;)