Main Content

tform2rotm

Extract rotation matrix from homogeneous transformation

Description

example

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).

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

Homogeneous Transformation Matrices

Homogeneous transformation matrices consist of both an orthogonal rotation and a translation.

2-D Transformations

2-D transformations have a rotation θ about the z-axis:

Rz(θ)=[cosθsinθsinθcosθ]

, and a translation along the x and y axis:

t=[xy]

, resulting in the 2-D transformation matrix of the form:

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

3-D Transformations

3-D transformations contain information about three rotations about the x-, y-, and z-axes:

Rx(ϕ)=[1000cosϕsinϕ0sinϕcosϕ],Ry(ψ)=[cosψ0sinψ010sinψ0cosψ],Rz(θ)=[cosθsinθ0sinθcosθ0001]

and after multiplying become the rotation about the xyz-axes:

Rxyz=Rx(ϕ)Ry(ψ)Rz(θ)=[cosϕcosψcosθsinϕsinθcosϕcosψsinθsinϕcosθcosϕsinψsinϕcosψcosθ+cosϕsinθsinϕcosψsinθ+cosϕcosθsinϕsinψsinψcosθsinψsinθcosψ]

and a translation along the x-, y-, and z-axis:

t=[xyz]

, resulting in the 3-D transformation matrix of the form:

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

| | | |