0

Given the 'xyz' rotation matrix ($\theta$ - roll, $\phi$ - pitch, $\psi$ - yaw):

$$R = \begin{bmatrix} c_\phi c_\psi & -c_\phi s_\psi & s_\phi \\ c_\theta s_\psi + c_\psi s_\phi s_\theta & c_\psi c_\theta - s_\phi s_\psi s_\theta & -c_\phi s_\theta \\ s_\psi s_\theta - c_\psi c_\theta s_\phi & c_\psi s_\theta + c_\theta s_\phi s_\psi & c_\phi c_\theta \end{bmatrix}$$

where $c_x = \cos x$ and $s_x = \sin x$, we can say that the singularity has occured if $|R(1,3)|-1=0$. In my textbook, the angles are calculated as follows: $$\theta = 0,$$ $$\phi=\arcsin{R(1,3)}$$ and there are two cases for $\psi$:

  1. If $R(1,3)=\sin\phi=-1$, $\phi=-\pi/2$: $$\psi=-\arctan2(R(2,1), R(3,1))$$
  2. If $R(1,3)=\sin\phi=1$, $\phi=\pi/2$: $$\psi=\arctan2(R(3,2), R(2,2))$$

What confuses me is the first case. Why is there a minus sign before $\arctan2$?

A6EE
  • 313

1 Answers1

0

Your textbook appears to have a typo. That minus sign should not be there.

Firstly, we should check the expression for $R$ you have is correct. It is, assuming our conventions are equivalent to implementing rotations in the following order: $$ R = \begin{pmatrix} 1 & 0 & 0 \\ 0 & c_{\theta } & -s_{\theta} \\ 0 & s_{\theta } & c_{\theta} \end{pmatrix} \cdot \begin{pmatrix} c_{\phi } & 0 & s_{\phi } \\ 0 & 1 & 0 \\ -s_{\phi } & 0 & c_{\phi } \\ \end{pmatrix} \cdot \begin{pmatrix} c_{\psi } & -s_{\psi } & 0 \\ s_{\psi } & c_{\psi } & 0 \\ 0 & 0 & 1 \\ \end{pmatrix} $$ Now clearly, in the special case that $\phi = -\pi/2$ and $\theta = 0$, we obtain $$ R = \begin{pmatrix} 0 & 0 & -1 \\ s_\psi & c_\psi & 0 \\ c_\psi & -s_\psi & 0 \end{pmatrix} $$ Clearly, the correct choice of $\psi$ has sine given by $R_{2,1}$ and cosine given by $R_{3,1}$. Thus $$\psi = \operatorname{atan2}(\sin \psi, \cos \psi) = \operatorname{atan2}(R_{2,1},R_{3,1})$$

not all wrong
  • 16,178
  • 2
  • 35
  • 57
  • Is it a convention to read from right to left? If so, is there a logical explanation for that? – A6EE Mar 28 '21 at 21:26
  • @A6EE It's the nature of how we write matrix multiplication. When you apply a product of matrices to a vector, the matrix on the right acts on it first. – not all wrong Mar 28 '21 at 22:15
  • @A6EE I should emphasize that the inverse $R^{-1} = R^T = R_{\psi}^{T} R_{\phi}^{T} R_{\theta}^{T}=R_{-\psi} R_{-\phi} R_{-\theta}$ has the matrices reversed in order. As such, you get opposite orders when you ask how to apply operations to untransformed coordinates to get their transformed state, or when you ask what operations you need to apply to transformed coordinate to get their untransformed state. You should really be clear which one you mean if discussing what order you are applying the transformations. – not all wrong Mar 28 '21 at 22:24
  • @A6EE I should also further clarify one more subtlety: the order I gave in quote marks is probably misleading in this particular context, because probably you mean yaw/pitch/roll with respect to the body axes. What I was saying is really that "we implement rotations first about the world z axis, then the y axis, then the x axis". See e.g. https://math.stackexchange.com/questions/3242495/yaw-pitch-and-roll-composition?rq=1 for a discussion of this. I've edited the answer to remove reference to this. – not all wrong Mar 28 '21 at 22:34