본문 바로가기

Fundamental

Quaternion kinematics for the error-state Kalman filter 내용 정리 Part 1

본 포스트는 Joan Solà의 "Quaternion kinematics for the error-state Kalam filter (2017)" 페이퍼를 정리한 포스트이다. 이는 Quaternion과 SO(3) 군, Error-state Kalman filter 모델링에 대해 자세히 나와있어서 SLAM을 공부할 때 이론적인 부분을 참고하면 좋은 페이퍼이다.

1 Quaternion Definition and properties

1.1 Definition of quaternion

두 개의 복소수 $A = a+bi, C=c+di$가 주어졌을 때 이를 $Q=A+Cj$와 같이 구성하고 $k \triangleq ij$로 정의하면 $Q$는 쿼터니언 공간 $\mathbb{H}$ 안에 존재하는 수가 된다.
\begin{equation}
\begin{aligned}
Q = a+bi+cj+dk \in \mathbb{H}
\end{aligned}
\label{eq:1}
\end{equation}

이 때, $a,b,c,d \in \mathbb{R}$이고 $\{i,j,k\}$는 다음과 같이 정의된 3개의 허수를 의미한다.
\begin{equation}
\begin{aligned}
i^{2} = j^{2} = k^{2} = ijk = -1
\end{aligned} \label{eq:2}
\end{equation}

이는 다음과 같은 성질을 만족한다.
\begin{equation}
\begin{aligned}
ij = -ji = k, \quad jk = -kj = i, \quad ki = -ik = j
\end{aligned}
\end{equation}

임의의 쿼터니언 $Q$는 복소수가 0일 때도 쿼터니언을 만족해야하므로 다음과 같은 수 또한 모두 쿼터니언이다.
\begin{equation}
\begin{aligned}
Q = a \in \mathbb{R} \subset \mathbb{H}, \quad Q = bi \in \mathbb{I} \subset \mathbb{H}, \quad Q = a + bi \in \mathbb{Z} \subset \mathbb{H}
\end{aligned}
\end{equation}

또한 실수가 0일 때도 쿼터니언을 만족해야 하는데 이때는 특별히 복소수 $\{i,j,k\}$만으로 구성된 순수 쿼터니언(pure quaternion)이라고 한다. 이는 순수 쿼터니언 공간 $\mathbb{H}_{p} = \text{Im}(\mathbb{H})$에 존재한다고 정의한다.
\begin{equation}
\begin{aligned}
Q = bi+cj+dk \in \mathbb{H}_{p} \subset \mathbb{H}.
\end{aligned}
\end{equation}

쿼터니언을 표기하는데는 다양한 방법들이 존재한다. 본 페이지에서 설명하는 쿼터니언은 $ijk=-1$ 조건인 오른손법칙을 만족하는 쿼터니언이다. 이는 $Q=(w,x,y,z)$와 같이 실수부 $w$가 앞에있고 허수부 $x,y,z$가 뒤에 있는 순서로 표기한다. 이러한 성질들을 만족하는 쿼터니언을 특별히 Hamilton Quaternion이라고 한다.


1.1.1 Alternative representations of the quaternion

쿼터니언은 앞서 설명한 실수부+허수부로 표기할 수 있을 뿐만 아니라 스칼라+벡터로도 표기할 수 있다.
\begin{equation}
\begin{aligned}
Q = q_{w} + q_{x}i + q_{y}j + q_{z}k \quad \Leftrightarrow \quad Q = q_{w} + \mathbf{q}_{v},
\end{aligned}
\end{equation}

여기서 $q_{w}$는 실수부 또는 스칼라 파트이며, $\mathbf{q}_{v} = q_{x}i +q_{y}j + q_{z}k$는 허수부 또는 벡터 파트이다. 이는 다음과 같이 표기되기도 한다.
\begin{equation}
\begin{aligned}
Q = <q_{w} , \mathbf{q}_{v}>
\end{aligned}
\end{equation}

가장 자주 사용되는 표기법은 다음과 같이 벡터로 표기하는 법이다.
\begin{equation}
\begin{aligned}
q \triangleq \begin{bmatrix}
q_{w} \\ \mathbf{q}_{v}
\end{bmatrix} = \begin{bmatrix}
q_{w} \\ q_{x} \\ q_{y} \\ q_{z}
\end{bmatrix}
\end{aligned}
\end{equation}

이와 같은 표기법은 쿼터니언과 관련된 대수 연산을 사용할 수 있도록 해준다.

1.2 Main quaternion properties

1.2.1 Sum

두 쿼터니언의 덧셈은 다음과 같이 정의한다.
\begin{equation}
\begin{aligned}
\mathbf{p} + \mathbf{q} = \begin{bmatrix}
p_{w} \\ \mathbf{p}_{v}
\end{bmatrix} \pm \begin{bmatrix}
q_{w} \\ \mathbf{q}_{v}
\end{bmatrix} = \begin{bmatrix}
p_{w} \pm q_{w} \\ \mathbf{p}_{v} \pm \mathbf{q}_{w}
\end{bmatrix}
\end{aligned}
\end{equation}

쿼터니언의 덧셈 연산은 교환법칙과 결합법칙을 만족한다
\begin{equation}
\begin{aligned}
\mathbf{p} + \mathbf{q} = \mathbf{q} + \mathbf{p}
\end{aligned}
\end{equation}
\begin{equation}
\begin{aligned}
\mathbf{p} + (\mathbf{q}+\mathbf{r}) = (\mathbf{p} + \mathbf{q}) + \mathbf{r}
\end{aligned}
\end{equation}

1.2.2 Product

Hamilton Quaternion의 곱은 $\otimes$과 같이 표기하며, 앞서 설명한 (\ref{eq:1})과 (\ref{eq:2})의 법칙을 따른다.
\begin{equation}
\begin{aligned}
\mathbf{p} \otimes \mathbf{q} =
\begin{bmatrix}
p_{w}q_{w} - p_{x}q_{x} - p_{y}q_{y} - p_{z}p_{z} \\
p_{w}q_{x} + p_{x}q_{w} + p_{y}q_{z} - p_{z}p_{y} \\
p_{w}q_{y} - p_{x}q_{z} + p_{y}q_{w} + p_{z}p_{x} \\
p_{w}q_{z} + p_{x}q_{y} - p_{y}q_{x} + p_{z}p_{w}
\end{bmatrix}\\
\end{aligned} \label{eq:3}
\end{equation}

이를 스칼라와 벡터 표기로 다시 나타내면 다음과 같다.
\begin{equation}
\begin{aligned}
\mathbf{p} \otimes \mathbf{q} =
\begin{bmatrix}
p_{w}q_{w} - \mathbf{p}^{\intercal}_{v}\mathbf{q}_{v} \\
p_{w}\mathbf{q}_{v} + q_{w}\mathbf{p}_{v} + \mathbf{p}_{v} \times \mathbf{q}_{v}
\end{bmatrix}\\
\end{aligned} \label{eq:4}
\end{equation}

위 연산에는 cross product가 포함되어 있으므로 쿼터니언의 곱셈은 교환법칙이 성립하지 않는다.
\begin{equation}
\begin{aligned}
\mathbf{p} \otimes \mathbf{q} \neq \mathbf{q} \otimes \mathbf{p}
\end{aligned}
\end{equation}

하지만 만약 $\mathbf{p}_{v} \times \mathbf{q}_{v} = 0$이 성립하는 경우 교환법칙이 성립한다. 또한, 쿼터니언의 곱셈은 결합법칙이 성립한다.
\begin{equation}
\begin{aligned}
(\mathbf{p} \otimes \mathbf{q}) \otimes \mathbf{r} = \mathbf{p} \otimes (\mathbf{q} \otimes \mathbf{r})
\end{aligned}
\end{equation}

그리고 덧셈에 대한 분배법칙이 성립한다.
\begin{equation}
\begin{aligned}
\mathbf{p} \otimes (\mathbf{q} + \mathbf{r}) = \mathbf{p} \otimes \mathbf{q} + \mathbf{p} \otimes \mathbf{r}
\end{aligned}
\end{equation}
\begin{equation}
\begin{aligned}
(\mathbf{p} + \mathbf{q}) \otimes \mathbf{r} = \mathbf{p} \otimes \mathbf{r} + \mathbf{q} \otimes \mathbf{r}
\end{aligned}
\end{equation}

두 쿼터니언의 곱은 다음과 같이 행렬곱으로도 나타낼 수 있다.
\begin{equation}
\begin{aligned}
\mathbf{q}_{1} \otimes \mathbf{q}_{2} = [\mathbf{q}_{1}]_{L}\mathbf{q}_{2} \quad \text{and} \quad \mathbf{q}_{1} \otimes \mathbf{q}_{2} = [\mathbf{q}_{2}]_{R}\mathbf{q}_{1}
\end{aligned}
\end{equation}

이 때, $[\mathbf{q}_{1}]_{L}, [\mathbf{q}_{2}]_{R}$은 각각 왼쪽, 오른쪽 쿼터니언 곱셈에 대한 행렬을 의미하며 (\ref{eq:3})에 의해 다음과 같이 나타될 수 있다.
\begin{equation}
\begin{aligned}
[\mathbf{q}_{1}]_{L} = \begin{bmatrix}
q_{w} & -q_{x} & -q_{y} & -q_{z} \\
q_{x} & q_{w} & -q_{z} & q_{y} \\
q_{y} & q_{z} & q_{w} & -q_{x} \\
q_{z} & -q_{y} & q_{x} & q_{w}
\end{bmatrix} \quad
[\mathbf{q}_{2}]_{R} = \begin{bmatrix}
q_{w} & -q_{x} & -q_{y} & -q_{z} \\
q_{x} & q_{w} & q_{z} & -q_{y} \\
q_{y} & -q_{z} & q_{w} & q_{x} \\
q_{z} & q_{y} & -q_{x} & q_{w}
\end{bmatrix}
\end{aligned}
\end{equation}

또한, (\ref{eq:4})로부터 다음과 같이 나타낼 수 있다.
\begin{equation}
\begin{aligned}
[\mathbf{q}_{1}]_{L} = q_{w}\mathbf{I} + \begin{bmatrix}
0 & -\mathbf{q}_{v}^{\intercal} \\
\mathbf{q}_{v} & [\mathbf{q}_{v}]_{\times}
\end{bmatrix} \quad
[\mathbf{q}_{2}]_{R} = q_{w}\mathbf{I} + \begin{bmatrix}
0 & -\mathbf{q}_{v}^{\intercal} \\
\mathbf{q}_{v} & -[\mathbf{q}_{v}]_{\times}
\end{bmatrix}
\end{aligned}
\end{equation}

여기서 $[\cdot]_{\times}$ 연산자는 3차원 벡터로부터 반대칭행렬(skew symmetric matrix)를 생성하는 연산자이다.
\begin{equation}
\begin{aligned}
[\mathbf{a}]_{\times} \triangleq \begin{bmatrix}
0 & -a_{z} & a_{y} \\
a_{z} & 0 & -a_{x} \\
-a_{y} & a_{x} & 0
\end{bmatrix}
\end{aligned}
\end{equation}

또한 반대칭행은 $[\mathbf{a}]^{\intercal}_{\times} = -[\mathbf{a}]_{\times}$를 만족한다. 반대칭행렬은 벡터에 곱해지면 cross product를 하는 것과 동일한 연산을 수행한다.
\begin{equation}
\begin{aligned}
[\mathbf{a}]_{\times} \mathbf{b} = \mathbf{a} \times \mathbf{b}, \quad \forall \mathbf{a,b} \in \mathbb{R}^{3}
\end{aligned}
\end{equation}

따라서 임의의 3개의 쿼터니언 $\mathbf{q}, \mathbf{x}, \mathbf{p}$이 존재할 때 곱셈은 다음과 같이 나타낼 수 있다.
\begin{equation}
\begin{aligned}
\mathbf{q} \otimes \mathbf{x} \otimes \mathbf{p} & = (\mathbf{q} \otimes \mathbf{x}) \otimes \mathbf{p} = [\mathbf{p}]_{R}[\mathbf{q}]_{L} \mathbf{x} \\
& = \mathbf{q} \otimes (\mathbf{x} \otimes \mathbf{p}) = [\mathbf{q}]_{L}[\mathbf{p}]_{R}\mathbf{x}
\end{aligned}
\end{equation}

