Main Content

rotm2tform

Convert rotation matrix to homogeneous transformation

Description

example

tform = rotm2tform(rotm) converts the rotation matrix rotm into a homogeneous transformation matrix tform. The input rotation matrix must be in the premultiply form for rotations. When using the transformation matrix, premultiply it by the coordinates to be transformed (as opposed to postmultiplying).

Examples

collapse all

rotm = [1 0 0 ; 0 -1 0; 0 0 -1];
tform = rotm2tform(rotm)
tform = 4×4

     1     0     0     0
     0    -1     0     0
     0     0    -1     0
     0     0     0     1

Input Arguments

collapse all

Rotation matrix, specified as a 2-by-2-by-n or a 3-by-3-by-n array containing n rotation matrices. Each rotation matrix is either 2-by-2 or 3-by-3 and is orthonormal. The input rotation matrix must be in the premultiplied form for rotations.

Note

Rotation matrices that are not orthonormal can be normalized with the normalize function.

2-D rotation matrices are of this form:

R=[r11r12r21r22]

3-D rotation matrices are of this form:

R=[r11r12r13r11r22r23r31r32r33]

Example: [0 0 1; 0 1 0; -1 0 0]

Output Arguments

collapse all

Homogeneous transformation, returned as a 3-by-3-by-n array or 4-by-4-by-n array. n is the number of homogeneous transformations. When using the transformation matrix, premultiply it by the coordinates to be transformed (as opposed to postmultiplying).

2-D homogeneous transformation matrices are of this form:

T=[r11r12t1r21r22t2001]

3-D homogeneous transformation matrices are of this form:

T=[r11r12r13t1r21r22r23t2r31r32r33t30001]

Example: [0 0 1 0; 0 1 0 0; -1 0 0 0; 0 0 0 1]

More About

collapse all

2-D Homogeneous Transformation Matrix

2-D homogeneous transformation matrices consist of both an SO(2) rotation and an xy-translation.

To read more about SO(2) rotations, see the 2-D Orthonormal Rotation Matrix section of the so2 object.

The translation is along the x-, and y-axes as a two-element column vector:

t=[xy]

The SO(2) rotation matrix R is applied to the translation vector t to create the homogeneous translation matrix T. The rotation matrix is present in the upper-left of the transformation matrix as 2-by-2 submatrix, and the translation vector is present as a two-element vector in the last column.

T=[Rt01×21]=[I2t01×21]·[R001×21]

3-D Homogeneous Transformation Matrix

3-D homogeneous transformation matrices consist of both an SO(3) rotation and an xyz-translation.

To read more about SO(3) rotations, see the 3-D Orthonormal Rotation Matrix section of the so3 object.

The translation is along the x-, y-, and z-axes as a three-element column vector:

t=[xyz]

The SO(3) rotation matrix R is applied to the translation vector t to create the homogeneous translation matrix T. The rotation matrix is present in the upper-left of the transformation matrix as 3-by-3 submatrix, and the translation vector is present as a three-element vector in the last column.

T=[Rt01x31]=[I3t01x31]·[R001x31]

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2015a

expand all

See Also

| | | |