# Position, Orientation and Coordinate Transformations

Coordinate frames are attached to rigid bodies to represent the relative pose (position and orientation) between the rigid bodies. The geometric relationship between these two coordinate frames is then specified.

## Position

The position of the origin of one frame with respect to another frame can be described with a translation vector (3x1):

## Orientation

The orientation of one coordinate frame relative to another frame can be described with a rotation matrix (3x3):

## Pose

A homogeneous transformation matrix (4x4) simultaneously represents position and orientation of one coordinate frame relative to another coordinate frame:

## Roll-Pitch-Yaw

A rigid body possesses at most three rotational degrees of freedom. In other words, only three independent quantities are sufficient to describe an arbitrary rigid body orientation. One such minimal representation of orientation is the roll-pitch-yaw representation, defined by roll (\(\phi\)), pitch (\(\theta\)), and yaw (\(\psi\)) angles:

The advantage of roll-pitch-yaw representation is that it requires only three values. These values are also geometrically easy to understand compared to other representations. The disadvantages are:

The values are not continuous.

The final orientation depends on:

The order of applying the rotations.

Applying rotations about moving axes (intrinsic rotations) or fixed axes (extrinsic rotations).

The roll-pitch-yaw representation is common among robot vendors. However, not all robot vendors assume the same convention. Understanding the convention, i.e., the order of rotations and whether they are intrinsic or extrinsic is necessary to convert roll-pitch-yaw angles to other representations.

## Axis-Angle / Rotation Vector

Axis-angle representation describes the following:

A rotation by a unit vector (\(\boldsymbol{u}\)) indicating the axis of rotation direction.

An angle (\(\theta\)) describing the magnitude of rotation about the axis.

There are four parameters in total. Multiplying each element of the unit vector with the angle is a common method to minimize the number of parameters, the result of which is the rotation vector (\(\boldsymbol{r}\)):

The advantage of the axis-angle representation over roll-pitch-yaw angles is that it is free from continuity and rotational sequence issues. However, it is hard to match the physical orientation and the numerical values of the rotation vector. Another disadvantage is that it is impossible to apply the rotation directly on a 3D point; this requires conversion to a different representation.

## Unit Quaternion

Unit quaternions represent a simple but robust method to encode the axis-angle representation with four parameters.

Unit quaternions are considered the best method of representing orientation between two coordinate frames because they are more compact, more numerically stable, and more efficient than rotation matrices. Compared to roll-pitch-yaw representation, unit quaternions do not suffer from gimbal lock (impossibility to represent orientation uniquely). Also, unlike axis-angle representation, it is possible to apply unit quaternions directly to 3D points.

Note

Check out Conversions Between Common Orientation Representations

## Coordinate Transformations

Any coordinate transformation of a rigid body in 3D can be described with a rotation and a translation. For example, it is possible to transform a point (or a point cloud) from one coordinate frame (\(b\)) to another coordinate frame (\(a\)). This can be performed with a rotation matrix and a translation vector:

The same can be done with a homogeneous transformation matrix describing the pose between the two frames:

where \(\widetilde{p}^{a}\) and \(\widetilde{p}^{b}\) are homogeneous representations of the vectors \(p^{a}\) and \(p^{b}\), respectively.

The homogeneous transformation matrix \(\boldsymbol{H}^{a}_{b}\) in the above equation represents:

the operation that transforms a point \(p^{b}\) in frame \(b\) to a point \(p^{a}\) in frame \(a\) (coordinate transformation matrix)

the operation that expresses a point \(p^{b}\) defined relative to frame \(b\) as it would be defined relative to frame \(a\) (coordinate transformation matrix)

the pose (position and orientation) of frame \(b\) with respect to frame \(a\)

the transform (position and orientation) from frame \(a\) to frame \(b\) expressed as a homogenous transformation matrix

In code samples, we use the following notation for this transformation matrix: `a_to_b_transform`

or `b_pose_in_a_frame`

.