I suspect this is a bit basic for mathoverflow, seeing I'm still just an undergraduate
I've been playing around with quaternions as means to eliminate the gimbal lock. From what I understand, one place the gimbal lock occurs is when you rotate $\frac{\pi}{2}$ around the y-axis. If I create two rotation matrices, $R_{1}$ rotates first $\phi$ around x-axis and $\frac{\pi}{2}$ around the y-axis, while $R_{2}$ rotates first $\frac{\pi}{2}$ around the y-axis and then $\theta$ around the z-axis.
$\begin{equation} R_{1} = R_{z}(0) R_{y}(\frac{\pi}{2}) R_{x}(\phi) \\ = \begin{bmatrix} 0 & 0 & 1 \\ 0 & 1 & 0 \\ -1 & 0 & 0 \end{bmatrix} \begin{bmatrix} 1 & 0 & 0 \\ 0 & \cos(\phi) & -\sin(\phi) \\ 0 & \sin(\phi) & \cos(\phi) \end{bmatrix} \\ = \begin{bmatrix} 0 & \sin(\phi) & \cos(\phi) \\ 0 & \cos(\phi) & -\sin(\phi) \\ -1 & 0 & 0 \end{bmatrix}, \end{equation}$
$\begin{equation} R_{2} = R_{z}(\theta) R_{y}(\frac{\pi}{2}) R_{x}(0) \\ = \begin{bmatrix} \cos(\theta) & -\sin(\theta) & 0 \\ \sin(\theta) & \cos(\theta) & 0 \\ 0 & 0 & 1 \\ \end{bmatrix} \begin{bmatrix} 0 & 0 & 1 \\ 0 & 1 & 0 \\ -1 & 0 & 0 \end{bmatrix} \\ = \begin{bmatrix} 0 & -\sin(\theta) & \cos(\theta) \\ 0 & \cos(\theta) & \sin(\theta) \\ -1 & 0 & 0 \end{bmatrix}. \end{equation} $
Since $R_{1} = R_{2}^{-1} \Rightarrow R_{1}(\theta) = R_{2}(-\theta)$, we've lost a degree of freedom. Which is what I expect.
From what I understand, if I perform the same rotations using quaternions, I should be avoiding the gimbal lock?
$ Q_{1} = Q_{z}(0) \times Q_{y}(\frac{\pi}{2}) \times Q_{x}(\theta) = (1, 0, 0, 0) \times (\frac{1}{\sqrt(2)}, 0, \frac{1}{\sqrt(2)}, 0) \times (\cos\frac{\theta}{2}, \sin\frac{\theta}{2}, 0, 0)\\ = \frac{1}{\sqrt(2)}(\cos\frac{\theta}{2}, \sin\frac{\theta}{2}, \cos\frac{\theta}{2}, -\sin\frac{\theta}{2})$
$ Q_{2} = Q_{z}(\phi) \times Q_{y}(\frac{\pi}{2}) \times Q_{x}(0) = (\cos\frac{\phi}{2}, 0, 0, \sin\frac{\phi}{2}) \times (\frac{1}{\sqrt(2)}, 0, \frac{1}{\sqrt(2)}, 0) \times (1, 0, 0, 0) \\ = \frac{1}{\sqrt(2)}(\cos\frac{\phi}{2}, -\sin\frac{\phi}{2}, \cos\frac{\phi}{2}, \sin\frac{\phi}{2})$
By setting $\phi = -\theta$, $Q_{2}$ becomes
$ Q_{2} = \frac{1}{\sqrt(2)}(\cos\frac{-\theta}{2}, -\sin\frac{-\theta}{2}, \cos\frac{-\theta}{2}, \sin\frac{-\theta}{2})$ which due to trig properies becomes $ Q_{2} = \frac{1}{\sqrt(2)}(\cos\frac{\theta}{2}, \sin\frac{\theta}{2}, \cos\frac{\theta}{2}, -\sin\frac{\theta}{2})$
Which means that $Q_{1}$ and $Q_{2}$ rotates around the same axis only in the oppsite direction, and we've lost a degree of freedom (??). Am I missing something fundamental?