Calculate transform matrices.