# Lecture_005_3D_Rotation_and_Complex_Representations

2D rotation commute, but 3D rotation does not.

## Imaginary Unit and Complex Number

Note: I think $\imath = \sqrt{-1}$ is a bull shit since it is not normal algebra. This relation only exists if we defined Complex Multiplication. Solve $z$ in $z^2 = \imath$

Complex Number: 2D vectors with basis $(1, \imath)$, but instead of using parenthesis, we write it as $a + b \imath$

• it behaves identical as 2D vector except for an additional operation called Complex Multiplication

Complex Multiplication ($*$): a new operation just like vector dot product and cross product we defined.

• magnitudes multiply

Note: Complex Multiplication $A * B$ behaves like linear transformation where $A = a + a_i\imath = \langle{a, a_i}\rangle, B = b + b_i\imath = \langle{b, b_i}\rangle$. Think $A$ as the transformation where the vector $\langle{a, a_i}\rangle$ is where $\hat{i}$ lands and $\hat{j}$ remain in relation to $\hat{i}$. (Rotation only)

\begin{align*} z_1 &= (a + b \imath)\\ z_2 &= (c + d \imath)\\ z_1z_2 &= ac + ad\imath + bc\imath + bd\imath^2\\ &= (ac - bd) + (ad + bc)\imath\\ \end{align*}

In above example:

• Real Part: $\text{Re}(z_1z_2) = (ac - bd)$

• Imaginary Part: $\text{Im}(z_1z_2) = (ad + bc)$

Complex Division: reverse Complex Multiplication

Complex Power: multiple Complex Multiplication

Euler's Formula: $e^{\imath \theta} = \cos \theta + \imath \sin \theta$ (this is a mapping from an angle $\theta$ to a unit vector in 2D plane)

• We implement using Euler's Formula: $z_1 = r_1e^{t\theta_1}, z_2 = r_2e^{t\theta_2}$

• Then: $z_1z_2 = r_1r_2e^{\imath(\theta_1 + \theta_2)} = r_1r_2(\cos(\theta_1 + \theta_2) + \imath \sin(\theta_1 + \theta_2))$

• Therefore: we see complex operation preserves invariants of Complex Multiplication

// QUESTION: prove (a + bi)*(c + di) = whatever your result is using definition

// QUESTION: how is high dimensional complex number relate to quaternion

It gives us a easy way calculate $\cos(75 \deg)$

\begin{align*} \cos(75 \deg) &= \cos(45 \deg + 30 \deg)\\ &=(\cos(45 \deg) + \sin(45 \deg)\imath) * (\cos(30 \deg) + \sin(30 \deg)\imath)\\ &=(\frac{\sqrt{2}}{2} + \frac{\sqrt{2}}{2})\imath * (\frac{\sqrt{3}}{2} + \frac{1}{2}\imath)\\ &=\frac{\sqrt{6} - \sqrt{2}}{4}\\ \end{align*}

## Quaternions

Definition: $i^2 = j^2 = k^2 = ijk = -1$

• $ij = -ji = k$

• $jk = -kj = i$

• $ki = -ik = j$

Hamilton Space: $\mathbb{H} := \text{span}(\{1, \imath, \jmath, k\})$

• Complex Product not Commutative: $pq \neq qp$

• This is because rotation not commutative.

• Quaternion is a point in Hamilton Space

Interactive Video Explaining Quaternions

We can simplify above equation by viewing the real part as a scalar and the imagenary part as a vector (dot products and cross products).

Quaternion Multiplication in Vector Form:

(a, \overrightarrow{u})*(b, \overrightarrow{v}) = (ab - \overrightarrow{u} \cdot \overrightarrow{v}, a \overrightarrow{v} + b \overrightarrow{u} + \overrightarrow{u} \times \overrightarrow{v})

When the quaternions comes from $\mathbb{R}^3$ (ie $a = b = 0$), then we can simplify $(0, \overrightarrow{u})*(0, \overrightarrow{v}) = \overrightarrow{u}*\overrightarrow{v} = \overrightarrow{u} \times \overrightarrow{v} - \overrightarrow{u} \cdot \overrightarrow{v}$

### Express Rotation with Quaternions

We first write vectors $v \in \mathbb{R}^3$ as the imagenary part of a quaternion $x \in \text{Im}(\mathbb{H})$ with zero real part.

Unit Quaternion: $q \in \mathbb{H} | \|q\| = 1$

Complex Reflection: let $q = a + b\imath + c\jmath + dk$, then $\bar{q} = a - b\imath - c\jmath - dk$

Rotation Expression: $\bar{q}xq$ express some rotation along an axis. $q = \cos(\theta / 2) + \sin(\theta / 2)\overrightarrow{u}$

• where $\theta$ is the angle

• were $\overrightarrow{u}$ is the rotational axis

### Rotation Interpolation

Slerp: spherical linear Interpolation

\text{Slerp}(q_0, q_1, t) = q_0(q_0^{-1}q_1)^t, t \in [0, 1]

## Axis Angle Rotation

Represent 3D rotation using a rotational axis. That's it.

Table of Content