# Change Of Coordinate Transformations

Change of Coordinate Transformations
An example of various coordinate transformations applied to simple geometry.

# Basic Description

A Change Of Coordinate Transformation is a transformation that converts coordinates from one coordinate system to another coordinate system. Transformations such as scaling, rotating, and translating are usually looked upon as changing or manipulating the geometry itself. However, with change of coordinate transformations, it is important to realize that the coordinate representation of the geometry is modified, rather than the geometry itself.

The Change of Coordinate Systems in general is also common for converting coordinates from system to another, such as from Cartesian coordinates to Cylindrical coordinates.

# A More Mathematical Explanation

Note: understanding of this explanation requires: *Linear Algebra

Change of coordinate transformations are different for vectors and points.

### Vectors

[...]

Change of coordinate transformations are different for vectors and points.

### Vectors

Transformation of vector $\boldsymbol{\vec{p}}$ from coordinate system A to coordinate system B.
Consider a coordinate system A, and a vector $\boldsymbol{\vec{p}}$. The coordinates of $\boldsymbol{\vec{p}}$ relative to coordinate system A is $\boldsymbol{\vec{p}}_A = (x, y)$. It is also apparent that
$\boldsymbol{\vec{p}} = x\boldsymbol{\hat{u}} + y\boldsymbol{\hat{v}}$
In which $\boldsymbol{\hat{u}}$ and $\boldsymbol{\hat{v}}$ are unit vectors along the x and y-axes of coordinate system A. Now consider a second coordinate system, B. In coordinate system B,
$\boldsymbol{\vec{p}}_B = x\boldsymbol{\hat{u}}_B + y\boldsymbol{\hat{v}}_B$
More generally, given $\boldsymbol{\vec{p}}_A = (x, y)$ along with $\boldsymbol{\hat{u}}$ and $\boldsymbol{\hat{v}}$, $\boldsymbol{\vec{p}}_B = (x', y')$ may be found using the formula above.
In 3-dimensional space, given $\boldsymbol{\vec{p}}_A = (x, y, z)$ then
$\boldsymbol{\vec{p}}_B = x\boldsymbol{\hat{u}}_B + y\boldsymbol{\hat{v}}_B + z\boldsymbol{\hat{w}}_B$
In which $\boldsymbol{\hat{u}}$, $\boldsymbol{\hat{v}}$, and $\boldsymbol{\hat{w}}$ are unit vectors along the x, y, and z-axes of coordinate system A.
Given:
$\boldsymbol{\vec{p}}_A = \begin{bmatrix} 5 & 7 & 13 \end{bmatrix}$, $\boldsymbol{\hat{u}}_B = \begin{bmatrix} 0 & 0 & 1 \end{bmatrix}$, $\boldsymbol{\hat{v}}_B = \begin{bmatrix} 1 & 0 & 0 \end{bmatrix}$, and $\boldsymbol{\hat{w}}_B = \begin{bmatrix} 0 & 0 & 0 \end{bmatrix}$
Then:
$\boldsymbol{\vec{p}}_B = \begin{bmatrix} 5 & 7 & 0 \end{bmatrix}$
Explanation:
The formula, $\boldsymbol{\vec{p}}_B = x\boldsymbol{\hat{u}}_B + y\boldsymbol{\hat{v}}_B + z\boldsymbol{\hat{w}}_B$, was used for the change of coordinate transformation. The dot product of 5 and $\boldsymbol{\hat{u}}_B$ is 5, and the dot product of 7 and $\boldsymbol{\hat{v}}_B$ is 7. Since $\boldsymbol{\hat{w}}_B$ a zero vector, the dot product of 13 and $\boldsymbol{\hat{w}}_B$ is 0.

### Points

