I\'m a physicist, and have been learning some programming, and have come across a lot of people using quaternions for rotations instead of writing things in matrix/vector fo
An answer that someone might read: There are tedious problems with all representations. Quaternions are smaller than matrices but the quaternion multiplication is not a mere vector dot product or such, and in fact takes more time on a computer than the dot product of two 3x3 matrices. (Computers are very very good at operating with ordinary matrices)
Matrices though have other annoying features. For example, they are not stable creatures in the long run. When modelling rotations in 3D space, one usually accumulates rotations on top of each other into an Orientation matrix, that is just a single rotation matrix storing the orientation of a reference frame. This process will over the course of millions of additions cause the O-matrix to diverge from a strict rotation matrix form. This can be circumvented by periodically reconfiguring the matrix, but there are conditions when this is nontrivial. Namely the no-rotation case of identity matrix.
You would want to find an axis-angle representation (or quaternion representation) of the rotation, and then reproduce a matrix for that. Most algorithms produce a zero vector, and then encounter zero-division in this case. In these kinds of cases it is also generally a poor idea to try to avoid such cases with "if 0 then..." -type of solutions, since a) forks are slow and b) you can still end up machine epsilon apart from singularity and end up with horrendous errors.