Changed rotate to output a 3x3 matrix.