이는 곧 아래 공식이 성립하는 것을 의미한다.
\begin{equation}
\begin{aligned}
[\mathbf{p}]_{R}[\mathbf{q}]_{L} = [\mathbf{q}]_{L}[\mathbf{p}]_{R}
\end{aligned}
\end{equation}

1.2.3 Identity

항등 쿼터니언(identity quaternion) $\mathbf{q}_{1}$은 다음과 같은 공식 $\mathbf{q}_{1}\otimes\mathbf{q} = \mathbf{q}\otimes\mathbf{q}_{1} = \mathbf{q}$를 만족하며 다음과 같이 정의된다.
\begin{equation}
\begin{aligned}
\mathbf{q}_{1} = 1 = \begin{bmatrix}
1 \\ \mathbf{0}_{v}
\end{bmatrix}
\end{aligned}
\end{equation}

1.2.4 Conjugate

쿼터니언의 켤레복소수는 다음과 같이 정의된다.
\begin{equation}
\begin{aligned}
\mathbf{q}^{*} \triangleq q_{w} - \mathbf{q}_{v} = \begin{bmatrix}
q_{w} \\ -\mathbf{q}_{v}
\end{bmatrix}
\end{aligned}
\end{equation}

이는 다음과 같은 성질을 갖는다.
\begin{equation}
\begin{aligned}
\mathbf{q} \otimes \mathbf{q}^{*} = \mathbf{q}^{*} \otimes \mathbf{q} = q_{w}^{2} + q_{x}^{2}+q_{y}^{2} +q_{z}^{2} = \begin{bmatrix}
q_{w}^{2} + q_{x}^{2}+q_{y}^{2} +q_{z}^{2} \\ \mathbf{0}_{v}
\end{bmatrix}
\end{aligned}
\end{equation}
\begin{equation}
\begin{aligned}
(\mathbf{p} \otimes \mathbf{q})^{*} = \mathbf{q}^{*} \otimes \mathbf{p}^{*}
\end{aligned}
\end{equation}

1.2.5 Norm

쿼터니언의 놈은 다음과 같이 정의된다.
\begin{equation}
\begin{aligned}
\left \| \mathbf{q} \right \| \triangleq \sqrt{\mathbf{q} \otimes \mathbf{q}^{*}} = \sqrt{\mathbf{q}^{*} \otimes \mathbf{q}} = \sqrt{q_{w}^{2} + q_{x}^{2}+q_{y}^{2} +q_{z}^{2}} \in \mathbb{R}
\end{aligned}
\end{equation}

이는 다음과 같은 성질을 갖는다.
\begin{equation}
\begin{aligned}
\left \| \mathbf{p} \otimes \mathbf{q} \right \| = \left \| \mathbf{q} \otimes \mathbf{p} \right \| = \left \| \mathbf{p} \right \| \left \| \mathbf{q} \right \|
\end{aligned} \label{eq:19}
\end{equation}

1.2.6 Inverse

쿼터니언의 역은 $\mathbf{q}^{-1}$과 같이 표기하며 다음과 같은 특성을 지닌다.
\begin{equation}
\begin{aligned}
\mathbf{q} \otimes \mathbf{q}^{-1} = \mathbf{q}^{-1} \otimes \mathbf{q} = \mathbf{q}_{1}
\end{aligned}
\end{equation}

$\mathbf{q}^{-1}$은 다음과 같이 구할 수 있다.
\begin{equation}
\begin{aligned}
\mathbf{q}^{-1} = \mathbf{q}^{*} / \left \| \mathbf{q} \right \|^{2}
\end{aligned}
\end{equation}

1.2.7 Unit or normalized quaternion

단위 쿼터니언은 $\left \| \mathbf{q} \right \| = 1$의 특징을 가진다. 따라서 아래와 같은 특성을 만족한다.
\begin{equation}
\begin{aligned}
\mathbf{q}^{-1} = \mathbf{q}^{*}
\end{aligned}
\end{equation}

단위 쿼터니언은 3차원 공간에서 물체의 방향을 표현하거나 회전을 수행하는 연산자로써 사용된다. 위 성질은 역방향 회전이 기존 벡터에 켤레복소수 쿼터니언을 곱함으로써 얻어질 수 있다는 것을 의미한다. 단위 쿼터니언은 항상 다음과 같이 표현될 수 있다.
\begin{equation}
\begin{aligned}
\mathbf{q} = \begin{bmatrix}
\cos\theta \\ \mathbf{u}\sin\theta
\end{bmatrix}
\end{aligned}
\end{equation}

이 때, $\mathbf{u} = u_{x}i + u_{y}j + u_{z}k$는 단위 벡터를 의미하며 $\theta$는 스칼라 값이다.

1.3 Additional quaternion properties

1.3.1 Quaternion commutator

