Transformation matrix implementation