fix the transformation matrix calculation