쿼터니언 교환자(commutator는 $[\mathbf{p}, \mathbf{q}] \triangleq \mathbf{p}\otimes \mathbf{q} - \mathbf{q}\otimes \mathbf{p}$와 같이 정의한다. (\ref{eq:4})로부터 다음 공식을 얻을 수 있다.
\begin{equation}
\begin{aligned}
\mathbf{p} \otimes \mathbf{q} - \mathbf{q}\otimes \mathbf{p} = 2\mathbf{p}_{v} \times \mathbf{q}_{v}
\end{aligned}
\end{equation}

이는 곧 다음과 같다.
\begin{equation}
\begin{aligned}
\mathbf{p}_{v} \otimes \mathbf{q}_{v} - \mathbf{q}_{v}\otimes \mathbf{p}_{v} = 2\mathbf{p}_{v} \times \mathbf{q}_{v}
\end{aligned} \label{eq:20}
\end{equation}

해당 성질은 특정 공식의 유도과정에서 종종 사용된다.

1.3.2 Product of pure quaternions

순수 쿼터니언은 $Q = \mathbf{q}_{v}$, $\mathbf{q} = [0,\mathbf{q}_{v}]$와 같이 실수부가 0이고 허수부만 존재하는 쿼터니언을 말한다. (\ref{eq:4})로부터 두 순수 쿼터니언의 곱셈을 다음과 같이 나타낼 수 있다.
\begin{equation}
\begin{aligned}
\mathbf{p}_{v} \otimes \mathbf{q}_{v} = -\mathbf{p}^{\intercal}_{v}\mathbf{q}_{v} + \mathbf{p}_{v} \times \mathbf{q}_{v} = \begin{bmatrix}
-\mathbf{p}_{v}^{\intercal}\mathbf{q}_{v} \\
\mathbf{p}_{v} \times \mathbf{q}_{v}
\end{bmatrix}
\end{aligned}
\end{equation}

동일한 순수 쿼터니언의 곱셈에 대해서는 다음과 같다.
\begin{equation}
\begin{aligned}
\mathbf{q}_{v} \otimes \mathbf{q}_{v} = -\mathbf{q}_{v}^{\intercal}\mathbf{q}_{v} = - \left \| \mathbf{q}_{v} \right \|^{2}
\end{aligned} \label{eq:5}
\end{equation}

또한 pure unitary quaternion $\mathbf{u} \in \mathbb{H}_{p}, \left \| \mathbf{u} \right \|=1$의 곱셈에 대해서는 다음과 같다.
\begin{equation}
\begin{aligned}
\mathbf{u} \otimes \mathbf{u} = -1
\end{aligned}
\end{equation}

이는 허수의 곱셈 $i\cdot i = -1$과 동일한 결과이다.

1.3.3 Natural powers of pure quaternions

임의의 자연수 $n \in \mathbb{N}$에 대하여 $\otimes$ 연산자를 사용하여 $n$번 곱한 쿼터니언을 $\mathbf{q}^{n}$이라고 하자. 만약 순수 쿼터니언 $\mathbf{v}$가 $\mathbf{v} = \mathbf{u}\theta$이고 $\theta = \left\| \mathbf{v} \right\| \in \mathbb{R}$, $\mathbf{u}$는 pure unitary quaternion 일 때, (\ref{eq:5})에 의해 다음과 같은 순환적 패턴이 형성된다.
\begin{equation}
\begin{aligned}
\mathbf{v}^{2}=-\theta^{2}, \quad \mathbf{v}^{3} = -\mathbf{u}\theta^{3}, \quad \mathbf{v}^{4} = \theta^{4}, \quad \mathbf{v}^{5} = \mathbf{u}\theta^{5}, \quad \mathbf{v}^{6} = -\theta^{6} \quad \cdots
\end{aligned} \label{eq:6}
\end{equation}


그리고 $\mathbf{u}$에 대해 다음과 같은 패턴이 형성된다.
\begin{equation}
\begin{aligned}
\mathbf{u}^{2} = -1, \quad \mathbf{u}^{3} = -\mathbf{u}, \quad \mathbf{u}^{4} = 1, \quad \mathbf{u}^{5} = \mathbf{u}, \quad \mathbf{u}^{6} = -1, \quad \cdots
\end{aligned}
\end{equation}


1.3.4 Exponential of pure quaternions

쿼터니언의 exponential은 다음과 같이 나타낼 수 있다.
\begin{equation}
\begin{aligned}
e^{\mathbf{q}} \triangleq \sum^{\infty}_{k=0} \frac{1}{k!} \mathbf{q}^{k} \in \mathbb{H}
\end{aligned}
\end{equation}

실수부만 존재하는 쿼터니언의 경우 이에 대한 exponential은 일반적인 exponential과 동일하다. 순수 쿼터니언 $\mathbf{v} = v_{x}i + v_{y}j + v_{z}k$에 대한 exponential 은 다음과 같이 정의한다.
\begin{equation}
\begin{aligned}
e^{\mathbf{v}} = \sum^{\infty}_{k=0} \frac{1}{k!}\mathbf{v}^{k} \in \mathbb{H}
\end{aligned}
\end{equation}

이 때, $\mathbf{v} = \mathbf{u}\theta, \ \ \theta = \left\| \mathbf{v} \right\|, \ \ \text{unitary } \mathbf{u}$과 (\ref{eq:6})을 활용하여 위 식을 전개하면 다음과 같이 스칼라와 벡터 수열로 분리할 수 있다.
\begin{equation}
\begin{aligned}
e^{\mathbf{u}\theta} = \bigg(1 - \frac{\theta^{2}}{2!} + \frac{\theta^{4}}{4!} + \cdots \bigg) + \bigg(\mathbf{u}\theta - \frac{\mathbf{u}\theta^{3}}{3!} + \frac{\mathbf{u}\theta^{5}}{5!} + \cdots \bigg)
\end{aligned}
\end{equation}

이는 $\cos\theta$, $\sin\theta$ 공식에 대한 수열을 나타내므로 다음과 같이 표현할 수 있다.
\begin{equation}
\begin{aligned}
e^{\mathbf{v}} = e^{\mathbf{u}\theta} = \cos\theta + \mathbf{u}\sin\theta = \begin{bmatrix} \cos\theta \\ \mathbf{u}\sin\theta \end{bmatrix}
\end{aligned} \label{eq:8}
\end{equation}

이는 오일러 공식 $e^{i \theta} = \cos\theta + i \sin\theta$와 동일하다. 또한, $\left\| e^{\mathbf{v}} \right\|^{2} = \cos^{2}\theta + \sin^{2}\theta = 1$이므로 순수 쿼터니언(pure quaternion)의 exponential은 단위 쿼터니언(unit quaternion)이 된다는 것을 확인할 수 있다. 순수 쿼터니언의 exponential은 다음의 성질을 만족한다.
\begin{equation}
\begin{aligned}
e^{-\mathbf{v}} = (e^{\mathbf{v}})^{*}.
\end{aligned}
\end{equation}

매우 작은 각도에 대한 쿼터니언은 $\mathbf{u} = \mathbf{v} / \left\| \mathbf{v} \right\|$ 공식이 0으로 나눠지는 것을 방지하기 위해 고차항을 제거한 테일러 급수로 나타낸다.
\begin{equation}
\begin{aligned}
e^{\mathbf{v}} \simeq \begin{bmatrix} 1 - \theta^{2}/2 \\ \mathbf{v}(1 - \theta^{2})/6 \end{bmatrix} \simeq \begin{bmatrix} 1 \\ \mathbf{v} \end{bmatrix} \Rightarrow_{\theta \rightarrow 0} \begin{bmatrix} 1 \\ 0 \end{bmatrix}
\end{aligned}
\end{equation}

1.3.5 Exponential of general quaternions

쿼터니언의 곱셈은 교환법칙을 만족하지 않으므로 일반적인 쿼터니언 $\mathbf{p}, \mathbf{q}$에 대해 $e^{\mathbf{p}+\mathbf{q}} = e^{\mathbf{p}}e^{\mathbf{q}}$가 성립하지 않는다. 하지만 실수부끼리 곱하는 경우 교환법칙이 성립한다. 일반적인 쿼터니언의 exponential은 다음과 같이 실수부와 허수부로 분해할 수 있다.
\begin{equation}
\begin{aligned}
e^{\mathbf{q}} = e^{q_{w} + \mathbf{q}_{v}} = e^{q_{w}}e^{\mathbf{q}_{v}}
\end{aligned}
\end{equation}

이를 (\ref{eq:8})을 사용하여 $\mathbf{u}\theta = \mathbf{q}_{v}$와 같이 표현하면 다음 공식을 얻을 수 있다.
\begin{equation}
\begin{aligned}
e^{\mathbf{q}} = e^{q_{w}} \begin{bmatrix} \cos \left\| \mathbf{q}_{v} \right\| \\ \frac{\mathbf{q}_{v}}{\left\| \mathbf{q}_{v} \right\|} \sin \left\| \mathbf{q}_{v} \right\| \end{bmatrix}
\end{aligned}
\end{equation}

1.3.6 Logarithm of unit quaternions

단위 쿼터니언은 $\left\| \mathbf{q} \right\| = 1$의 성질을 만족하므로 이에 대한 $\log$ 연산은 다음과 같이 나타낼 수 있다.
\begin{equation}
\begin{aligned}
\log \mathbf{q} = \log (\cos\theta + \mathbf{u}\sin\theta) = \log(e^{\mathbf{u}\theta}) = \mathbf{u}\theta = \begin{bmatrix} 0 \\ \mathbf{u}\theta \end{bmatrix}
\end{aligned}
\end{equation}

따라서 단위 쿼터니언(unit quaternion)의 $\log$ 연산은 순수 쿼터니언(pure quaternion)이 되는 것을 알 수 있다. angle-axis 값 $\mathbf{u}, \theta$는 (\ref{eq:8})을 통해 구할 수 있다.
\begin{equation}
\begin{aligned}
& \mathbf{u} = \mathbf{q}_{v} / \left\| \mathbf{q}_{v} \right\| \\
& \theta = \arctan(\left\| \mathbf{q}_{v} \right\|, q_{w})
\end{aligned}
\end{equation}

매우 작은 각도에 대한 쿼터니언은 0으로 나뉘어지는 것을 방지하기 위해 $\arctan$에 대한 테일러 급수로 나타낸다.
\begin{equation}
\begin{aligned}
\log(\mathbf{q}) = \mathbf{u}\theta = \mathbf{q}_{v} \frac{\arctan(\left\| \mathbf{q}_{v}\right\|, q_{w})}{\left| \mathbf{q}_{v} \right|} \simeq \frac{\mathbf{q}_{v}}{q_{w}} \bigg( 1 - \frac{\left\| \mathbf{q}_{v} \right|^{2}}{3q_{w}^{2}} \bigg) \simeq \mathbf{q}_{v} \Rightarrow_{\theta \rightarrow 0} 0.
\end{aligned}
\end{equation}

1.3.7 Logarithm of general quaternions

만약 $\mathbf{q}$가 일반적인 쿼터니언이라면 $\log$ 연산은 다음과 같다.
\begin{equation}
\begin{aligned}
\log \mathbf{q} = \log (\left\| \mathbf{q} \right\| \frac{\mathbf{q}}{\left\| \mathbf{q} \right\|}) = \log \left\| \mathbf{q} \right\| + \log \frac{\mathbf{q}}{\left\| \mathbf{q} \right\|} = \log \left\| \mathbf{q} \right\| + \mathbf{u}\theta = \begin{bmatrix} \log \left\| \mathbf{q} \right\| \\ \mathbf{u}\theta
\end{bmatrix}
\end{aligned}
\end{equation}

1.3.8 Exponential forms of the type $\mathbf{q}^{t}$

임의의 쿼터니언 $\mathbf{q} \in \mathbb{H}$와 실수 $t \in \mathbb{R}$가 주어졌을 때 이에 대한 지수승은 다음과 같이 나타낼 수 있다.
\begin{equation}
\begin{aligned}
\mathbf{q}^{t} = \exp(\log(\mathbf{q}^{t})) = \exp(t \log(\mathbf{q})).
\end{aligned}
\end{equation}

만약 $\left\| \mathbf{q} \right\| = 1$이면 $\mathbf{q} = [\cos\theta, \mathbf{u}\sin\theta]$이고 $\log(\mathbf{q}) = \mathbf{u}\theta$를 만족하므로 이를 활용하면 다음과 같이 나타낼 수 있다.
\begin{equation}
\begin{aligned}
\mathbf{q}^{t} = \exp(t \mathbf{u}\theta) = \begin{bmatrix} \cos t \theta \\ \mathbf{u}\sin t \theta \end{bmatrix}
\end{aligned} \label{eq:26}
\end{equation}

2 Rotations and cross-relations

2.1 The 3D vector rotation formula


위 그림은 오른손법칙을 사용하여 3차원 공간 상의 임의의 벡터 $\mathbf{x}$를 $\mathbf{u}$축을 중심으로 $\phi$만큼 회전시키는 모습을 나타낸다. $\mathbf{x}$를 $\mathbf{u}$축에 평행인 벡터 $\mathbf{x}_{\parallel}$와 직교하는 벡터 $\mathbf{x}_{\perp}$로 분해할 수 있다.
\begin{equation}
\mathbf{x} = \mathbf{x}_{\parallel} + \mathbf{x}_{\perp}.
\end{equation}

두 벡터는 다음과 같이 계산할 수 있다. 이 때, $\alpha$ 는 $\mathbf{x}$와 $\mathbf{u}$축 사이의 각도를 의미한다.
\begin{equation}
\begin{aligned}
& \mathbf{x}_{\parallel} = \mathbf{u}(\left\| \mathbf{x} \right\| \cos\alpha) = \mathbf{u}\mathbf{u}^{\intercal}\mathbf{x} \\
& \mathbf{x}_{\perp} = \mathbf{x} - \mathbf{x}_{\parallel} = \mathbf{x} - \mathbf{u}\mathbf{u}^{\intercal} \mathbf{x}.
\end{aligned}
\end{equation}

회전이 수행되는 동안 $\mathbf{u}$축에 평행한 $\mathbf{x}_{\parallel}$은 회전하지 않는다.
\begin{equation}
\mathbf{x}'_{\parallel} = \mathbf{x}_{\parallel}
\end{equation}

그리고 $\mathbf{u}$축에 직교하는 파트들은 $\mathbf{u}$와 수직인 평면 내부에서 회전하게 된다. 따라서 평면 내부에 서로 직교하는 두 basis $\{ \mathbf{e}_{1}, \mathbf{e}_{2}\}$가 있다고 했을 때 이는 다음과 같이 나타낼 수 있다.
\begin{equation}
\begin{aligned}
& \mathbf{e}_{1} = \mathbf{x}_{\perp} \\
& \mathbf{e}_{2} = \mathbf{u} \times \mathbf{x}_{\perp} = \mathbf{u} \times \mathbf{x}
\end{aligned}
\end{equation}

두 basis는 $\left\| \mathbf{e}_{1} \right\| = \left\| \mathbf{e}_{2} \right\|$를 만족한다. 따라서 $\mathbf{x}_{\perp} = \mathbf{e}_{1} \cdot 1 + \mathbf{e}_{2} \cdot 0$과 같이 쓸 수 있고 $\phi$만큼 회전한 직교벡터에 대해서는 다음과 같이 나타낼 수 있다.
\begin{equation}
\mathbf{x}'_{\perp} = \mathbf{e}_{1} \cos\phi + \mathbf{e}_{2}\sin\phi
\end{equation}

이는 다음과 같이 전개해서 나타낼 수 있다.
\begin{equation}
\mathbf{x}'_{\perp} = \mathbf{x}_{\perp} \cos\phi + (\mathbf{u}\times \mathbf{x}) \sin \phi
\end{equation}

따라서 최종적으로 회전한 벡터 $\mathbf{x}'$는 다음과 같이 쓸 수 있다.
\begin{equation}
\boxed{\mathbf{x}' = \mathbf{x}'_{\parallel} + \mathbf{x}'_{\perp} = \mathbf{x}_{\parallel} + \mathbf{x}_{\perp} \cos\phi + (\mathbf{u}\times \mathbf{x}) \sin \phi}
\label{eq:17}
\end{equation}

2.2 The rotation group SO(3)

3차원 공간에서 SO(3) 군은 원점을 중심으로 회전하는 연산에 대한 군을 말한다. 회전은 벡터의 길이와 상대벡터의 방향을 보존하는 선형 변환 연산이다. 이는 로보틱스에서 강체(rigid body)의 움직임 중 회전을 표현하는데 주로 사용된다. 강체의 움직임이란 물체의 형태가 변화하지 않아서 각도, 상대적인 회전량(relative orientation), 거리 등이 보존되는 움직임을 의미한다.

유클리디언 공간에서 $\mathbf{v} \in \mathbb{R}^{3}$ 벡터에 대해 회전을 수행하는 연산자 $r : \mathbb{R}^{3} \rightarrow \mathbb{R}^{3} ; \mathbf{v} \mapsto r(\mathbf{v}) $가 주어졌을 때 이는 다음과 같은 성질을 만족한다.

  • 회전은 벡터의 놈을 보존한다.

\begin{equation}
\left\| r(\mathbf{v}) \right\| = \sqrt{<r(\mathbf{v}), r(\mathbf{v})>} = \sqrt{<\mathbf{v}, \mathbf{v}>} \triangleq \left\| \mathbf{v} \right\|, \quad \forall \mathbf{v} \in \mathbb{R}^{3}
\label{eq:88}
\end{equation}

  • 회전은 두 벡터에 대한 각도를 보존한다.

\begin{equation}
<r(\mathbf{v}), r(\mathbf{w})> = <\mathbf{v}, \mathbf{w}> = \left\| \mathbf{v} \right\| \left\| \mathbf{w} \right\| \cos\alpha, \quad \forall \mathbf{v}, \mathbf{w} \in \mathbb{R}^{3}
\end{equation}

  • 회전은 두 벡터의 상대 회전량(relative orientation)을 보존한다.

\begin{equation}
\mathbf{u} \times \mathbf{v} = \mathbf{w} \Leftrightarrow r(\mathbf{u}) \times r(\mathbf{v}) = r(\mathbf{w})
\label{eq:10}
\end{equation}


위 성질을 토대로 SO(3) 군을 다음과 같이 정의할 수 있다.
\begin{equation}
SO(3) : \{ r : \mathbb{R}^{3} \rightarrow \mathbb{R}^{3} / \forall \mathbf{v},\mathbf{w} \in \mathbb{R}^{3}, \ \ \left\| r(\mathbf{v})\right\| = \left\| \mathbf{v} \right\|, \ \ r(\mathbf{v})\times r(\mathbf{w}) = r(\mathbf{v}\times\mathbf{w}) \}
\end{equation}

SO(3) 군은 일반적으로 회전행렬(rotation matrix)를 사용하여 표기한다. 하지만 쿼터니안을 사용하여 SO(3)를 표기하는 방법 또한 널리 사용된다. 본 챕터에서는 두 표기법이 동일하다는 것을 증명한다. 두 표기법은 개념적으로나 대수적으로 많은 부분에서 유사하다.

2.2 The rotation group and the rotation matrix

회전연산자 $r$은 선형성을 가진다. 따라서 선형성을 가진 스칼라나 벡터, 행렬로도 $r$을 표현할 수 있다. 그 중 대표적인 것이 회전행렬 $\mathbf{R} \in \mathbb{R}^{3\times3}$을 통해 회전연산자를 표현하는 방법이다.
\begin{equation}
r(\mathbf{v}) = \mathbf{Rv}
\end{equation}

내적 $<\mathbf{a}, \mathbf{b}> = \mathbf{a}^{\intercal}\mathbf{b}$ 을 활용하여 (\ref{eq:88})에 해당 공식을 적용하면 모든 $\mathbf{v}$에 대해 다음 공식이 적용된다.
\begin{equation}
(\mathbf{Rv})^{\intercal}(\mathbf{Rv}) = \mathbf{v}^{\intercal}\mathbf{R}^{\intercal}\mathbf{Rv} = \mathbf{v}^{\intercal}\mathbf{v}.
\end{equation}

이를 통해 회전행렬의 직교하는 성질을 유도할 수 있다.
\begin{equation}
\boxed{\mathbf{R}^{\intercal}\mathbf{R} = \mathbf{I} = \mathbf{RR}^{\intercal}}
\label{eq:9}
\end{equation}

회전행렬 $\mathbf{R} = [\mathbf{r}_{1}, \mathbf{r}_{2}, \mathbf{r}_{3}]$와 같이 열행렬 $\mathbf{r}_{i}$로 표기하면 직교행렬의 성질에 의해 다음 공식이 성립한다.
\begin{equation}
\begin{aligned}
& <\mathbf{r}_{i}, \mathbf{r}_{i}> = \mathbf{r}_{i}^{\intercal}\mathbf{r}_{i} = 1 \\
& <\mathbf{r}_{i}, \mathbf{r}_{j}> = \mathbf{r}_{i}^{\intercal} \mathbf{r}_{j} = 0, \quad \text{if } i \neq j
\end{aligned}
\end{equation}

이에 따라 3차원 공간에서 변환 시 벡터의 놈과 각도를 보존하는 군을 Orthogonal 군이라고 하며 줄여서 O(3)라고 표현한다. Orthogonal 군은 강체의 변환일 때 회전과 비강체의 변환일 때 반사(reflection)로 구성되어 있다. 여기서 군이라는 표현을 사용하는 이유는 두 개의 직교하는 O(3) 행렬을 곱하면 언제나 직교하는 O(3) 행렬이 나오기 때문이다. 즉, 곱셈에 대해 닫혀있다. 이는 역행렬 또한 직교행렬의 성질을 만족하는 것을 의미한다. 따라서 (\ref{eq:9})에 의해 회전행렬의 역행렬은 전치행렬과 동일하다.
\begin{equation}
\mathbf{R}^{-1} = \mathbf{R}^{\intercal}
\end{equation}

그리고 강체의 움직임에 한해서 상대적인 회전량을 보존하는 성질 (\ref{eq:10})에 의해 다음과 같은 제약조건이 추가된다.
\begin{equation}
\boxed{\det(\mathbf{R}) = 1}
\label{eq:11}
\end{equation}

Orthogonal 군에서 특별히 위와같이 positive unit determinant를 만족하는 군을 Speical Orthonogal 군, 즉 SO(3)군이라고 한다. 군의 성질을 만족해야 하므로 임의의 두 SO(3) 회전행렬의 곱은 항상 SO(3) 회전행렬이 된다.

2.3.1 The exponential map

Exponential map(+Logarithm map)은 3차원 공간의 회전을 조금 더 편하게 쉽게 이해 및 응용할 수 있게 해주는 강력한 수학적 도구이다. 이는 미세한 변화량에 대한 미적분(infinitesimal calculus)과 3차원 회전을 연결시켜주는 고리 역할을 수행한다. 또한, 3차원 회전에 대한 자코비안을 정의하거나, 섭동(perturbation) 모델링을 정의하거나 속도를 정의하고 사용할 수 있도록 해주는 핵심적인 역할을 수행한다. 따라서 3차원 공간에서 회전에 대한 추정 문제를 사용할 때 필수적으로 사용된다.

회전은 강체 움직임(rigid motion)의 성질을 만족한다. 이 때, 강체 움직임의 성질이란 처음 $t_0 = 0$ 순간의 방향 $r(0)$으로부터 $t$ 초 후 현재의 방향 $r(t)$까지 물체가 회전했을 때 SO(3) 군 내에서 연속적인 궤적(continuous trajectory)를 정의할 수 있음을 말한다. 이러한 연속적인 궤적은 시간 $t$에 따라 회전을 미분할 수 있음을 의미한다.



앞서 SO(3)의 제약조건 중 (\ref{eq:9})에 대한 시간미분 값을 유도하면 다음과 같다.
\begin{equation}
\frac{d}{dt} (\mathbf{R}^{\intercal}\mathbf{R}) = \dot{\mathbf{R}}^{\intercal}\mathbf{R} + \mathbf{R}^{\intercal}\dot{\mathbf{R}} = 0
\end{equation}

위 식을 정리하면 다음과 같은 공식을 얻을 수 있다.
\begin{equation}
\begin{aligned}
\mathbf{R}^{\intercal}\dot{\mathbf{R}} = -(\mathbf{R}^{\intercal}\dot{\mathbf{R}})^{\intercal}
\end{aligned}
\end{equation}

이는 $\mathbf{R}^{\intercal}\dot{\mathbf{R}}$이 반대칭행렬(skew -symmetric matrix)의 성질을 만족하는 것을 의미한다. 이러한 3x3 반대칭행렬의 집합을 so(3)라고 하며 SO(3) 군의 Lie Algebra라고 한다. 3x3 반대칭행렬은 다음과 같은 형태를 갖는다.
\begin{equation}
\begin{aligned}
[\omega]_{\times} \triangleq \begin{bmatrix} 0 & -\omega_{z} & \omega_{y} \\ \omega_{z} & 0 & -\omega_{x} \\ -\omega_{y} & \omega_{x} & 0 \end{bmatrix}
\end{aligned}
\end{equation}

반대칭행렬은 3자유도를 가지며 (\ref{eq:13})에서 설명한 것처럼 cross product 연산자로 사용된다. 이는 $\omega \in \mathbb{R}^{3} \leftrightarrow [\omega]_{\times} \in so(3)$과 같이 임의의 3차원 벡터는 so(3)와 일대일 매핑 관계에 있다는 것을 알 수 있다.
\begin{equation}
\begin{aligned}
\mathbf{R}^{\intercal}\dot{\mathbf{R}} = [\omega]_{\times}
\end{aligned}
\end{equation}

위 식은 다음과 같이 일반미분방정식(ordinary differential equation, ODE) 형태를 가진다.
\begin{equation}
\begin{aligned}
\dot{\mathbf{R}} = \mathbf{R}[\omega]_{\times}
\end{aligned}
\end{equation}

원점 부근에서 $\mathbf{R} = I$라고 하면 $\dot{\mathbf{R}} = [\omega]_{\times}$의 식이 유도된다. 따라서 so(3)는 원점 근처에서 $r(t)$의 시간에 대한 미분 공간으로 해석할 수 있다. 이는 SO(3) 군에 대한 접평면(tangent space)를 의미한다. 또는 velocity space이라고도 불린다. 따라서, $\omega$는 순간적인 각속도를 의미한다.

만약 각속도 $\omega$가 일정한 경우, 미분방정식은 다음과 같이 나타낼 수 있다.
\begin{equation}
\begin{aligned}
\mathbf{R}(t) = \mathbf{R}(0)e^{[\omega]_{\times}t} = \mathbf{R}_{0}e^{[\omega t]_{\times}}
\end{aligned}
\end{equation}

exponential $e^{[x]_{\times}}$는 테일러 급수로 전개하여 나타낼 수 있다. $\mathbf{R}_{0}, \mathbf{R}(t)$는 회전행렬을 의미하므로 $e^{[\omega t]_{\times}} = \mathbf{R}(0)^{\intercal}\mathbf{R}(t)$와 같이 나타낼 수 있다. 임의의 벡터 $\phi \triangleq \omega \Delta t$를 시간 $\Delta t$에 대한 회전벡터로 정의하면 다음 공식을 얻을 수 있다.
\begin{equation}
\begin{aligned}
\mathbf{R} = e^{[\phi]_{\times}}
\end{aligned} \label{eq:14}
\end{equation}

이는 $[\phi]_{\times}$를 exponential map을 통해 회전행렬로 변환이 가능함을 의미한다. 즉, so(3)에서 SO(3) 군으로 변환을 의미한다.
\begin{equation}
\begin{aligned}
\exp : so(3) \rightarrow SO(3) ; \quad [\phi]_{\times} \mapsto \exp([\phi]_{\times}) = e^{[\phi]_{\times}}
\end{aligned}
\end{equation}

2.3.2 The capitalized exponential map

앞서 소개한 exponential map은 종종 표기법에서 혼란을 일으킨다. 이는 주로 $\phi \in \mathbb{R}^{3]}$와 $[\phi]_{\times} \in so(3)$을 혼용하면서 발생한다. 이러한 표기의 혼란을 막기 위해 $\mathbb{R}^{3} \rightarrow SO(3)$로 변환하는 연산은 대문자 $\text{Exp}$ 연산이라고 정의한다.
\begin{equation}
\begin{aligned}
\text{Exp} : \mathbb{R}^{3} \rightarrow SO(3); \quad \phi \mapsto \text{Exp}(\phi) = e^{[\phi]_{\times}}
\end{aligned}
\end{equation}

두 연산자 exp, Exp 사이에는 다음과 같은 관계가 성립한다.
\begin{equation}
\begin{aligned}
\text{Exp}(\phi) \triangleq \exp([\phi]_{\times})
\end{aligned}
\end{equation}


다음 섹션에서는 벡터 $\phi$가 회전벡터 또는 angle-axis 벡터로 불리는 것에 대해 설명한다. 따라서 임의의 각도 $\theta$와 $\mathbf{u}$축에 대해 $\phi = \omega \Delta t = \theta \mathbf{u}$와 같이 나타낼 수 있다.

2.3.3 Rotation matrix and rotation vector: the Rodrigues rotation formula

회전행렬 $\mathbf{R}$은 회전벡터 $\phi = \theta \mathbf{u}$에 exponential map을 적용함으로써 정의된다. (\ref{eq:14})에 $\phi = \theta \mathbf{u}$를 활용하여 테일러 전개해보면 다음과 같다.
\begin{equation}
\begin{aligned}
\mathbf{R} = e^{\theta [\mathbf{u}]_{\times}} = \mathbf{I} + \theta [\mathbf{u}]_{\times} + \frac{1}{2}\theta^{2}[\mathbf{u}]_{\times}^{2} + \frac{1}{3!}\theta^{3}[\mathbf{u}]_{\times}^{3} + \frac{1}{4!}\theta^{4}[\mathbf{u}]^{4}_{\times} + \cdots
\end{aligned}
\end{equation}

$\mathbf{u}$는 단위벡터이므로 반대칭행렬 $[\mathbf{u}]_{\times}$는 다음을 만족한다.
\begin{equation}
\begin{aligned}
& [\mathbf{u}]_{\times}^{2} = \mathbf{uu}^{\intercal} - \mathbf{I} \\
& [\mathbf{u}]_{\times}^{3} = - [\mathbf{u}]_{\times}
\end{aligned} \label{eq:15}
\end{equation}

따라서 모든 $[\mathbf{u}]_{\times}$의 지수승은 $[\mathbf{u}]_{\times}$와 $[\mathbf{u}]_{\times}^{2}$로 표현이 가능하다.
\begin{equation}
\begin{aligned}
[\mathbf{u}]^{4}_{\times} = -[\mathbf{u}]^{2}_{\times}, \quad [\mathbf{u}]^{5}_{\times} = [\mathbf{u}]_{\times}, \quad [\mathbf{u}]^{6}_{\times} = [\mathbf{u}]^{2}_{\times}, \quad [\mathbf{u}]^{7}_{\times} = -[\mathbf{u}]_{\times}, \quad \cdots
\end{aligned}
\end{equation}

따라서 $[\mathbf{u}]_{\times}$와 $[\mathbf{u}]_{\times}^{2}$로 테일러 전개를 묶은 후 $\sin\theta$, $\cos\theta$ 공식을 적용하면 회전벡터로부터 회전행렬을 구하는 공식이 나오는데 이를 특별히 Rodrigues rotation formula라고 한다.
\begin{equation}
\begin{aligned}
\mathbf{R} = \mathbf{I} + \sin\theta [\mathbf{u}]_{\times} + (1 - \cos\theta)[\mathbf{u}]^{2}_{\times}
\end{aligned} \label{eq:16}
\end{equation}

이는 $\mathbf{R}\{\theta \} \triangleq \text{Exp}(\theta)$와 같이 나타낼 수 있다. 위 공식은 다양한 변형 공식이 존재하는데 대표적으로 (\ref{eq:15})를 활용하여 다음과 같이 나타낼 수 있다.
\begin{equation}
\begin{aligned}
\mathbf{R} = \mathbf{I}\cos\theta + [\mathbf{u}]_{\times}\sin\theta + \mathbf{uu}^{\intercal}(1 - \cos\theta)
\end{aligned}
\end{equation}

2.3.4 The logarithm maps

exponential map의 역연산으로 logarithm map을 정의할 수 있다.
\begin{equation}
\begin{aligned}
\log : SO(3) \rightarrow so(3); \quad \mathbf{R} \mapsto \log(\mathbf{R}) = [\mathbf{u}\theta]_{\times}
\end{aligned}
\end{equation}

이 때,
\begin{equation}
\begin{aligned}
& \theta = \arccos \bigg( \frac{\text{trace}(\mathbf{R}) -1}{2} \bigg) \\
& \mathbf{u} = \frac{(\mathbf{R} - \mathbf{R}^{\intercal})^{\vee}}{2\sin\theta}
\end{aligned}
\end{equation}

와 같으며 $(\cdot)^{\vee}$ 연산은 $[\cdot]_{\times}$ 연산의 역연산을 의미히나다. 즉, $([\mathbf{v}]_{\times})^{\vee} = \mathbf{v}$이고 $[\mathbf{V}^{\vee}]_{\times} = \mathbf{V}$이다. exponential map과 동일하게 대문자 연산 Log를 정의할 수 있다. 이는 회전행렬로부터 회전벡터를 구하는 연산이다.
\begin{equation}
\begin{aligned}
\text{Log} : SO(3) \rightarrow \mathbb{R}^{3}; \quad \mathbf{R} \mapsto \text{Log}(\mathbf{R}) = \mathbf{u}\theta
\end{aligned}
\end{equation}

소문자 연산자와 대문자 연산자 사이에는 다음과 같은 성질을 만족한다.
\begin{equation}
\begin{aligned}
\text{Log}(\mathbf{R}) \triangleq (\log(\mathbf{R}))^{\vee}
\end{aligned}
\end{equation}

지금까지 설명한 대소문자 exponential, logarithm map을 그림으로 표현하면 다음과 같다.




2.3.5 The rotation action

3차원 공간에서 임의의 벡터 $\mathbf{x}$를 $\mathbf{u}$축을 중심으로 각도 $\theta$만큼 회전시키기 위해서는 다음과 같은 선형연산이 적용된다.
\begin{equation}
\begin{aligned}
\mathbf{x}' = \mathbf{Rx}
\end{aligned}
\end{equation}

이 때, $\mathbf{R} = \text{Exp}(\mathbf{u}\theta)$이다. 이를 Rodrigues formula (\ref{eq:16})을 사용하여 표현하면 다음과 같다.
\begin{equation}
\begin{aligned}
\mathbf{x}' & = \mathbf{Rx} \\
& = (\mathbf{I} + \sin\theta[\mathbf{u}]_{\times} + (1-\cos\theta)[\mathbf{u}]^{2}_{\times})\mathbf{x} \\
& = \mathbf{x} + \sin\theta[\mathbf{u}]_{\times}\mathbf{x} + (1-\cos\theta)[\mathbf{u}]_{\times}^{2}\mathbf{x} \\
& = \mathbf{x} + \sin\theta(\mathbf{u}\times \mathbf{x}) + (1-\cos\theta)(\mathbf{uu}^{\intercal} - \mathbf{I})\mathbf{x} \\
& = \mathbf{x}_{\parallel} + \mathbf{x}_{\perp} + \sin\theta(\mathbf{u}\times \mathbf{x}) - (1-\cos\theta)\mathbf{x}_{\perp} \\
& = \mathbf{x}_{\parallel} + (\mathbf{u} \times \mathbf{x})\sin\theta + \mathbf{x}_{\perp}\cos\theta
\end{aligned}
\end{equation}

이는 정확히 벡터의 회전 공식 (\ref{eq:17})과 동일하다.

2.4 The rotation group and the quaternion

본 섹션에서는 SO(3)의 표기법으로 쿼터니언을 사용하는 방법에 대해 설명한다. 또한, 쿼터니언과 회전행렬이 어떠한 연관성이 있는지 설명한다. 쿼터니언이 벡터를 회전하는 연산은 다음과 같이 나타낼 수 있다.
\begin{equation}
\begin{aligned}
r(\mathbf{v}) = \mathbf{q} \otimes \mathbf{v} \otimes \mathbf{q}^{*}
\end{aligned}
\end{equation}

또한, 이를 통해 제약조건 (\ref{eq:19})를 활용하여 (\ref{eq:88})를 다시 표기하면 다음과 같다.
\begin{equation}
\begin{aligned}
\left\| \mathbf{q} \otimes \mathbf{v} \otimes \mathbf{q}^{*} \right\| = \left\| \mathbf{q} \right\|^{2} \left\| \mathbf{v} \right\| = \left\| \mathbf{v} \right\|
\end{aligned}
\end{equation}

이를 통해 $\left\| \mathbf{q} \right\| = 1$ 조건을 유도할 수 있다. 즉, 단위 쿼터니언(unit quaternion)만이 물체의 3차원 회전에 대한 연산을 수행할 수 있음을 의미한다. 이를 통해 다음 공식이 성립한다
\begin{equation}
\begin{aligned}
\boxed{\mathbf{q}^{*} \otimes \mathbf{q} = 1 = \mathbf{q} \otimes \mathbf{q}^{*}}
\end{aligned}
\end{equation}

이는 회전행렬의 직교성질인 $\mathbf{R}^{\intercal}\mathbf{R} = \mathbf{I} = \mathbf{RR}^{\intercal}$ (\ref{eq:9})와 유사하다. 또한 아래와 같은 전개를 통해 (\ref{eq:10})이 성립함을 보일 수 있다.
\begin{equation}
\begin{aligned}
& r(\mathbf{v}) \times r(\mathbf{w}) && = (\mathbf{q} \otimes \mathbf{v} \otimes \mathbf{q}^{*}) \times (\mathbf{q} \otimes \mathbf{w} \otimes \mathbf{q}^{*}) \\
& (\ref{eq:20}) && = \frac{1}{2} ((\mathbf{q} \otimes \mathbf{v} \otimes \mathbf{q}^{*}) \otimes (\mathbf{q} \otimes \mathbf{w} \otimes \mathbf{q}^{*}) - (\mathbf{q}\otimes \mathbf{w} \otimes \mathbf{q}^{*}) \otimes (\mathbf{q} \otimes \mathbf{v} \otimes \mathbf{q}^{*})) \\
& && = \frac{1}{2}(\mathbf{q} \otimes \mathbf{v} \otimes \mathbf{w} \otimes \mathbf{q}^{*} - \mathbf{q} \otimes \mathbf{w} \otimes \mathbf{v} \otimes \mathbf{q}^{*}) \\
& && = \frac{1}{2}(\mathbf{q} \otimes (\mathbf{v} \otimes \mathbf{w} - \mathbf{w} \otimes \mathbf{v}) \otimes \mathbf{q}^{*}) \\
& (\ref{eq:20}) && = \mathbf{q} \otimes (\mathbf{v} \times \mathbf{w}) \otimes \mathbf{q}^{*} \\
& && = r(\mathbf{v} \times \mathbf{w})
\end{aligned}
\end{equation}

위 전개를 통해 단위 쿼터니언은 곱셈 연산에 대해 닫힌 연산을 수행하는 군을 형성하는 것을 알 수 있다. 단위 쿼터니언 군의 manifold는 기하학적으로 $\mathbb{R}^{4}$차원의 단위 구(unit sphere)를 형성한다. 4차원 구는 일반적으로 표현할 수 없으므로 이를 단순화하여 3차원 구를 통해 manifold를 설명한다. 이러한 단위 쿼터니언의 군을 $\mathcal{S}^{3}$라고 부른다.



2.4.1 The exponential map

임의의 단위 쿼터니언이 $\mathbf{q} \in S^{3}$가 주어졌을 때 이는 직교조건 $\mathbf{q}^{*} \otimes \mathbf{q} = 1$을 만족한다. 따라서 회전행렬과 마찬가지로 직교조건에 대해 미분을 취하면 다음과 같다.
\begin{equation}
\frac{d (\mathbf{q}^{*} \otimes \mathbf{q})}{dt} = \dot{\mathbf{q}}^{*} \otimes \mathbf{q} + \mathbf{q}^{*} \otimes \dot{\mathbf{q}} = 0
\end{equation}

이를 전개하면 다음과 같다.
\begin{equation}
\mathbf{q}^{*} \otimes \dot{\mathbf{q}} = -(\dot{\mathbf{q}}^{*} \otimes \mathbf{q}) = -(\mathbf{q}^{*} \otimes \dot{\mathbf{q}})^{*}
\end{equation}

이는 곧 $\mathbf{q}^{*} \otimes \dot{\mathbf{q}}$이 순수 쿼터니언임(pure quaternion)을 의미한다. 순수 쿼터니언은 실수부가 0이므로 켤레복소수를 취하면 음수인 자기 자신이 된다. 순수 쿼터니언을 $\Omega \in \mathbb{H}$라고 하면 다음과 같이 나타낼 수 있다.
\begin{equation}
\mathbf{q}^{*} \otimes \dot{\mathbf{q}} = \Omega = \begin{bmatrix}
0 \\ \Omega
\end{bmatrix} \in \mathbb{H}_{p}
\end{equation}

이를 정리하면 다음과 같다.
\begin{equation}
\dot{\mathbf{q}} = \mathbf{q} \otimes \Omega
\label{eq:22}
\end{equation}

원점 부근에서 $\mathbf{q} = 1$이 되고 위 식은 $\dot{\mathbf{q}} = \Omega \in \mathbb{H}_{p}$와 같이 나타낼 수 있다. 따라서 순수 쿼터니언 공간 $\mathbb{H}_{p}$는 접평면(tangent space)을 의미하며 $S^{3}$ 군의 Lie Algebra라고 불린다.



단위 쿼터니언의 경우 회전행렬과 달리 접평면이 velocity space를 의미하지 않고 half-velocity space를 의미한다. 이에 대해서는 뒷 섹션에서 자세히 설명한다. 만약 $\Omega$가 일정한 경우 미분방정식은 다음과 같이 나타낼 수 있다.
\begin{equation}
\mathbf{q}(t) = \mathbf{q}(0) \otimes e^{\Omega t}
\label{eq:23}
\end{equation}

위 식에서 $\mathbf{q}(t)$와 $\mathbf{q}_{0}$가 모두 단위 쿼터니언이므로 $e^{\Omega t}$ 또한 단위 쿼터니언이 된다. 이는 (\ref{eq:8})에서 한 번 유도한 적이 있다. $\mathbf{V} \triangleq \Omega \Delta t$와 같이 정의하면
\begin{equation}
\boxed{\mathbf{q} = e^{\mathbf{V}}}
\end{equation}

와 같이 나타낼 수 있다. 이는 회전행렬과 마찬가지로 순수 쿼터니언(pure quaterinon)에 exponential map을 취하면 단위 쿼터니언(unit quaternion)을 만들 수 있음을 의미한다.
\begin{equation}
\exp : \mathbb{H}_{p} \rightarrow S^{3}; \quad \mathbf{V} \mapsto \exp(\mathbf{V}) = e^{\mathbf{V}}
\label{eq:21}
\end{equation}

2.4.2 The capitalized exponential map

exponential map에 사용되는 순수 쿼터니언 $\mathbf{V}$은 일반적으로 $\mathbf{V} = \theta \mathbf{u} = \phi \mathbf{u}/2$와 같이 $\mathbf{u}$축을 중심으로 회전하고자 하는 각도 $\phi$의 절반의 각도 $\theta = \phi/2$를 사용한다. 이에 대해 직관적으로 이해해보면 다음과 같다. 임의의 벡터 $\mathbf{x}$가 쿼터니언에 의해 회전하기 위해서는 $\mathbf{x}' = \mathbf{q} \otimes \mathbf{x} \otimes \mathbf{q}^{*}$과 같이 두 번에 걸쳐서 쿼터니언이 곱해지기 때문에 $\mathbf{V}$에 절반의 각도를 사용하는 것으로 이해할 수 있다.

쿼터니언과 angle-axis 표현법 $\mathbf{v} = \phi\mathbf{u} \in \mathbb{R}^{3}$ 사이의 직접적인 관계를 표현하기 위해 angle-axis의 절반의 각도를 사용하는 순수 쿼터니언으로 변환하는 대문자 exponential map에 대해 정의할 수 있다.
\begin{equation}
\text{Exp} : \mathbb{R}^{3} \rightarrow S^{3}; \quad \mathbf{v} \mapsto \text{Exp}(\mathbf{v}) = e^{\mathbf{v}/2}
\end{equation}

대문자와 소문자 exponential map 사이의 관계는 다음과 같다.
\begin{equation}
\text{Exp} (\mathbf{v}) \triangleq \exp(\mathbf{v}/2)
\end{equation}

임의의 각속도를 $\omega = 2\Omega \in \mathbb{R}^{3}$와 같이 정의하면 (\ref{eq:22}), (\ref{eq:23})은 다음과 같이 다시 나타낼 수 있다.
\begin{equation}
\begin{aligned}
& \dot{\mathbf{q}} = \frac{1}{2} \mathbf{q} \otimes \omega \\
& \mathbf{q} = e^{\omega t /2}
\end{aligned} \label{eq:24}
\end{equation}

2.4.3 Quaternion and rotation vector

임의의 angle-axis 벡터 $\mathbf{v} = \phi \mathbf{u}$가 주어졌을 때, 이에 대한 exponential map은 오일러 공식의 확장 버전으로 표현할 수 있다.
\begin{equation}
\boxed{\mathbf{q} \triangleq \text{Exp}(\mathbf{v}) = \text{Exp}(\phi \mathbf{u}) = e^{\phi \mathbf{u}/2} = \cos\frac{\phi}{2} + \mathbf{u}\sin\frac{\phi}{2} = \begin{bmatrix}
\cos(\phi/2) \\ \mathbf{u} \sin(\phi/2)
\end{bmatrix}}
\end{equation}

위 식은 주로 angle-axis 표현법에서 쿼터니언으로 변환하는 공식으로 사용되며 $\mathbf{q} = \mathbf{q}\{\mathbf{v}\} \triangleq \text{Exp} (\mathbf{v})$와 같이 표기한다.

2.4.4 The logarithmic maps

단위 쿼터니언 또한 회전행렬과 마찬가지로 exponential map에 대한 역연산인 logarithmic map이 존재한다.
\begin{equation}
\log : S^{3} \rightarrow \mathbb{H}_{p} ; \quad \mathbf{q} \mapsto \log(\mathbf{q}) = \mathbf{u}\theta
\end{equation}

또한 대문자 logratihmic map 역시 존재한다. 이는 임의의 쿼터니언을 3차원 벡터로 변환하는 연산이다.
\begin{equation}
\text{Log} : S^{3} \rightarrow \mathbb{R}^{3}; \quad \mathbf{q} \mapsto \text{Log}(\mathbf{q}) = \mathbf{u}\phi
\end{equation}

두 연산 사이에는 다음과 같은 관계가 성립한다.
\begin{equation}
\text{Log}(\mathbf{q}) \triangleq 2\log(\mathbf{q})
\end{equation}

$\phi$와 $\mathbf{u}$는 다음과 같이 구할 수 있다.
\begin{equation}
\begin{aligned}
& \phi = 2\arctan(\left\| \mathbf{q}_{v} \right\|, q_{w}) \\
& \mathbf{u} = \mathbf{q}_{v} / \left \| \mathbf{q}_{v} \right \|
\end{aligned}
\end{equation}

매우 작은 움직임을 표현하는 쿼터니언에 대해서는 위 식과 같이 $\mathbf{u}$를 구할 수 없다. 이럴 경우에는 테일러 급수를 사용하여 고차항을 버리고 근사된 값을 사용한다.
\begin{equation}
\text{Log} (\mathbf{q}) = \theta \mathbf{u} \simeq 2 \frac{\mathbf{q}_{v}}{q_{w}} \bigg( 1 - \frac{\left\| \mathbf{q}_{v} \right\|^{2}}{3q_{w}^{2}} \bigg)
\end{equation}

2.4.5 The rotation action

앞서 설명한 내용과 같이 3차원 공간에서 임의의 벡터 $\mathbf{x}$를 $\mathbf{u}$축을 중심으로 $\phi$만큼 회전하고 싶으면 다음과 같이 2번의 쿼터니언 곱을 통해 회전을 표현할 수 있다.
\begin{equation}
\mathbf{x}' = \mathbf{q} \otimes \mathbf{x} \otimes \mathbf{q}^{*}
\end{equation}

이 때, $\mathbf{q} = \text{Exp}(\mathbf{u}\phi)$를 의미하며 임의의 벡터 $\mathbf{x}$ 또한 다음과 같은 쿼터니언 형태로 변형된다.
\begin{equation}
\mathbf{x} = xi + yj + zk = \begin{bmatrix}
0 \\ \mathbf{x}
\end{bmatrix} \in \mathbb{H}_{p}
\end{equation}

2번의 쿼터니언 곱이 벡터의 회전을 수행하는 것을 증명하기 위해서 (\ref{eq:4}), (\ref{eq:24})를 사용하여 위 공식을 다음과 같이 나타낼 수 있다.
\begin{equation}
\begin{aligned}
\mathbf{x}' & = \mathbf{q} \otimes \mathbf{x} \otimes \mathbf{q}^{*} \\
& = \bigg( \cos\frac{\phi}{2} + \mathbf{u}\sin\frac{\phi}{2} \bigg) \otimes (0 + \mathbf{x}) \otimes (\cos\frac{\phi}{2} - \mathbf{u}\sin\frac{\phi}{2}) \\
& = \mathbf{x}\cos^{2}\frac{\phi}{2} + (\mathbf{u} \otimes \mathbf{x} - \mathbf{x}\otimes \mathbf{u})\sin\frac{\phi}{2} \cos\frac{\phi}{2} - \mathbf{u} \otimes \mathbf{x} \otimes \mathbf{u} \sin^{2}\frac{\phi}{2} \\
& = \mathbf{x}\cos^{2}\frac{\phi}{2} + 2(\mathbf{u}\times \mathbf{x})\sin\frac{\phi}{2} \cos\frac{\phi}{2} - (\mathbf{x}(\mathbf{u}^{\intercal}\mathbf{u}) - 2\mathbf{u}(\mathbf{u}^{\intercal}\mathbf{x}))\sin^{2}\frac{\phi}{2} \\
& = \mathbf{x}(\cos^{2}\frac{\phi}{2} - \sin^{2}\frac{\phi}{2}) + (\mathbf{u} \times \mathbf{x})(2\sin\frac{\phi}{2}\cos\frac{\phi}{2}) + \mathbf{u}(\mathbf{u}^{\intercal}\mathbf{x})(2\sin^{2}\frac{\phi}{2}) \\
& = \mathbf{x}\cos\phi + (\mathbf{u} \times \mathbf{x})\sin\phi + \mathbf{u}(\mathbf{u}^{\intercal}\mathbf{x})(1-\cos\phi) \\
& = (\mathbf{x} - \mathbf{uu}^{\intercal}\mathbf{x})\cos\phi + (\mathbf{u} \times \mathbf{x})\sin\phi + \mathbf{uu}^{\intercal}\mathbf{x} \\
& = \mathbf{x}_{\perp}\cos\phi + (\mathbf{u} \times \mathbf{x})\sin\phi + \mathbf{x}_{\parallel}
\end{aligned} \label{eq:30}
\end{equation}

위 전개를 통해 쿼터니언 연산이 벡터의 회전 공식과 동일하다는 것을 알 수 있다.

2.4.6 The double cover of the manifold of SO(3)

임의의 단위 쿼터니언 $\mathbf{q}$가 주어졌다고 했을 때, 항등 쿼터니언(identity quaternion) $\mathbf{q}_{1} = [1,0,0,0]$과 $\mathbf{q}$ 사이의 각도 $\theta$는 다음과 같이 표현할 수 있다.
\begin{equation}
\cos\theta = \mathbf{q}_{1}^{\intercal}\mathbf{q} = \mathbf{q}(1) = q_{w}
\end{equation}

또한, 3차원 물체가 $\mathbf{q}$에 의해 $\phi$ 각도만큼 회전했을 때 $\mathbf{q}$는 다음과 같다.
\begin{equation}
\mathbf{q} = \begin{bmatrix}
q_{w} \\ \mathbf{q}_{v}
\end{bmatrix} = \begin{bmatrix}
\cos\phi/2 \\ \mathbf{u} \sin\phi/2
\end{bmatrix}
\end{equation}

위 두 식을 종합해보면 $q_{w} = \cos\theta = \cos\phi/2$인 것을 알 수 있다. 즉, 단위 쿼터니언 공간 $S^{3}$에서 움직이는 각도 $\theta$는 실제 물체가 움직이는 각도의 절반 $\phi/2$ 인 것을 알 수 있다.
\begin{equation}
\theta = \phi/2
\end{equation}



만약 $\theta = \pi/2$인 경우 실제 월드 상의 물체는 $\phi = \pi$만큼 회전한다. 그리고 $\theta = \pi$만큼 반바퀴 회전을 하면 실제 월드 상의 물체는 $\phi = 2\pi$만큼 한 바퀴 회전을 한다.

2.5 Rotation matrix and quaternion

임의의 angle-axis 벡터 $\mathbf{v} = \mathbf{u}\phi$가 주어졌을 때, $\mathbf{q} = \text{Exp}(\mathbf{u}\phi)$를 통해 단위 쿼터니언을 만들 수 있고 또한 $\mathbf{R} = \text{Exp}(\mathbf{u}\phi)$를 통해 회전행렬을 만들 수 있다. 그리고 위 두 값을 통해 3차원 공간 상의 임의의 벡터 $\mathbf{x}$를 $\mathbf{u}$축을 중심으로 $\phi$만큼 회전시킬 수 있다.
\begin{equation}
\forall \mathbf{v}, \mathbf{x} \in \mathbb{R}^{3}, \quad \mathbf{q} = \text{Exp}(\mathbf{v}), \quad \mathbf{R} = \text{Exp}(\mathbf{v})
\end{equation}

이는 곧 다음 공식이 성립함을 의미한다.
\begin{equation}
\mathbf{q} \otimes \mathbf{x} \otimes \mathbf{q}^{*} = \mathbf{Rx}
\end{equation}

위 두 식은 모두 $\mathbf{x}$에 대한 선형변환 식이다. 이를 토대로 회전행렬과 단위 쿼터니언 사이의 변환식을 다음과 같이 유도할 수 있다.
\begin{equation}
\boxed{\mathbf{R} = \begin{bmatrix}
q_{w}^{2} +q_{x}^{2}-q_{y}^{2}-q_{z}^{2} & 2(q_{x}q_{y} -q_{w}q_{z}) & 2(q_{x}q_{z} + q_{w}q_{y}) \\
2(q_{x}q_{y} + q_{w}q_{z}) & q_{w}^{2}-q_{x}^{2}+q_{y}^{2}-q_{z}^{2} & 2(q_{y}q_{z} - q_{w}q_{x}) \\
2(q_{x}q_{z} - q_{w}q_{y}) & 2(q_{y}q_{z} + q_{w}q_{z}) & q_{w}^{2} - q_{x}^{2} - q_{y}^{2} + q_{z}^{2}
\end{bmatrix}}
\end{equation}

위 변환식은 $\mathbf{R} = \mathbf{R}\{\mathbf{q}\}$와 같이 나타낸다. 또한, (\ref{eq:25})를 참고해서 쿼터니언을 행렬곱 형태로 만들면 다음과 같이 다시 쓸 수 있다.
\begin{equation}
\mathbf{q} \otimes \mathbf{x} \otimes \mathbf{q}^{*} = [\mathbf{q}^{*}]_{R}[\mathbf{q}]_{L}\begin{bmatrix}
0 \\ \mathbf{x}
\end{bmatrix} = \begin{bmatrix}
0 \\ \mathbf{Rx}
\end{bmatrix} \label{eq:31}
\end{equation}

이를 통해 다음과 같이 다른 변환 공식을 유도할 수 있다.
\begin{equation}
\boxed{\mathbf{R} = (q_{w}^{2} - \mathbf{q}_{v}^{\intercal}\mathbf{q}_{v})\mathbf{I} + 2\mathbf{q}_{v}\mathbf{q}_{v}^{\intercal} + 2q_{w}[\mathbf{q}_{v}]_{\times}}
\end{equation}

회전행렬과 단위 쿼터니언 사이에는 다음과 같은 성질이 만족한다.
\begin{equation}
\begin{aligned}
& \mathbf{R}\{[1,0,0,0]^{\intercal}\} = \mathbf{I} \\
& \mathbf{R}\{\mathbf{-q}\} = \mathbf{R}\{\mathbf{q}\} \\
& \mathbf{R}\{\mathbf{q}^{*}\} = \mathbf{R}\{\mathbf{q}\}^{\intercal} \\
& \mathbf{R}\{\mathbf{q}_{1} \otimes \mathbf{q}_{2}\} = \mathbf{R}\{\mathbf{q}_{1}\}\mathbf{R}\{\mathbf{q}_{2}\}
\end{aligned}
\end{equation}

위 성질들을 토대로 쿼터니언의 지수승은 다음과 같이 변환된다.
\begin{equation}
\mathbf{R}\{\mathbf{q}^{t}\} = \mathbf{R}\{\mathbf{q}\}^{t}
\end{equation}

이는 스칼라 $t$에 대해 단위 쿼터니언과 회전행렬의 구형 보간법(spherical interpolation)이 서로 연관이 있음을 의미한다.

2.6 Rotation composition

단위 쿼터니언의 합성(composition)은 회전함수의 합성과 유사하다. 즉, 동일한 순서로 곱셈을 수행한다.
\begin{equation}
\mathbf{q}_{AC} = \mathbf{q}_{AB} \otimes \mathbf{q}_{BC} \quad \quad \mathbf{R}_{AC} = \mathbf{R}_{AB}\mathbf{R}_{BC}
\end{equation}

이는 결합법칙을 사용하여 다음과 같이 나타낼 수 있다.
\begin{equation}
\begin{aligned}
\mathbf{x}_{A} & = \mathbf{q}_{AB} \otimes \mathbf{x}_{B} \otimes \mathbf{q}_{AB}^{*} \\
& = \mathbf{q}_{AB} \otimes (\mathbf{q}_{BC} \otimes \mathbf{x}_{c} \otimes \mathbf{q}_{BC}^{*}) \otimes \mathbf{q}_{AB}^{*} \\
& = (\mathbf{q}_{AB} \otimes \mathbf{q}_{BC}) \otimes \mathbf{x}_{c} \otimes (\mathbf{q}_{BC}^{*} \otimes \mathbf{q}_{AB}^{*}) \\
& = (\mathbf{q}_{AB} \otimes \mathbf{q}_{BC}) \otimes \mathbf{x}_{c} \otimes (\mathbf{q}_{AB} \otimes \mathbf{q}_{BC})^{*} \\
& = \mathbf{q}_{AC} \otimes \mathbf{x}_{c} \otimes \mathbf{q}_{AC}^{*} \quad \text{for quaternion}
\end{aligned}
\end{equation}

\begin{equation}
\begin{aligned}
\mathbf{x}_{A} &= \mathbf{R}_{AB}\mathbf{x}_{B} \\
& = \mathbf{R}_{AB}(\mathbf{R}_{BC}\mathbf{x}_{C}) \\
& = (\mathbf{R}_{AB}\mathbf{R}_{BC})\mathbf{x}_{C} \\
& = \mathbf{R}_{AC} \mathbf{x}_{C} \quad \text{for rotation matrix}
\end{aligned}
\end{equation}



이 때, $\mathbf{q}_{ij}$ 또는 $\mathbf{R}_{ij}$의 의미는 특정 i 방향(orientation)에서 j 방향으로 변환하는 연산자를 의미한다. 또는 i 좌표계에서 j 좌표계로의 변환으로도 이해할 수 있다.

2.7 Spherical linear interpolation (SLERP)

단위 쿼터니언은 두 방향(orientation) $\mathbf{q}_{0}, \mathbf{q}_{1}$이 주어졌을 때 두 지점을 구의 선형 보간(spherical linear interpolation)하기 상대적으로 쉬운 특징을 가지고 있다. 구의 선형보간은 출발지가 $\mathbf{q}_{0}$ 이고 목적지가 $\mathbf{q}_{1}$일 때, 특정 시간 $t$에서 보간함수 $\mathbf{q}(t), t \in [0,1]$를 구하는 문제가 된다. 보간함수는 초기조건으로 $\mathbf{q}(0) = \mathbf{q}_{0}, \mathbf{q}(1) = \mathbf{q}_{1}$를 가진다. 보간함수 $\mathbf{q}(t)$를 사용하면 $t \in [0,1]$ 구간에서 물체가 고정된 속도로 자연스럽게 $\mathbf{q}_{0} \rightarrow \mathbf{q}_{1}$로 회전할 수있다.

Method 1 첫 번째 방법은 쿼터니언 대수학을 이용하는 것이다. 방향의 변화량 $\Delta \mathbf{q}$를 사용하여 $\mathbf{q}_{1} = \mathbf{q}_{0} \otimes \Delta \mathbf{q}_{0}$와 같이 표현하는 방법이다.
\begin{equation}
\Delta \mathbf{q} = \mathbf{q}_{0}^{*} \otimes \mathbf{q}_{1}
\end{equation}

위 변화량에 logarithmic map을 사용하여 angle-axis 회전벡터 $\Delta \mathbf{v} = \mathbf{u} \Delta \phi$를 얻을 수 있다.
\begin{equation}
\mathbf{u}\Delta\phi = \text{Exp} (\Delta \mathbf{q})
\end{equation}

최종적으로 $\mathbf{u}$축은 유지한 상태에서 시간 $t \in [0,1]$에 따른 각도의 변화량을 $\delta \phi = t\Delta \phi$라고 하면 $\delta \mathbf{q} = \text{Exp}(\mathbf{u}\delta\phi)$와 같이 나타낼 수 있다. 이를 다시 위 공식에 대입하면 다음과 같이 보간함수를 구할 수 있다.
\begin{equation}
\mathbf{q}(t) = \mathbf{q}_{0} \otimes \text{Exp}(t\mathbf{u}\Delta\phi)
\end{equation}

이를 자세히 풀어쓰면 $\mathbf{q}(t) = \mathbf{q}_{0} \otimes \text{Exp}(t \text{Log}(\mathbf{q}_{0}^{*}\otimes \mathbf{q}_{1}))$가 되고 이를 다시 정리하면 다음과 같다.
\begin{equation}
\boxed{\mathbf{q}(t) = \mathbf{q}_{0} \otimes (\mathbf{q}_{0}^{*} \otimes \mathbf{q}_{1})^{t}}
\end{equation}

이는 (\ref{eq:26})과 같이 벡터 형태로 나타낼 수 있다.
\begin{equation}
\mathbf{q}(t) = \mathbf{q}_{0} \otimes \begin{bmatrix}
\cos(t\Delta\phi/2) \\ \mathbf{u} \sin(t\Delta\phi/2)
\end{bmatrix}
\end{equation}


Note: 위 식을 회전행렬에 대한 식으로 변경하면 다음과 같다.
\begin{equation}
\mathbf{R}(t) = \mathbf{R}_{0} \text{Exp}(t \text{Log}(\mathbf{R}^{\intercal}_{0}\mathbf{R}_{1})) = \mathbf{R}_{0}(\mathbf{R}_{0}^{\intercal}\mathbf{R}_{1})^{t}
\end{equation}

$\mathbf{R}^{t}$를 Rodrigues 공식 (\ref{eq:16})을 사용하여 다시 표현하면 다음과 같다.
\begin{equation}
\mathbf{R}(t) =\mathbf{R}_{0}(\mathbf{I} + \sin(t \Delta \phi)[\mathbf{u}]_{\times} + (1-\cos(t\Delta\phi))[\mathbf{u}]_{\times})
\end{equation}

Method 2 다른 구의 선형보간 방법은 쿼터니언 대수학을 사용하거나 manifold에 종속되지 않는 방법이다. 위 그림에서 보면 $\mathbf{q}_{0}, \mathbf{q}_{1}$은 단위 원 내에 존재하는 단위벡터로 볼 수 있다. 보간함수 $\mathbf{q}(t)$는 $\mathbf{q}_{0}$와 $\mathbf{q}_{1}$의 최단거리를 동일한 각속도로 움직이는 단위벡터로 생각할 수 있다. 최단거리는 두 지점을 포함하는 하나의 평면 호(planar arc)를 형성하는데 이를 $\pi$ 평면이라고 정의한다.

첫 번째 접근 방법은 두 단위벡터 $\mathbf{q}_{0}, \mathbf{q}_{1}$ 사이의 각도를 대수학적으로 구하는 것이다.
\begin{equation}
\cos(\Delta \theta) = \mathbf{q}_{0}^{\intercal}\mathbf{q}_{1} \quad \Delta \theta = \arccos(\mathbf{q}_{0}^{\intercal}\mathbf{q}_{1})
\label{eq:27}
\end{equation}

다음으로 $\pi$ 평면 내에서 두 개의 직교하는 basis $\{\mathbf{q}_{0}, \mathbf{q}_{\perp]}\}$를 정의한다. $\mathbf{q}_{\perp}$는 $\mathbf{q}_{1}$를 $\mathbf{q}_{0}$에 대해 직교화한 basis 벡터를 의미한다.
\begin{equation}
\mathbf{q}_{\perp} = \frac{\mathbf{q}_{1} - (\mathbf{q}_{0}^{\intercal}\mathbf{q}_{1})\mathbf{q}_{0}}{\left\| \mathbf{q}_{1} - (\mathbf{q}_{0}^{\intercal}\mathbf{q}_{1})\mathbf{q}_{0} \right\|}
\end{equation}



