## Basis

All objects have a frame of reference: an origin point and an orientation relative to that point. When we apply transforms, we apply them to the objects reference frame. We will represent an objects reference frame with basis vectors and a position vector. The basis vectors control the reference frame orientation. The canonical basis is the vector (1,1,1) with position (0,0,0). We will use basis vectors and positions to move to and from reference frames (or vector spaces for those that know the term).

### Position

The position vector can be used to move to and from a reference frame. For example, if a frame origin is at \( (2,3,4) \), then this matrix moves a point to the frame: $$ \begin{bmatrix} 1 & 0 & 0 & 2 \ 0 & 1 & 0 & 3 \ 0 & 0 & 1 & 4 \ 0 & 0 & 0 & 1 \ \end{bmatrix} $$ And this matrix moves from the frame to the canonical frame: $$ \begin{bmatrix} 1 & 0 & 0 & -2 \ 0 & 1 & 0 & -3 \ 0 & 0 & 1 & -4 \ 0 & 0 & 0 & 1 \ \end{bmatrix} $$

### Orientation

# The orientation of a frame is defined by basis vectors. A basis has one vector for each dimension. Our bases will have orthogonal and have unit length vectors. This is called an orthonormal basis. When describing bases, we will use the symbols \(u\), \(v\), and \(w\). These are the thumb, index, and middle fingers respectively (for right handed systems). For the canonical basis, we will say that \(u\) is long the x-axis going right, \(v\) is along the y-axis going up, and \(w\) is along the z-axis towards us. Here's an example basis matrix: $$ \mathbf{B} = \begin{bmatrix} \mathbf{u} & \mathbf{v} & \mathbf{w} \end{bmatrix}

\begin{bmatrix} u_x & v_x & w_x \ u_y & v_y & w_y \ u_z & v_z & w_z \ \end{bmatrix} $$

Basis vectors can be used to move points from one reference frame to another. Consider a basis that is the canonical basis, rotated about the z-axis by 90 degrees. In such a frame, the x-axis points along positive y, and the y-axis points along -x. $$ \mathbf{u} = \begin{bmatrix} 0 & 1 & 0 \end{bmatrix}^T \ \mathbf{v} = \begin{bmatrix} -1 & 0 & 0 \end{bmatrix}^T \ \mathbf{w} = \begin{bmatrix} 0 & 0 & 1 \end{bmatrix}^T $$ The basis matrix is then: $$ \mathbf{B} = \begin{bmatrix} 0 & -1 & 0 \ 1 & 0 & 0 \ 0 & 0 & 1 \end{bmatrix} $$ So, the point (1, 2, 3) becomes:

$$ \mathbf{q} = \mathbf{B p} = \begin{bmatrix} 0 & -1 & 0 \ 1 & 0 & 0 \ 0 & 0 & 1 \end{bmatrix}

# \begin{bmatrix} 1 \ 2 \ 3 \end{bmatrix}

\begin{bmatrix} -2 \ 1 \ 3 \end{bmatrix} $$

# Since we are using bases that are orthonormal, a basis inverse is the transpose of the basis matrix. Consider the transformed point from the previous example and the transposed basis matrix: $$ \mathbf{p} = \mathbf{B^T q} = \begin{bmatrix} 0 & 1 & 0 \ -1 & 0 & 0 \ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} -2 \ 1 \ 3 \end{bmatrix}

\begin{bmatrix} 1 \ 2 \ 3 \end{bmatrix} $$

Position and orientation can be combined using 4x4 homogeneous matrices.