Main Content

tform2rotm

Extract rotation matrix from homogeneous transformation

Description

rotm = tform2rotm(tform) extracts the rotational component from a homogeneous transformation, tform, and returns it as an orthonormal rotation matrix, rotm. The translational components of tform are ignored. The input homogeneous transformation must be in the pre-multiply form for transformations. When using the rotation matrix, premultiply it with the coordinates to be rotated (as opposed to postmultiplying).

example

Examples

collapse all

tform = [1 0 0 0; 0 -1 0 0; 0 0 -1 0; 0 0 0 1];
rotm = tform2rotm(tform)
rotm = 3×3

     1     0     0
     0    -1     0
     0     0    -1

Input Arguments

collapse all

Homogeneous transformation, specified as a 3-by-3-by-n array or 4-by-4-by-n array. n is the number of homogeneous transformations. The input homogeneous transformation must be in the premultiplied form for transformations.

2-D homogeneous transformation matrices are of the form:

T=[r11r12t1r21r22t2001]

3-D homogeneous transformation matrices are of the form:

T=[r11r12r13t1r21r22r23t2r31r32r33t30001]

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

Output Arguments

collapse all

Rotation matrix, returned as a 2-by-2-n array or 3-by-3-by-n array containing n rotation matrices. Each rotation matrix in the array has either a size of 2-by-2 or 3-by-3 and is orthonormal. When using the rotation matrix, premultiply it with the coordinates to be rotated (as opposed to postmultiplying).

2-D rotation matrices are of the form:

R=[r11r12r21r22]

3-D rotation matrices are of the form:

R=[r11r12r13r11r22r23r31r32r33]

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

More About

collapse all

Extended Capabilities

expand all

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

Version History

Introduced in R2015a

expand all