따라서 $\mathbf{q}_{1}$은 다음과 같이 나타낼 수 있다.
\begin{equation}
\mathbf{q}_{1} = \mathbf{q}_{0} \cos\Delta\theta + \mathbf{q}_{\perp}\sin\Delta \theta
\label{eq:28}
\end{equation}

따라서 보간함수 $\mathbf{q}(t)$는 $\mathbf{q}_{0}$를 $\pi$ 평면을 따라 각도 $t\Delta\theta$만큼 움직이는 함수가 된다.
\begin{equation}
\boxed{\mathbf{q}(t) = \mathbf{q}_{0}\cos(t\Delta\theta) + \mathbf{q}_{\perp}\sin(t\Delta\theta)}
\label{eq:29}
\end{equation}

Method 3 이와 유사한 방법으로 Glenn Davis in Shoemake (1985)가 제안한 방법이 있다. 이 방법은 $\mathbf{q}_{0}, \mathbf{q}_{1}$이 속한 $\pi$ 평면 내에 임의의 벡터는 선형조합(linear combination)을 통해 나타낼 수 있는 성질을 활용한다. $\Delta\theta$를 (\ref{eq:27})을 통해 계산하고 $\mathbf{q}_{\perp}$를 (\ref{eq:28})을 통해 구한 후 (\ref{eq:29})에 넣으면 다음과 같다. 이 때, $\sin(\Delta\theta - t\Delta\theta) = \sin\Delta\theta\cos t \Delta\theta - \cos\Delta\theta \sin t \Delta\theta$의 성질을 활용함으로써 Davis's formula를 얻을 수 있다.
\begin{equation}
\boxed{\mathbf{q}(t) = \mathbf{q}_{0} \frac{\sin((1-t)\Delta\theta)}{\sin(\Delta\theta)} + \mathbf{q}_{1}\frac{\sin(t\Delta\theta)}{\sin\Delta\theta}}
\end{equation}

