How Quaternions encode rotations: derivation and sample code
Anyone interested in such topics should check out geometric algebra, a.k.a. Clifford algebra. Start with http://geocalc.clas.asu.edu/pdf/OerstedMedalLecture.pdfMatrices and trigonometry are in my opinion a pedagogically, conceptually, and practically poor way of understanding and using quaternions; furthermore, cross products (and the associated confusion about a right hand rule and polar vs. axial vectors and so on, not to mention a total failure to generalize to higher dimensions) need to vanish from the earth.More generally, this is a topic that should be explained first using pictures, ideally interactive ones. The algebraic manipulations to formally prove what the pictures explain visually should just fill in the bookkeeping details.Finally, perhaps the most important reason geometric (Clifford) algebras should be used for pedagogy, even if you plan to write code which only uses quaternions per se, is that they make the “sandwich” multiplication of versors as operators on vectors completely obvious as composition of reflections.