## 3D Orientation§

• Rotation matrix
• 9 numbers to represent 3D orientation, i.e. upper-left 3x3 block of a 4x4 transformation matrix.
• Usually, all other orientation representations are converted into a rotation matrix.
• Fixed angles/Euler Angles/Yaw-Pitch-Roll
• 3 numbers can represent any 3D orientation
• TODO: Insert image.
• Euler’s rotation theorem
• Any rotation can be expressed as a single rotation about some axis
• 4 numbers to represent a 3D orientation
• Prone to gimbal lock.
• Quaternions
• Interpolation is easy using (S)LERP between begin and end quaternions.
• $i^2 = j^2 = k^2 = ijk = -1$
• $ij = k, jk = i, ki = j$
• $ji = k, kj = -i, ik = -j$ $$w + xi + yj + zl \iff (w, x, y, k) \iff (w, \vec{v})$$
• Quaternion algebra
• $q_0 = (w_0, \vec{v}_0), q_1 = (w_1, \vec{v}_1)$
• $q_1q_0 = (w_1w_0 - \vec{v}_1 \cdot \vec{v}_0, w_1\vec{v}_0 + w_0\vec{v}_1 + \vec{v}_1 \times \vec{v}_0)$
• $q_1 q_0 \neq q_0 q_1$
• Unit quaternions can be used to represent 3D rotations
• Let $w = \cos \left(\frac{1}{2}\theta\right)$ and $\vec{v} = \sin \left(\frac{1}{2}\theta\right)\hat{r}$

## Interpolation§

### LERP: Linear Interpolation§

\begin{align} \vec{q}(u) &= (1-u)\\ \hat{q}(u) &= \frac{\vec{q}(u)}{\|\vec{q}(u)\|_2} \end{align}

### SLERP: Spherical Linear Interpolation§

\begin{align} \hat{q}(u) &= \frac{\sin ((1 - u) \theta)}{\sin \theta} \hat{q}_0 + \frac{\sin (u \theta)}{\sin \theta}\hat{q}_1\\ \theta &= \arccos \left(\frac{\vec{q}_0 \cdot \vec{q}_1}{\|\vec{q}_0\|_2\,\|\vec{q}_1\|_2}\right) \end{align}

### LERP vs. SLERP§

• SLERP gives constant rotation speed
• LERP can interpolate between more than 2 quaternions
• $\vec{q}(\alpha, \beta, \gamma) = \alpha\hat{q}_0 + \beta\hat{q}_1 + \gamma\hat{q}_2$
• $\hat{q}(\alpha, \beta, \gamma) = \textrm{norm}(\vec{q})$
• LERP is easier to use with splines

### Long vs. Short Path§

When interpolating rotations with quaternions, there is a short and long way to get to the target rotation. For example, if we want to rotate right by 90 degrees, we can choose to add 90 degrees to our orientation or -270 degrees. We want to choose the short path to prevent any weird artifacts.

## Arc Length Parameterization§

Problem: Distance in world space is not the same as $u$, the distance along a parametric curve.

E.g. the distance $\|p(u)\|$ for $u \in [1, 1.1]$ is not necessarily the same as for $u \in [3, 3.1]$ even if the intervals both have length $0.1$.

Given 2 $u$ values, how can we compute the arc length between them?

$$$$S = \int_{u_0}^{u_1}\|\vec{p}\,’(u)\|_2\,\mathrm{d}u$$$$

Unfortunately, this intergral is intractable.

A crude approximation can be obtained by computing the following

$$$$S \approx \|\vec{p}(u_1) - \vec{p}(u_0)\|_2$$$$

and building a lookup table between $u$ and $s.$

• Both $u$ and $s$ are monotonically increasing
• We increase $u$ with constant $\Delta u$ (i.e. linearly)
• Note that $s$ does not respond linearly

Lookup Table Construction

$u \leftarrow 0$ $s \leftarrow 0$ insert $(u, s)$ while not done do:   $s \leftarrow s + \mathrm{arclength}(u, u \rightarrow \Delta u)$   $u \leftarrow u + \Delta u$   insert $(u, s)$

With this table we can perform lookups in either direction: $u \rightarrowtail s$ and $s \rightarrowtail u$.

Lookup Table

We’ll use the following lookup table for the next few examples.