[Math] How to find the difference between two euler angles in 3D

3danglerotations

More specifically, given angles $a$ and $b$, what is the shortest rotation $c$ such that when applied to $a$, the angle $b$ is the result? Can this solution be found in all cases, and if so, is there a specific algorithm for it? I can't seem to find any resources online that make the answer obvious, if even give one.

Best Answer

We have two rotations, $\mathbf p$ and $\mathbf q$, and we want to find the rotation $\mathbf r$ such that applying $\mathbf p$ and then $\mathbf r$ is equivalent to applying $\mathbf q$.

In quaternions or full-strength rotation matrices, this is easy: $\mathbf q = \mathbf {rp}$, so $\mathbf r = \mathbf q\mathbf p^{-1}$.

Converting between quaternions and Euler angles is another problem, and of course depends on what form of Euler angles you're using. Wikipedia's got a page literally named Conversion between quaternions and Euler angles that looks pretty promising.