Introduction to Graphics Math

Translation Matrix

A: (, 1.0)
B: (, 0.0)
C: (, 1.0)
D: (, 0.0)

x: (1.0,0.0, 0.0)
y: (0.0,1.0, 0.0)

T: (0.0,0.0, 1.0)

So far we haven't differentiated between a point and a direction. When it comes to translating them in space, we have to make a distinction. Points can be moved around in space and their coordinates change, whereas a direction can be anywhere in space and will still be pointed in the same direction and still have the same values. In this example, B is displayed relative to A. At the origin, you'll see B is also displayed in gray. They're both the same vector. Once we start translating vectors, we want to make sure that directions aren't changed, but points are. To do that we need to add an extra element to our vectors. The added element is a weight that we'll indicate with the subscript w: \[\textbf{A}=(A_x, A_y, A_w)\] \[\textbf{B}=(B_x, B_y, B_w)\] \[\textbf{x}=(x_x, x_y, x_w)\] \[\textbf{y}=(y_x, y_y, y_w)\] The added weight is a divisor for each of the other components. Our vectors now represent homogeneous coordinates, rather than conventional coordinates. To convert from homogeneous coordinates to conventional coordinates, divide the weight into each of the other components and drop the weight: \[(A_x, A_y, A_w) = (\frac{A_x}{A_w}, \frac{A_y}{A_w})\] The weight has applications such as in curve representations, but we won't get into that here. For more information search for homogeneous coordinates. For our purposes, the weight will be either 1 or 0. When set to 0, the homogeneous coordinate represents a point at infinity, which represents a direction. When set to 1, the homogeneous coordinate represents a point in space. In this example, A is a point, B is a direction, x is a direction and y is a direction: \[\textbf{A}=(A_x,A_y,1)\] \[\textbf{B}=(B_x,B_y,0)\] \[\textbf{x}=(x_x,x_y,0)\] \[\textbf{y}=(y_x,y_y,0)\] In order to perform translations, we'll need another vector T which will be a point in space: \[\textbf{T}=(T_x,T_y,1)\] And now we have enough information to put it all into a translation matrix: \[\begin{bmatrix}\textbf{x} \\ \textbf{y} \\ \textbf{T}\end{bmatrix}=\begin{bmatrix}1 & 0 & 0 \\ 0 & 1 & 0 \\ T_x & T_y & 1\end{bmatrix}\] We'll use it to transform A to C and B to D: \[\textbf{C}=\textbf{A} \cdot \begin{bmatrix}\textbf{x} \\ \textbf{y} \\ \textbf{T}\end{bmatrix}=A_x \textbf{x} + A_y \textbf{y} + A_w \textbf{T}\] \[=-3.0 \cdot (1.0, 0.0, 0.0) + 1.0 \cdot (0.0, 1.0, 0.0) + 1.0 \cdot (0.0,0.0,1.0)\] \[=\underline{\underline{(-3.0, 1.0, 1.0)}}\] \[\textbf{D}=\textbf{B} \cdot \begin{bmatrix}\textbf{x} \\ \textbf{y} \\ \textbf{T}\end{bmatrix}=B_x \textbf{x} + B_y \textbf{y} + B_w \textbf{T}\] \[=1.0 \cdot (1.0, 0.0, 0.0) + 1.0 \cdot (0.0, 1.0, 0.0) + 0.0 \cdot (0.0,0.0,1.0)\] \[=\underline{\underline{(1.0, 1.0,0.0)}}\]