Performing rotation using a rotation matrix