Added rotation matrix calculation.