Rotation & Translation Matrix Transformations

J. O'Rourke

Mathematica tips:
Semicolon supresses output; no semicolon produces output.
To evaluate a "cell", click on its handle, and then Shift-Return
(or Evaluation/Evaluate Notebook).

To transform a point p by a matrix M, compute M.p, i.e., the point is to the right of the matrix.

A matrix in Mathematica is a list of lists.  So here is the 3x3 matrix that rotates by 45 deg (= Pi/4):

R={
{Cos[Pi/4],-Sin[Pi/4],0},
{Sin[Pi/4],Cos[Pi/4],0},
{0,0,1}
};
MatrixForm[R]

MatrixForm is a function that displays it nicely.

Now we see what this matrix does to the point {1,0}.  The conventions are that we use right-multiplication.

R.{1,0,1}

Now we make a 3x3 translation matrix, to translate by {1,0}:

T={{1,0,1},{0,1,0},{0,0,1}};
MatrixForm[T]

Now we see what this matrix does to the point {1,0}: it moves it rightward by 1.

T.{1,0,1}

It has the same effect on the origin:

T.{0,0,1}

See what R.T does to the point {0,0}, the origin: first it translates {0,0} to {1,0}, and then it rotates that.  

Note this is equivalent to the Postscript/OpenGL coordinate-change viewpoint of first rotating the coordinate system, and then translating in that rotated coordinate system.

R.T.{0,0,1}

See what T.R does to the point {0,0}, the origin: first it rotates {0,0} to give {0,0} again, and then translates that.

Or, in the Postscript/OpenGL coordinate-change viewpoint, it first translates the origin to {1,0}, and then spins the origin about the origin, which simply leaves it there.

T.R.{0,0,1}

The results of R.T and T.R are different.  Let's look at the matrix products:

MatrixForm[R.T]

MatrixForm[T.R]

The matrix products are different.