Trackball C++ code without quaternions

I'm leaving some code to handle a simple trackball interface to move 3D objects around. Trackballs give an intuitive rotation given an input mouse motion: given a clicked point and a second point moving on the screen we compute a rotation (that you apply to some 3D object in the scene) that gives the user the impression of dragging a 3D ball where we first clicked on it.

The code actually wasn't done by me, but I can't remember where I took it! Originally it was C code which I've wrapped up in a C++ class with way more comments and an example of how to use it. [  C++ trackball code ].