Last Updated September 28, 2011
We have used column and row matrices to represent points and vectors;
\[ \vec{a}= \left(\begin{array}{c} x \\ y \\ z \end{array} \right) \]
\[ \vec{p}= \left(\begin{array}{ccc} 23&45&3 \end{array} \right) \]
There is another kind of matrix called a square matrix which we will be using to apply operations to vectors and points. A square matrix is a 2x2 or 3x3 or 4x4 matrix, made up of rows and columns;
The elements of a matrix are usually numbers. The numbers of rows and columns of a matrix are called its dimensions. the name for a matrix is usually a capital letter in bold face, like A or M.
Two matrices are equal if the have the same dimensions and the coresponding elements are the same;
Two matrices of the same dimensions can be added by adding the corresponding elements;
A matrix can be multiplied by a real number (scalar) by multiplying all the elements by the scalar;
What is the negative of a matrix?
What happens if you add a matrix to its negative?
Two matrices of the same dimensions can be added by adding the corresponding elements;
The Transpose of a matrix, is a new matrix whose rows are the columns of the original.
What happens if you transpose twice?
A square matrix can multiply a column matrix if the number of columns in the square matrix is the same as the number of rows in the column matrix. For instance, a 3x3 matrix can multiply a 3 element column matrix. But a 4x4 matrix cannot multiply a 3 element column matrix.
The elements in the new matrix are the dot product of each row of the square matrix and the column matrix. The result of the multiplication is a new column matrix.
A square matrix cannot multiply a row matrix.
A row matrix can multiply a square matrix iff the number of columns in the row matrix is the same as the number of rows in the square matrix.
Again, the elements are the dot product of the row in the first matrix and the columns of the second;
Two square matrices can be multiplied if they are the same size. The result is a square matrix. The multiplication is performed by getting the dot product of the rows of the first matrix with the columns of the second.
The real number contain a special number called the identity ($i=1$) such that for any real number x;
Matrix multiplication also has an identity (I); such that for any square matrix M
For a 3x3 matrix $ I=\left(\begin{array}{ccccc} 1&0& 0 \\ 0& 1 & 0 \\ 0 & 0 & 1\end{array} \right)$
Real numbers also have an inverse, such that
Most square matrices also have an inverse such that;
Finding the inverse of 3x3 and 4x4 matrices is difficult to do by hand. But the existence of matrix inverses makes algebreaic manipulation possible.
In computer graphics models (object that we want to view) defined in terms of a collection of vertices. The best way to manipulate these vertices is to use transformation transformations to move, strech and rotate them.
These changes can be achieved by applying an affine transformation matrix to the vertices of the polygon mesh. Geometrically, an affine transformation in Euclidean space is one that preserves
In general, an affine transformation is composed of linear transformations (rotation, scaling or shear) and a translation (or "shift"). Several linear transformations can be combined into a single one, so that the general formula given above is still applicable.
These transformations are implemented by multiplying the appropriate vertex by a matrix representing the transformation.
2D transfomations applet (http://www.cs.princeton.edu/%7Emin/cs426/jar/transform.html)
To scale a mesh (stretch along x-axis). Apply the following to each point;
\[ \left(\begin{array}{ccccc} s & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{array} \right)\left(\begin{array}{ccccc}x \\ y \\ z \end{array} \right)= \left(\begin{array}{ccccc}s.x\\y\\z \end{array} \right) \]
In this case, x component of each point has been multiplied by s.
This scaling matrix can be generalised as;
\[ \left( \begin{array}{ccc}sx&0&0\\0&sy&0\\0&0&sz\end{array}\right) \]
Where $sx$ , $sy$ and $sz$ are scaling factors along the x-axis, y-axis and z-axis respectively.
Beware when scaling objects which are not positioned at the origin.
To rotate a point $\theta$ degrees about the z-axis, multiply the point by the following matrix;
\[ R_{z\theta} = \left(\begin{array}{ccccc} \cos \theta & -\sin \theta & 0 \\ \sin \theta & \cos \theta & 0 \\ 0 & 0 & 1 \end{array} \right) \]
For rotations about the x-axis and y-axis, apply the following;
\[ R_{x\theta} = \left(\begin{array}{ccccc} 1 & 0 & 0 \\ 0 & \cos \theta & -\sin \theta \\ 0 & \sin \theta & \cos \theta \\ \end{array} \right)\qquad R_{y\theta} = \left(\begin{array}{ccccc} \cos \theta & 0 & \sin \theta \\ 0 & 1 & 0\\ -\sin \theta & 0 & \cos \theta \\ \end{array} \right) \]
\[ \left(\begin{array}{ccccc}x&y&z \end{array} \right)+\left(\begin{array}{ccccc}dx&dy&dz \end{array} \right)= \left(\begin{array}{ccccc}x+dx & y+dy & z+dz \end{array} \right) \]
\[ \left(\begin{array}{ccccc}x&y&z \end{array} \right)\quad \rightarrow \quad \left(\begin{array}{ccccc}x&y&z&1 \end{array} \right) \]
to convert a matrix to homogeneous co-ordinates add an extra row and an extra column;
\[ \left(\begin{array}{ccccc}a&b&c\\d&e&f\\h&i&j \end{array} \right)\quad \rightarrow \quad \left(\begin{array}{ccccc} a&b&c&0\\d&e&f&0\\h&i&j&0\\0&0&0&1 \end{array} \right) \]
Using the homogeneous matrix, translation can be implemented by matrix multiplication;
\[ \left(\begin{array}{ccccc}1&0&0&dx \\0&1&0&dy \\0&0&1&dz \\0&0&0&1 \end{array}\right) \left(\begin{array}{ccccc}x\\y\\z\\1 \end{array} \right) = \left(\begin{array}{ccccc}x+dx \\ y+dy \\ z+dz \\ 1\end{array} \right) \]
This representation simplifies calculation in computer graphics as all necessary transformations can be performed by matrix multiplications. As a result, a series of affine transformations can be combined simply by multiplying successive matrices together. This is at the heart of real-time graphics systems such as OpenGL and DirectX which can use modern graphics cards to perform operations with homogeneous coordinates.
© Ken Power 1996-2016