# While converting rotation matrix to angle-axis representation how to find axis of rotation when angle of rotation is Pi?

I have to convert a $3 \times 3$ rotation matrix into angle-axis representation.

Angle($\theta$) can be calculated using $tr (\mathbf{R}) = 1+2\cos{\theta}$ and vector $v$ corrresponding to the axis of rotation can be calculated using :

$v= {\dfrac {1}{2\sin(\theta)}}\begin{bmatrix} r_{32}-r_{23} \\ r_{13}-r_{31} \\ r_{21} -r_{12} \end{bmatrix}$ where $r_{ij}$ are appropriate entries of $R$ matrix.

The above representation for $v$ works fine when $0$ $<$ $\theta$ < $\pi$, but what method has to be applied when $\theta$ comes out to be $\pi$/-$\pi$

• Welcome to MSE. Please read this text about how to ask a good question. – José Carlos Santos May 19 '18 at 14:57
• I hope the edited version of the question is more clear :) – MSD May 19 '18 at 15:26
• Yes. It is much better now. – José Carlos Santos May 19 '18 at 15:36
• link The above link has a representation for rotation matrix which can be used for finding the angle-axis form when theta = pi , but I can't find a way to use it – MSD May 22 '18 at 4:03
• @MSD I'm curious, something unclear MSD in my answer? – Widawensen May 30 '18 at 9:45

Use Rodrigues formula for a rotation matrix $R$

$$R=I+\sin(\theta)S(v)+(1-\cos(\theta))S^2(v)$$

where $S(v)$ is a skew-symmetric matrix corresponding to the vector $v$

$$S(v)=\begin{bmatrix} 0 & -v_z & v_y \\ v_z & 0 & -v_x \\ -v_y & v_x & 0 \end{bmatrix}$$

You can check that relation $$S^2(v)=vv^T-I$$ holds ( $v$ has to be unit vector here)
and for $$\theta=\pi$$
we have very useful relation
$$R=I+2(vv^T-I)$$ and consequently $$vv^T=\dfrac{1}{2}(R+I)$$

The matrix $$vv^T=\begin{bmatrix} v_x^2 & v_y v_x& v_zv_x \\ v_xv_y & v_y^2& v_z v_y\\ v_x v_z & v_y v_z & v_z^2 \end{bmatrix}$$ allows to calculate $$v = [ v_x \ \ v_y \ \ v_z]^T$$ directly from obtained entries of the matrix (two solutions $R(v,\pi)=R(-v,\pi))$.