$SO(3)$, $SE(3)$, and quaternion logarithm and exponential are mathematical operations that can facilitate the computation and representation of rigid body motion. Post Rigid Body Motion, Concepts and Terminologies discussed matrix exponential in $SO(3)$ and $SE(3)$. In addition to that,
This post summarizes formulas for computing $SO(3)$ and $SE(3)$ matrix logarithm, and unit quaternion logarithm and pure quaternion logarithm. For further details, please refer to 2017@Lynch , 1998@Dam , Wikipedia@Quat , and Wikipedia@QuatAndRot .
As discussed in Orientation section of post Rigid Body Motion, Concepts and Terminologies, $[\hat{\omega}]\theta \in so(3) \rightleftharpoons e^{[\hat{\omega}] \theta} \in SO(3)$ are the matrix logarithm and exponential of each other. And the section provided the formula to compute $e^{[\hat{\omega}]\theta} \in SO(3)$ from $[\hat{\omega}]\theta$.
Another common application is to get $(\hat{\omega}, \theta)$ for a given $R\in SO(3)$, where $||\hat{\omega}||=1$ and $\theta \in [0, \pi]$. That is, given a rotation matrix, one wants to find a unit axis and an angle such that rotating about the unit axis by the angle will result in the given rotation matrix.
With that said, given $R\in SO(3)$, to get $(\hat{\omega}, \theta)$, there are 3 cases to consider.
$$ \hat{\omega} \rightarrow \text{undefined} \rightarrow \text{any unit vector} $$ $$ \theta = 0 $$
$$ \begin{align} \hat{\omega} &= \frac{R - R^T}{2 \, \text{sin}\theta} \\ \theta &= \text{arccos} \frac{\text{tr}R - 1}{2} \end{align} $$
$$ \hat{\omega} = \begin{cases} \pm \frac{1}{\sqrt{2(1+r_{33})}} \begin{bmatrix} r_{13}, & r_{23}, & 1 + r_{33} \end{bmatrix}^T \\ \pm \frac{1}{\sqrt{2(1+r_{22})}} \begin{bmatrix} r_{12}, & 1 + r_{22}, & r_{32} \end{bmatrix}^T \\ \pm \frac{1}{\sqrt{2(1+r_{11})}} \begin{bmatrix} 1 + r_{11}, & r_{21}, & r_{31} \end{bmatrix}^T \end{cases} \label{eq:180-axis} $$ $$ \theta = \pi $$
Note that in the 180° rotation case:
It is then straightforward to compute $SO(3)$ matrix logarithm by $$R \rightarrow (\hat{\omega}, \theta) \rightarrow [\hat{\omega}]\theta = \log(R)$$
In short conclusion, the $SO(3)$ matrix logarithm and $so(3)$ matrix exponential are $$ \log(R) = [\hat{\omega}]\theta $$ $$ e^{[\hat{\omega}]\theta} = R $$
Analogous to the application of $SO(3)$ matrix logarithm, another common application is to get $(\mathcal{S}, \theta)$, or equivalently $(\bar{\omega}, \bar{v}, \theta)$, for a given $T(R,p) \in SE(3)$, where there must be either $||\bar{\omega}|| = 1$ or $||\bar{v}|| = 1$, and $\theta \in [0, \pi]$.
For that, there are two cases to consider.
$$ \bar{\omega} = \mathbf{0} $$ $$ \bar{v} = \frac{p}{||p||} $$ $$ \theta = ||p|| $$
$$ \bar{\omega} \leftarrow \text{log}(R) $$ $$ \theta \leftarrow \text{log}(R) $$ $$ \bar{v} = G^{-1}(\bar{\omega}, \theta) \, p $$ where $$\theta \in (0,\pi] \nonumber $$ $$ G^{-1}(\bar{\omega}, \theta) = \frac{1}{\theta} - \frac{1}{2}[\bar{\omega}] + \Big( \frac{1}{\theta} - \frac{1}{2}\text{cot}\frac{\theta}{2} \Big) [\hat{\omega}]^2 $$ and $\text{log}(R)$ follows Section SO(3) Matrix Logarithm, $\text{log}(R)$.
Similarly, it is then straightforward to compute $SE(3)$ matrix logarithm by $$ T \rightarrow (\bar{\omega}, \bar{v}, \theta) \rightarrow [\mathcal{S}]\theta = \begin{bmatrix} \, [\bar{\omega}] & \bar{v} \, \\ \mathbf{0} & 0 \end{bmatrix} \theta = \text{log}(T) $$
In short conclusion, the $SE(3)$ matrix logarithm and $se(3)$ matrix exponential are $$ \log(T) = [\mathcal{S}]\theta $$ $$ e^{[\mathcal{S}]\theta} = T $$
A unit quaternion is defined to represent a spatial rotation, and is common denoted as $$ q = \begin{bmatrix} \text{cos}\frac{\theta}{2} & \hat{\omega} \, \text{sin}\frac{\theta}{2} \end{bmatrix} $$ or $$ q = e^{\frac{\theta}{2}(\mathbf{i}\,\hat{\omega}_x + \mathbf{j}\,\hat{\omega}_y + \mathbf{k}\,\hat{\omega}_z)} $$ where $||q|| = 1$ and $\theta \in [0, 2\pi]$. Note that rotations come in pairs, i.e., given a rotation, it can also be obtained by rotating in the opposite direction about the opposite axis. As a result, $q$ and $-q$ correspond to the same rotation.
A general quaternion (unit, pure, or generic) is also commonly denoted as follows. $$ q = \begin{bmatrix} q_0 & q_1 & q_2 & q_3 \end{bmatrix} = \begin{bmatrix} q_w & q_x & q_y & q_z \end{bmatrix} $$ or $$ q = w + x\mathbf{i} + y\mathbf{j} + z\mathbf{k} $$
By the definition of unit quaternions, it is not difficult to extract the rotation angle and axis from a them. However, to include all possibilities, one should consider the following cases for $\theta \in [0, 2\pi]$.
$$\hat{\omega} \rightarrow \text{undefined} \rightarrow \text{any unit vector} \label{eq:q0-1-case-axis}$$ $$\theta = 0 \label{eq:q0-1-case-angle}$$
$$\hat{\omega} \rightarrow \text{undefined} \rightarrow \text{any unit vector}$$ $$\theta = 2\pi$$
$$ \hat{\omega} = \frac{\begin{bmatrix} q_1 & q_2 & q_3 \end{bmatrix}}{|| \begin{bmatrix} q_1 & q_2 & q_3 \end{bmatrix} ||} = \frac{\begin{bmatrix} q_1 & q_2 & q_3 \end{bmatrix}}{\sqrt{1 - q_0^2}} \label{eq:quat-axis} $$ $$\theta = 2\, \text{arccos}(q_0) \label{eq:quat-angle}$$
As mentioned earlier, since $q$ and $-q$ represent the same rotation by nature, \eqref{eq:q0-1-case-axis} and \eqref{eq:q0-1-case-angle} can be used to represent the rotation axis and angel for both the $q_0 = 1$ and $q_0 = -1$ cases.
Given a unit quaternion $ q = \begin{bmatrix} \text{cos}\frac{\theta}{2} & \hat{\omega} \, \text{sin}\frac{\theta}{2} \end{bmatrix} \in \mathbb{H}_1 $, its logarithm is defined as $$ \text{log}(q) \triangleq \begin{bmatrix} 0 & \frac{\theta}{2} \hat{\omega} \end{bmatrix} \in \mathbb{H} $$
For the special case $ q = \begin{bmatrix} 1 & \mathbf{0} \end{bmatrix} \in \mathbb{H}_1$, its logarithm is defined as $$ \text{log}(\begin{bmatrix} 1 & \mathbf{0} \end{bmatrix}) \triangleq \begin{bmatrix} 0 &\mathbf{0} \end{bmatrix} \in \mathbb{H} $$
Logarithm and exponential are inverse of each other. Given the definition of unit quaternion logarithm, the definition of pure quaternion exponential follows naturally.
Given a pure quaternion $\mathcal{Q} = \begin{bmatrix} 0 & \frac{\theta}{2} \hat{\omega} \end{bmatrix} \in \mathbb{H}$, its exponential is defined as $$ \text{exp}(\mathcal{Q}) \triangleq \begin{bmatrix} \text{cos}\frac{\theta}{2} & \hat{\omega} \, \text{sin}\frac{\theta}{2} \end{bmatrix} \in \mathbb{H}_1 $$
For the special case $\mathcal{Q}=\begin{bmatrix} 0 & \mathbf{0} \end{bmatrix} \in \mathbb{H}$, its exponential is defined as $$ \text{exp}(\begin{bmatrix} 0 & \mathbf{0} \end{bmatrix}) \triangleq \begin{bmatrix} 1 & \mathbf{0} \end{bmatrix} \in \mathbb{H}_1 $$
When evaluating matrix logarithms in $SO(3)$ and $SE(3)$, special cases arise when $R = I$ or $\text{tr}R = -1$. In practice, it is numerically more robust to evaluate $$ ||R - I|| < \epsilon $$$$||\text{tr}R + 1|| < \epsilon $$
The same goes for quaternion logarithm and exponential. To check for special cases $q = \begin{bmatrix} 1 & \mathbf{0} \end{bmatrix}$ and $\mathcal{Q} = \begin{bmatrix} 0 & \mathbf{0} \end{bmatrix}$, it is numerically more robust to evaluate $$ ||q_w - 1|| < \epsilon $$$$ \Big|\Big| \begin{bmatrix} q_x & q_y & q_z \end{bmatrix}\, \Big|\Big| < \epsilon $$
As well for extracting the rotation axis and angle from unit quaternions. To check for special cases $q_0 = 1$ or $q_0 = -1$ with better numerical stability, one should use $$\Big|\Big| |q_0| - 1 \Big|\Big| < \epsilon $$where $\epsilon \in R^+$ is a small number that represents a numerical threshold.
In addition, one should be aware of the "half-angle" correspondence between $SO(3)$ and $\mathbb{H}_1$ for encoding the angle and axis of a rotation, that is $$ (\hat{\omega}, \theta) \rightarrow R = Rot(\hat{\omega}, \theta) \in SO(3) $$ versus $$ (\hat{\omega}, \frac{\theta}{2}) \rightarrow q = \begin{bmatrix} \text{cos}\frac{\theta}{2} & \hat{\omega} \, \text{sin}\frac{\theta}{2} \end{bmatrix} \in \mathbb{H}_1 $$
Applications of unit quaternion logarithm and pure quaternion exponential can be found in 2020@Huber , further details will be discussed in a separate post.
A convenient 3D rotation converter between different representations can be found at Gaschler@2016 . A great visual illustration of unit quaternions can be found at Sanderson@Quat .