--- title: Change of Basis categories: 3D lecture --- **Reading** Ma 2004 Chapter 2.2-2.3 # Motion examples 1. Translation $$\vec{x}' = \vec{x}+\vec{t}$$ 1. Rotation $$\vec{x}' = \vec{x}\cdot R$$ - But note that $R$ is not an arbitrary matrix. - We'll return to the restrictions ![Handdrawn illustration](Images/motion.png) # Definition: Rigid Body Motion 1. 3D Object is a set of points in $\mathbb{R}^3$ 2. If the object moves, the constituent points move 3. The points have to move so that they preserve the shape of the object ## Constraints Let $\vec{X}(t)$ and $\vec{Y}(t)$ be the coordinates of points $\vec{x}$ and $\vec{x}$ at time $t$. 1. Preserve distance between points + $||\vec{X}(t)-\vec{Y}(t)||$ is constant 1. Preserve orientation + i.e. avoid mirroring + we have to preserve cross-products + If the right hand rule turns into a left hand rule, we have had mirroring. Let $u=\vec{X}-\vec{Y}$ be a vector, and $g_*(u)=g(\vec{X})-g(\vec{Y})$ the corresponding vector after motion. Preserving the cross-product means $$g_*(u)\times g_*(v) = g_*(u\times v), \forall u,v\in\mathbb{R}^3$$ # Change of Basis ## Bases 1. Basis aka. frame + Unit vectors: $\vec{e}_1$, $\vec{e}_2$, $\vec{e}_3$ 2. The meaning of a tuple to denote a vector + $\vec{x}=[x_1,x_2,x_3]= x_1\cdot\vec{e}_1+x_2\cdot\vec{e}_2+x_3\cdot\vec{e}_3$ 3. Orthonormal frame: orthogonal and unit length $$\vec{e}_i\vec{e}_j=\delta_{ij} = \begin{cases} 1 \quad\text{if } i=j\\ 0 \quad\text{if } i\neq j \end{cases} $$ ## Arbitrary Choice of Basis + Any set of three linearly independent vectors $\vec{u}_1$, $\vec{u}_2$, $\vec{u}_3$ can be used as a basis. + Usually, we prefer an orthonormal basis, i.e. - the basis vectors are orthogonal - the basis vectors have unit length $$ \langle\vec{u}_i, \vec{u}_j\rangle = \begin{cases} 1, \quad\text{when } i=j,\\ 0, \quad\text{when } i\neq j\end{cases}$$ + The basis is relative to a given Origin ## Local and Global Basis 1. 3D Scenes are built hierarchically 2. Each object is described in a local basis + and then placed in the global basis. 3. Why? + Save computational work + Local changes affect only local co-ordinates + Component motion independent of system motion ### Describing a Scene + Each object described in its own basis - independently of its position and orientation in the scene - *reusable* objects + Rotation and Deformation can be described locally + Transformation from local to global co-ordinates - Rotation of the basis - Translation of the origin + System of Systems - an object in the scene may itself be composed of multiple objects with different local frames ## Example E.g. our co-ordinates: 62°28'19.3"N 6°14'02.6"E Are these local or global co-ordinates? ## Rotation Consider **common origin** first. # Working with Different Bases ## Change of Basis + Point $\vec x$ represented in a basis $\vec{e}_1$, $\vec{e}_2$, $\vec{e}_3$ - i.e. $\vec x = x_1\vec{e}_1 + x_2\vec{e}_2 + x_3\vec{e}_3$ + Translate to a representation in another basis $\vec{u}_1$, $\vec{u}_2$, $\vec{u}_3$ + Suppose we can write the old basis in terms of the new one - $\vec{e_i} = e_{i,1}\vec{u}_1 + e_{i,2}\vec{u}_2 + e_{i,3}\vec{u}_3$ $$\begin{split} p = & x_1(e_{1,1}\vec{u}_1 + e_{1,2}\vec{u}_2 + e_{1,3}\vec{u}_3) + \\ & x_2(e_{2,1}\vec{u}_1 + e_{2,2}\vec{u}_2 + e_{2,3}\vec{u}_3) + \\ & x_3(e_{3,1}\vec{u}_1 + e_{3,2}\vec{u}_2 + e_{3,3}\vec{u}_3) \\ = &(x_1e_{1,1} + x_2e_{2,1} + x_3e_{2,1} )\vec{u}_1 + \\ &(x_1e_{1,2} + x_2e_{2,2} + x_3e_{2,2} )\vec{u}_2 + \\ &(x_1e_{1,3} + x_2e_{2,3} + x_3e_{2,3} )\vec{u}_3 \end{split}$$ Write $[x'_1, x'_2, x'_3]^\mathrm{T}$ for the coordinates in terms of the new basis. $$ x'_i = x_1e_{1,i} + x_2e_{2,i} + x_3e_{2,i} $$ ## Matrix form Still consider a point $p$ represented as + $[x_1, x_2, x_3]^\mathrm{T}$ in the basis $\vec{e}_1$, $\vec{e}_2$, $\vec{e}_3$ + $[x'_1, x'_2, x'_3]^\mathrm{T}$ in the basis $\vec{u}_1$, $\vec{u}_2$, $\vec{u}_3$ We found that $$\begin{bmatrix}x'_1 \\ x'_2 \\ x'_3\end{bmatrix} = \begin{bmatrix} e_{1,1} & e_{2,1} & e_{3,1} \\ e_{1,2} & e_{2,2} & e_{3,2} \\ e_{1,3} & e_{2,3} & e_{3,3} \end{bmatrix}\cdot \begin{bmatrix}x_1 \\ x_2 \\ x_3\end{bmatrix} = R\cdot \begin{bmatrix}x_1 \\ x_2 \\ x_3\end{bmatrix} $$ **Note** $R^\mathrm{T} = R^{-1}$ for an orthonormal basis $$\begin{bmatrix}x_1 \\ x_2 \\ x_3\end{bmatrix} = \begin{bmatrix} e_{1,1} & e_{1,2} & e_{1,3} \\ e_{2,1} & e_{2,2} & e_{2,3} \\ e_{3,1} & e_{3,2} & e_{3,3} \end{bmatrix}\cdot \begin{bmatrix}x'_1 \\ x'_2 \\ x'_3\end{bmatrix} = R^\mathrm{T}\cdot \begin{bmatrix}x'_1 \\ x'_2 \\ x'_3\end{bmatrix} $$ + Rows of $R$ define the $\vec{u}_i$ basis expressed in $\vec{e}_j$ + Columns of $R$ define the $\vec{e}_j$ basis expressed in $\vec{u}_i$ ## Rotation > Why is change of basis so important? + It also describes rotation of rigid bodies + Any orthonormal basis is a rotation of any other + The matrix $R$ defines the rotation ## Moving the Origin + A point is described relative to the origin $$\vec x = \vec{0} + x_1\cdot\vec{e}_1 + x_2\cdot\vec{e}_2 + x_3\cdot\vec{e}_3$$ + The origin is arbitrary + The local co-ordinate system is defined by 1. the basis $\vec{e}_1$, $\vec{e}_2$, $\vec{e}_3$ 2. the origin $\vec{0}$ **TODO** Complete # Demo **Use Python Here** ## Objects in 3D