# strange matrix -> quaternion conversion problem

I find two different rotation matrices are mapped to a single quaternion.

$$\begin{pmatrix} -1 & 0 & 0 \\ 0 & \frac{\sqrt{2}}{2} & -\frac{\sqrt{2}}{2} \\ 0 & -\frac{\sqrt{2}}{2} & -\frac{\sqrt{2}}{2} \end{pmatrix}$$

$$\begin{pmatrix} -1 & 0 & 0 \\ 0 & \frac{\sqrt{2}}{2} & \frac{\sqrt{2}}{2} \\ 0 & \frac{\sqrt{2}}{2} & -\frac{\sqrt{2}}{2} \end{pmatrix}$$

They are both mapped to a quaternion:

$w: 0$

$x: 0$

$y: 0.9238795325112867$

$z: 0.38268343236508984$

Is it a problem relate to my matrix-quaternion conversion program?

-

Yes, it's a problem. Both matrices describe rotations through $\pi$ and thus correspond to a quaternion with $w=0$ and $(x,y,z)$ a unit vector along the axis of rotation. The quaternion you give corresponds to the axis of rotation of the second rotation matrix, whereas the first one has the sign of the $y$ component flipped.