Transformation of point$\boldsymbol{q}$ from coordinate system A to coordinate system B.
Consider a coordinate system A, and a point $\boldsymbol{q}$. Point $\boldsymbol{q}$ may be expressed as:
$\boldsymbol{q} = x\boldsymbol{\hat{u}} + y\boldsymbol{\hat{v}} + \boldsymbol{O}$
In which $\boldsymbol{\hat{u}}$ and $\boldsymbol{\hat{v}}$ are unit vectors along the x and y-axes of coordinate system A, and $\boldsymbol{O}$ is the origin of coordinate system A. Now consider a second coordinate system, B. In coordinate system B,
$\boldsymbol{q}_B = x\boldsymbol{\hat{u}}_B + y\boldsymbol{\hat{v}}_B + \boldsymbol{O}_B$
More generally, given $\boldsymbol{q}_A = (x, y)$ along with $\boldsymbol{\hat{u}}$, $\boldsymbol{\hat{v}}$, and $\boldsymbol{O}$ relative to coordinate system B, then $\boldsymbol{q}_B = (x', y')$ may be found using the above formula.
In 3-dimensional space, given $\boldsymbol{q}_A = (x, y, z)$ then
$\boldsymbol{q}_B = x\boldsymbol{\hat{u}}_B + y\boldsymbol{\hat{v}}_B + z\boldsymbol{\hat{w}}_B + \boldsymbol{O}_B$
In which $\boldsymbol{\hat{u}}$, $\boldsymbol{\hat{v}}$, and $\boldsymbol{\hat{w}}$ are unit vectors along the x, y, and z-axes of coordinate system A, and $\boldsymbol{O}$ is the origin of coordinate system A.
Given:
$\boldsymbol{q}_A = \begin{bmatrix} 6 & 4 & 21\end{bmatrix}$, $\boldsymbol{\hat{u}}_B = \begin{bmatrix} 0 & 1 & 0 \end{bmatrix}$, $\boldsymbol{\hat{v}}_B = \begin{bmatrix} 0 & 0 & 1 \end{bmatrix}$, $\boldsymbol{\hat{w}}_B = \begin{bmatrix} 1 & 0 & 0 \end{bmatrix}$, and $\boldsymbol{O}_B = 17$
Then:
$\boldsymbol{q}_B = \begin{bmatrix} 23 & 21 & 38 \end{bmatrix}$
Explanation:
The formula, $\boldsymbol{q}_B = x\boldsymbol{\hat{u}}_B + y\boldsymbol{\hat{v}}_B + z\boldsymbol{\hat{w}}_B + \boldsymbol{O}_B$, was used for the change of coordinate transformation. The dot product of 6 and $\boldsymbol{\hat{u}}_B$ is 6, the dot product of 4 and $\boldsymbol{\hat{v}}_B$ is 4, and the dot product of 21 and $\boldsymbol{\hat{w}}_B$ is 21. $\boldsymbol{O}_B$, or 17, is then added to the resulting vector.

### Matrix Representation

The change of coordinate transformation varies for points and vectors and thus results in two different equations. However, by using homogeneous coordinates, both cases may be handled with the following equation:
$(x', y', z', w) = x\boldsymbol{u}_B + y\boldsymbol{v}_B + z\boldsymbol{w}_B + w\boldsymbol{O}_B$
When $w = 1$, the equation handles the change of coordinate transformation for points; when $w = 0$, the equation handles the transformation for vectors. As long as the $w$-coordinate is set correctly, there is no need to keep track of two different equations. Thus the change of coordinate matrix may be defined as:
$\begin{bmatrix} x' & y' & z' & w \end{bmatrix} = \begin{bmatrix} x & y & z & w \end{bmatrix} \begin{bmatrix} u_x & u_y & u_z & 0 \\ v_x & v_y & v_z & 0 \\ w_x & w_y & w_z & 0 \\ O_x & O_y & O_z & 1 \\ \end{bmatrix} = x\boldsymbol{\hat{u}}_B + y\boldsymbol{\hat{v}}_B + z\boldsymbol{\hat{w}}_B + w\boldsymbol{O}_B$

# References

Luna, Frank D. Introduction to 3D game programming with DirectX 10. Plano, Tex: Wordware Pub., Inc., 2008. Print.