위 식을 $s = 1-t$과 같이 치환하여 표현하면 다음과 같은 대칭성을 가진다.
\begin{equation}
\mathbf{q}(s) = \mathbf{q}_{1} \frac{\sin((1-s)\Delta\theta)}{\sin(\Delta\theta)} + \mathbf{q}_{0}\frac{\sin(s\Delta \theta)}{\sin(\Delta\theta)}
\end{equation}

이는 위 공식과 $\mathbf{q}_{0}, \mathbf{q}_{1}$이 바뀐 것을 제외하고 정확히 동일하다.

앞서 소개한 모든 쿼터니언 기반의 구의 선형보간 방법들(SLERPs)들은 보간하는 실제 회전각도가 $\phi \leq \pi$와 같은 조건을 가진다. 하지만 이전 챕터에서 설명한 쿼터니언의 SO(3) double cover 성질에 의해, 실제 단위 쿼터니언 공간에서 수행되는 보간은 $\Delta\theta \leq \pi/2$를 만족해야 한다. 따라서 만약 $\cos(\Delta \theta) = \mathbf{q}_{0}^{\intercal}\mathbf{q}_{1} < 0$이면 $\mathbf{q}_{1}$을 $-\mathbf{q}_{1}$로 치환한 후 보간을 수행한다.

