Correct singularity handling in J3DIMath matrix rotation decomposition

The old formula for handling the case where cos(rotate[1]) == 0 was
incorrect. This could cause flickering in the demo animation as it
calculated the rotation angles wrong when this singularity was
encountered. Implement the correct formulas solved from the equation
group:

row1[0] = sin(a)sin(b)cos(c) + cos(a)sin(c)
row1[1] = -sin(a)sin(b)sin(c) + cos(a)cos(c)
row2[0] = -cos(a)sin(b)cos(c) + sin(a)sin(c)
row2[1] = cos(a)sin(b)sin(c) + sin(a)cos(c)

where a = rotate[0], b = rotate[1], and c = rotate[2].

The bug reproduces in Chrome. It does not reproduce in Firefox due to
slightly different approximations for trigonometric functions, which
helps it avoid the singularity. These differences in approximations are
allowed by the ECMAScript spec.
Fix to adhere to the row/column confusion in J3DIMath

In J3DIMatrix, $matrix.mxy is actually the matrix value in the xth column
and yth row. WebKitCSSMatrix, which J3DIMatrix is based on, has incorrect
documentation about this. J3DIMatrix documentation in about row/column
majorness might be wrong as well, but this patch only attempts to fix the
matrix decomposition.
Fix remaining incorrect math in rotation decomposition

The cos(rotate[1]) != 0 code path in rotation decomposition used to work
only for a special case of the rotation. Fix it so that it should work
with arbitrary rotation.

The fix is demonstrated in MatrixTest.html. The first cube and the cube
with the decomposed rotation should rotate roughly the same way.
Add explanation of how the rotation decomposition is derived

Also fix an issue: rotate[2] can in fact be chosen arbitrarily when
cos(rotate[1]) == 0, so set it at 0 in that case. Still keep the more
robust formulas for rotate[0].
Merge pull request #487 from NVIDIA/matrix-singularity-fix

Fix rotation matrix decomposition in J3DIMath