Extract rotation matrix from homogeneous transformation
the rotational component from a homogeneous transformation,
rotm = tform2rotm(
and returns it as an orthonormal rotation matrix,
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).
Convert Homogeneous Transformation to Rotation Matrix
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
tform — Homogeneous transformation
3-by-3-by-n array | 4-by-4-by-n array
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:
3-D homogeneous transformation matrices are of the form:
[0 0 1 0; 0 1 0 0; -1 0 0 0; 0 0 0 1]
rotm — Rotation matrix
2-by-2-by-n array | 3-by-3-by-n array
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:
3-D rotation matrices are of the form:
[0 0 1; 0 1 0; -1 0
Homogeneous Transformation Matrices
Homogeneous transformation matrices consist of both an orthogonal rotation and a translation.
2-D transformations have a rotation θ about the z-axis:
, and a translation along the x and y axis:
, resulting in the 2-D transformation matrix of the form:
3-D transformations contain information about three rotations about the x-, y-, and z-axes:
and after multiplying become the rotation about the xyz-axes:
and a translation along the x-, y-, and z-axis:
, resulting in the 3-D transformation matrix of the form:
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Version HistoryIntroduced in R2015a
tform2rotm Supports 2-D Homogeneous
tform argument now accepts 2-D homogeneous
transformation matrices as a 3-by-3-by-n array
tform2rotm outputs 2-D rotation matrices