Main Content

rotz

Rotation matrix for rotations around z-axis

Description

R = rotz(ang) creates a 3-by-3 matrix used to rotate a 3-by-1 vector or 3-by-N matrix of vectors around the z-axis by ang degrees. When acting on a matrix, each column of the matrix represents a different vector. For the rotation matrix R and vector v, the rotated vector is given by R*v.

example

Examples

collapse all

Construct the matrix for the rotation of a vector around the z-axis by 45°. Then let the matrix operate on a vector.

R = rotz(45)
R = 3×3

    0.7071   -0.7071         0
    0.7071    0.7071         0
         0         0    1.0000

v = [1;-2;4];
y = R*v
y = 3×1

    2.1213
   -0.7071
    4.0000

Under a rotation around the z-axis, the z-component of a vector is invariant.

Input Arguments

collapse all

Rotation angle specified as a real-valued scalar. The rotation angle is positive if the rotation is in the counter-clockwise direction when viewed by an observer looking along the z-axis towards the origin. Angle units are in degrees.

Example: 45.0

Data Types: double

Output Arguments

collapse all

3-by-3 rotation matrix returned as

Rz(γ)=[cosγsinγ0sinγcosγ0001]

for a rotation angle γ.

More About

collapse all

References

[1] Goldstein, H., C. Poole and J. Safko, Classical Mechanics, 3rd Edition, San Francisco: Addison Wesley, 2002, pp. 142–144.

Extended Capabilities

expand all

Version History

Introduced in R2013a

See Also

|