You are on page 1of 5

# 28/12/2013

## 3D Game Engine Programming

Helping you build your dream game engine.

## 3D Math Primer for Game Programmers (Matrices)

Posted on February 4, 2011 by Jeremiah van Oosten

The Matrix

In this article, I will discuss matrices and operations on matrices. It is assumed that the reader has some experience with Linear Algebra, vectors, operations on vectors, and a basic understanding of matrices. Conventions Throughout this article, I will use a convention when referring to vectors, scalars, and matrices. 1. Scalars are represented by lower-case italic characters ( 2. Vectors are represented by lower-case bold characters ( 3. Matrices are represented by upper-case bold characters (
3dgep.com/?p=259

). ) )
1/5

28/12/2013

## 3D Math Primer for Game Programmers (Matrices) | 3D Game Engine Programming

Linear Transformation A linear transformation is defined as a transformation between two vector spaces denoted That is, 1. 2. for any scalar for any vectors and and

and must preserve the operations of vector addition and scalar multiplication.

This property also implies that any linear transformation will transform the zero vector into the zero vector. Since a non-zero translation will transform the zero vector into a non-zero vector then any transformation that translates a vector is not a linear transformation. A few examples of linear transformations of three-dimensional space Rotation A linear transformation that rotates a vector space about the axis: are:

axis:

axis:

by an angle :

3dgep.com/?p=259

2/5

28/12/2013

## A linear transformation that scales by a factor

in an arbitrary direction

Affine Transformation An affine transformation is a linear transformation followed by a translation. Any linear transformation is an affine transformation with a translation of , but not all affine transformations are linear transformations. The set of affine transformations is a superset of linear transformations. Types of affine transformations are scale, shear, rotation, reflection, and translation. Any combination of affine transformation results in an affine transformation. Any transformation in the form transformed vector, translation vector. Determinant of a Matrix For every square matrix, you can calculate a special scalar value called the determinant of the matrix. If the determinant is not , then the matrix is invertible and we can use the determinant to calculate the inverse of that matrix. is the original vector, is an affine transformation where is a linear transform matrix, and is the is a

is denoted

or

## . matrix, lets first

Before we discuss how to calculate the determinant of a larger discuss the determinant of a matrix:

3dgep.com/?p=259

3/5

28/12/2013

## 3D Math Primer for Game Programmers (Matrices) | 3D Game Engine Programming

You can use the following diagram to help you remember the order in which the terms should be placed:

In this diagram, we see the arrows passing through the diagonal terms. We simply multiply the operands on the diagonal terms and we subtract the result of the back diagonal term from the result of the front diagonal term.
Like 6

## You may also like:

Understanding Quaternions

## Rendering Primitives with OpenGL

This entry was posted in Graphics Programming, Math, Programming and tagged 3D, affine , determinant, game , games, inverse , linear, math, matrices, matrix , orthogonal, primer, Programming, rotation, scale , transformation, translate , translation by Jeremiah van Oosten. Bookmark the permalink [http://3dgep.com/? p=259] .
3dgep.com/?p=259 4/5

28/12/2013

## Greg Ruthenbeck on March 15, 2012 at 2:49 am said:

Nice article. A good detailed intro to 3D matrix math relevant to 3D graphics/games. However, can I suggest a correction: Youve referred to determinate of a matrix where it should read determinant. I.e. det(M) refers to the determinant not determinate of a matrix.

## Jeremiah van Oosten on March 15, 2012 at 9:56 am said:

Greg, Thanks for pointing this out. Spelling was never my strong point!

3dgep.com/?p=259

5/5