2.8 Quaternion and isoclinic rotations: explaining the magic

본 섹션에서는 다음 두 질문에 대한 답변을 제시한다. Joan Solà는 이를 마법(magic)이라고 부른다.

  • 왜 $\mathbf{q} \otimes \mathbf{x} \otimes \mathbf{q}^{*}$ 연산이 벡터 $\mathbf{x}$를 회전하는 공식이 되는가?
  • 왜 쿼터니언을 생성할 때 회전하고자 하는 각도의 절반의 각도를 입력해야 하는가? $\mathbf{q} = e^{\phi/2} = [\cos\phi/2, \mathbf{u}\sin\phi/2]?$

위 질문에 답을 하기 위해서는 대수적으로 단위 쿼터니언 곱이 벡터의 회전이라는 것을 증명한 (\ref{eq:30}) 이상의 기하학적인 설명이 필요하다. (\ref{eq:31})을 다시 보면 다음과 같다.
\begin{equation}
\mathbf{q} \otimes \mathbf{x} \otimes \mathbf{q}^{*} = [\mathbf{q}^{*}]_{R} [\mathbf{q}]_{L} \begin{bmatrix}
0 \\ \mathbf{x}
\end{bmatrix} = \begin{bmatrix}
0 \\ \mathbf{Rx}
\end{bmatrix}
\end{equation}

