Some time ago, I implemented a trackball without any trigonometric function. In a nutshell, I did it with the following matrix:

$$\frac{1}{q^2}\begin{pmatrix} s^2 + 4(y^2 - x^2) & -8xy & -4sx\\ -8xy & s^2 + 4(x^2 - y^2) & -4sy\\ 4sx & 4sy & s^2 - 4(x^2 + y^2) \end{pmatrix}$$

where \(x\) and \(y\) are the displacements of the mouse on the screen and \(q\) and \(s\) are short for \(1 + x^2 + y^2\) and \(1 - x^2 - y^2\) respectively.

It worked very well and I was happy about it, but there was a little concern: floating point approximations. Since this matrix is made purely out of rational numbers, I was wondering if I could try to do exact calculations. I was expecting things to be slower, but I wanted to see how bad it'd be.

So I picked a javascript bigrational library and gave it a shot:

Apparently your browser does not support HTML5 canvas.

As you can see, things go smooth at first, but if you keeping rotating the cube around, soon enough you'll notice some horrible lag. That's because the numerators and denominators in the matrix become bigger and bigger. Floating point approximations for the numerators, denominators and values of the matrix are shown on the canvas in real-time.