You have to convert them to get a human-readable representation (Euler angles) or something OpenGL can understand (Matrix).The only disadvantages of quaternions are: Similar to rotation matrices, you can just multiply 2 quaternions together to receive a quaternion that represents both rotations.After a lot of calculations on quaternions and matrices, rounding errors accumulate, so you have to normalize quaternions and orthogonalize a rotation matrix, but normalizing a quaternion is a lot less troublesome than orthogonalizing a matrix.Smooth interpolation between two quaternions is easy (in contrast to axis/angle or rotation matrices).The conversion to and from axis/angle representation is trivial.They can be represented as 4 numbers, in contrast to the 9 numbers of a rotations matrix.Quaternions don't suffer from gimbal lock, unlike Euler angles.Quaternions have some advantages over other representations of rotations. Unit quaternions are a way to compactly represent 3D rotations while avoiding singularities or discontinuities (e.g. Every unit quaternion represents a 3D rotation, and every 3D rotation has two unit quaternion representations. Sounds scary? Ok, so now you know never to ask that question again.įortunately for you, we will only work with a subset of quaternions: unit quaternions. The math behind quaternions is only slightly harder than the math behind vectors, but I'm going to spare you (for the moment).
Alternatively, a quaternion is what you get when you add a scalar and a 3d vector. It's defined as w + xi + yj + zk where i, j and k are imaginary numbers. As far as I know, D3D also has some convenience functions for Quaternions.Ī quaternion is an element of a 4 dimensional vector-space. I hope someone with more knowledge on the topic will review this article.Īlthough this article is in the OpenGL-section, the background information is of course true for Direct3D too. Unfortunately, I'm not exactly a quaternion-specialist, so there might be errors here. Quaternions are all the rage these days for (3D) computer games, so this wiki wouldn't be complete without an explanation about them. 5.2 The complex conjugate of a quaternion.