# Conversions between common orientation representations

This article presents equations for conversion between orientation representations common for robots. For more information on the pose representations check out Position, Orientation and Coordinate Transformations.

## Roll-Pitch-Yaw to Rotation Matrix

Roll-Pitch-Yaw is a common term to denote an orientation. Each represents an angle of rotation around a single axis, combined they represent a complete rotation. However, they are not explicit in terms of exactly what they represent. They are subject to the following confusions:

• Which axis does each rotate about?
• Are these axes fixed, or moving?
• In which order is the rotation defined? (There are multiple possibilities)

What follows are two different examples.

For x-y-z order of rotations about fixed axes (extrinsic rotations) or z-y'-x'' about moving axes (intrinsic rotations), Roll , Pitch , and Yaw angles can be converted to a rotation matrix as follows:

 (1) For z-y-x order of rotations about fixed axes (extrinsic rotations) or x-y'-z'' about moving axes (intrinsic rotations), Roll , Pitch , and Yaw angles can be converted to a rotation matrix as follows:

 (2) Note

If one assumes that the angles are the same in the two examples, then they do not represent the same final rotation matrix.

If one assumes that the final rotation matrixes are the same, then the angles are not identical between the two examples.

A definition is introduced: Roll angle is assigned to the first rotation about moving axes, Pitch is the second and Yaw is the third.

## Rotation Vector to Axis-Angle

A rotation vector can be converted to axis and angle as follows:  ## Axis-Angle to Quaternion

Axis and angle can be converted to a unit quaternion as follows: ## Quaternion to Rotation Matrix

A unit quaternion can be converted to a rotation matrix as follows: It is assumed that the quaternion is normalized . If not, it should be normalized before doing the conversion using this equation:  ## Rotation Matrix to Quaternion

A rotation matrix can be converted to a unit quaternion as follows:  ## Quaternion to Axis-Angle

A unit quaternion can be converted to axis and angle as follows:  ## Axis-Angle to Rotation Vector

Axis and angle can be converted to a rotation vector as follows: ## Rotation Matrix to Roll-Pitch-Yaw

Determining roll, pitch, yaw angles from a rotation matrix is not straightforward. There can be multiple and sometimes even infinite solutions. This requires an algorithm that can choose one of the multiple solutions based on some criteria.