Main Content

trvec2tform

Convert translation vector to homogeneous transformation

Description

example

tform = trvec2tform(trvec) converts the Cartesian representation of the translation vector trvec to the corresponding homogeneous transformation tform. When using the transformation matrix, premultiply it by the coordinates to be transformed (as opposed to postmultiplying).

Examples

collapse all

trvec = [0.5 6 100];
tform = trvec2tform(trvec)
tform = 4×4

    1.0000         0         0    0.5000
         0    1.0000         0    6.0000
         0         0    1.0000  100.0000
         0         0         0    1.0000

Input Arguments

collapse all

Cartesian representation of a translation vector, specified as an n-by-2 matrix if tform is a 3-by-3-by-n array and an n-by-3 matrix if tform is a 4-by-4-by-n array. n is the number of translation vectors. Each vector is of the form [x y] or [x y z].

Example: [0.5 6 100]

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 rotation matrix, premultiply it with the coordinates to be rotated (as opposed to postmultiplying).

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

2-D homogeneous transformation matrices are of the form:

T=[r11r12t1r21r22t2001]

3-D homogeneous transformation matrices are of the form:

T=[r11r12r13t1r21r22r23t2r31r32r33t30001]

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