단위 쿼터니언 $\mathbf{q}$은 다음 두 성질을 만족한다.
\begin{equation}
\begin{aligned}
& [\mathbf{q}][\mathbf{q}]^{\intercal} = \mathbf{I}_{4} \\
& \det([\mathbf{q}]) = + 1
\end{aligned}
\end{equation}

이는 SO(4)의 성질과 동일하다. 즉, 단위 쿼터니언은 $\mathbb{R}^{4}$ 공간에서 회전행렬을 의미한다. 구체적으로 말하면, 단위 쿼터니언의 곱은 $\mathbb{R}^{4}$ 공간에서 등복각회전(isoclinic rotation)을 수행한다. 따라서 (\ref{eq:31})은 $\mathbb{R}^{4}$ 공간에서 $\mathbf{x}$가 2번의 등복각회전을 수행하는 것을 의미한다. 등복각회전을 이해하기 위해서는 우선 $\mathbb{R}^{4}$ 공간에서 일반적인 회전을 이해해야 한다.

다음은 양영욱님의 저서 수학으로 시작하는 3D 게임 개발에 회전 관련 챕터 내용을 주로 참고하여 작성하였다. 2차원 $\mathbb{R}^{2}$ 공간에서 회전은 점을 중심으로 회전한다. 그리고 3차원 $\mathbb{R}^{3}$ 공간에서 회전은 선을 중심으로 회전한다. 두 차원에서 회전의 공통점이 있다면 점들은 회전하면서 반드시 원을 그린다 사실이다. $\mathbb{R}^{2}$ 공간에서는 이러한 원들이 모두 한 평면 공간상에 존재하지만 $\mathbb{R}^{3}$ 공간에서는 서로 평행한 여러 평면에 존재한다.


