Drag for trackball rotation.
Use arrow keys and m,n to rotate around axes.
Notes & Credits
See comments to understand how the math works.
The most important operation, multiplication, is implemented for convenience, so you won't have to implement it yourself!