어느 차원에서든 점이 회전하면 당연히 원이 그려지며 그 원이 존재하는 평면이 있게 된다. 따라서 회전을 점이나 선을 기준으로 하지 않고 특정 면을 기준으로 보면 차원과 상관없이 회전을 정의할 수 있으며 이러한 평면을 회전평면(rotation plane)이라고 부른다. 회전이 성립하려면 우선 2차원의 면이 존재해야하므로 1차원에서는 회전이 불가능함을 알 수 있다. $\mathbb{R}^{2}$ 공간에서는 2차원 회전평면을 제외하면 0차원 (2차원-2차원)이 남기 때문에 점을 중심으로 회전한다고 볼 수 있고 $\mathbb{R}^{3}$ 공간에서는 2차원 회전평면을 제외한 1차원 (3차원-2차원)이 남기 때문에 선을 중심으로 회전한다고 볼 수 있다. 따라서 이를 확장하면 $\mathbb{R}^{4}$ 공간에서는 2차원 회전평면을 제외하면 2차원 (4차원-2차원)이 남기 때문에 $\mathbb{R}^{4}$ 공간에서 회전은 면을 중심으로 회전한다는 것을 알수 있다.

하지만 우리는 $\mathbb{R}^{4}$ 공간에서 면을 중심으로 회전하는 것을 쉽게 생각할 수 없으므로 이를 2차원 면이 아닌 1차원의 회전축 2개를 중심으로 회전한다고 생각해볼 수 있다. 그렇다면 각각의 회전축과 수직을 이루는 회전평면 2개를 생각할 수 있다. 즉, $\mathbb{R}^{4}$ 공간에서 회전은 회전평면 $\pi_{A}, \pi_{B}$ 상에서 각각 $\alpha, \beta$ 각만큼 2개의 회전동시에 일어난다고 볼 수 있다. 이 때, $\pi_{A}, \pi_{B}$ 평면은 서로 직교(orthogonal)하며 이런 회전을 이중회전(double rotation)이라고 부른다. 만약 회전각 $\alpha, \beta$가 같다면 특별히 이를 등복각 회전(isoclinic rotation)이라고 부른다.


앞서 소개한 단위 쿼터니언 $\mathbf{q}$의 곱은 이러한 $\mathbb{R}^{4}$ 공간에서 등복각 회전을 의미하며 따라서 $\mathbf{q}$를 곱하는 것의 기하학적 의미는 $\mathbb{R}^{4}$ 공간에 존재하는 두 개의 회전평면 $\pi_{A}, \pi_{B}$에서 $\theta$만큼 동시에 두 회전이 일어나게 되는 것을 말한다. 흥미로운 점은 이러한 두 개의 회전평면 $\pi_{A}, \pi_{B}$ 중 하나의 회전평면은 쿼터니언의 벡터를 이루는 $i,j,k$축을 중심으로 회전하는 3차원 공간의 회전평면이라는 사실이다. 따라서 우리는 3차원 공간 상에서 순수 쿼터니언(pure quaternion)으로 변형된 벡터 $\mathbf{x}$가 회전하는 것을 원하므로 하나의 회전평면에서만 회전이 일어나게끔 해야한다.

등복각 회전에는 왼쪽 등복각(left-isoclinic) 회전과 오른쪽 등복각(right-isoclinic) 회전이 존재한다. 왼쪽 등복각 회전은 단위 쿼터니언을 왼쪽에서 곱했을 때 나타나고 오른쪽 등복각 회전은 오른쪽에서 곱했을 때 나타난다.
\begin{equation}
\begin{aligned}
& \mathbf{q} \otimes \mathbf{x} : \text{Left isoclinic rotation} \\
& \mathbf{x} \otimes \mathbf{q} : \text{Right isoclinic rotation}
\end{aligned}
\end{equation}

이 때, 두 회전의 곱셈은 교환법칙을 만족한다.
\begin{equation}
[\mathbf{q}]_{R}[\mathbf{q}]_{L} = [\mathbf{q}]_{L}[\mathbf{q}]_{R}
\end{equation}

i,j,k 축이 이루는 3차원의 회전평면을 $\pi_{A}$라고 하고 나머지 회전평면을 $\pi_{B}$라고 했을 때, 실제 벡터가 회전하려면 $\pi_{A}$에서만 회전이 일어나고 $\pi_{B}$에서는 회전이 발생하면 안된다. 왼쪽 등복각 회전은 $\pi_{A}$에서 반시계 방향 회전이 일어나고 $\pi_{B}$에서도 반시계 방향 회전이 일어나는 반면, 오른쪽 등복각 회전은 $\pi_{A}$에서 시계방향 회전이 일어나고 $\pi_{B}$에서 시계방향 회전이 일어난다. 즉, $\pi_{A}$는 단위 쿼터니언을 곱하는 방향에 따라 회전의 방향이 바뀌지만 $\pi_{B}$에서는 방향에 상관없이 항상 같은 방향의 회전이 일어난다. 따라서 단위 쿼터니언을 양쪽에 곱하면 $\pi_{A}$ 평면의 회전은 상쇄되어 없어지고 $\pi_{B}$ 평면 상의 회전만 반시계 방향으로 연달아 두 번 하는 것과 동일한 효과를 얻는다.



하지만 우리의 목적은 $\pi_{A}$에서만 회전이 일어나는 것을 원하므로 오른쪽 등복각 회전에 반대 방향의 단위 쿼터니언 $\mathbf{q}^{*}$을 곱해줌으로써 $\pi_{B}$ 평면의 회전을 상쇄시켜줌과 동시에 $\pi_{A}$에 $2\theta$만큼 회전을 수행할 수 있다. 이러한 기하학적 이유로 인해 단위 쿼터니언의 곱이 $\mathbf{q} \otimes \mathbf{x} \otimes \mathbf{q}^{*}$가 된다.
\begin{equation}
\begin{bmatrix}
0 \\ \mathbf{x}'
\end{bmatrix} = \mathbf{q} \otimes \mathbf{x} \otimes \mathbf{q}^{*} = [\mathbf{q}^{*}]_{R}[\mathbf{q}]_{L} \begin{bmatrix}
0 \\ \mathbf{x}
\end{bmatrix}
\end{equation}


단위 쿼터니언 곱은 하나의 동등한 $\mathbf{R}_{4}$ 행렬로 나타낼수 있다.
\begin{equation}
\mathbf{R}_{4} \triangleq [\mathbf{q}^{*}]_{R}[\mathbf{q}]_{L} = [\mathbf{q}]_{L}[\mathbf{q}^{*}]_{R} = \begin{bmatrix}
1 & \mathbf{0} \\ \mathbf{0} & \mathbf{R}
\end{bmatrix}
\end{equation}

이 때, $\mathbf{R}$는 $\mathbb{R}^{3}$ 공간에서 회전행렬을 의미하며 $\mathbf{R}_{4}$는 $\mathbb{R}^{4}$의 부분공간인 $\mathbb{R}^{3}$ 공간 내의 벡터를 회전시키는 행렬이 된다.

References

[1] Sola, Joan. "Quaternion kinematics for the error-state Kalman filter." arXiv preprint arXiv:1711.02508 (2017).