Main Content

rotx

Rotation matrix for rotations around x-axis

Description

example

R = rotx(ang) creates a 3-by-3 matrix for rotating a 3-by-1 vector or 3-by-N matrix of vectors around the x-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.

Examples

collapse all

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

R = rotx(30)
R = 3×3

    1.0000         0         0
         0    0.8660   -0.5000
         0    0.5000    0.8660

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

    2.0000
   -3.7321
    2.4641

Under a rotation around the x-axis, the x-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 x-axis towards the origin. Angle units are in degrees.

Example: 30.0

Data Types: double

Output Arguments

collapse all

3-by-3 rotation matrix returned as

Rx(α)=[1000cosαsinα0sinαcosα]

for a rotation angle α.

More About

collapse all

Rotation Matrices

Rotation matrices are used to rotate a vector into a new direction.

In transforming vectors in three-dimensional space, rotation matrices are often encountered. Rotation matrices are used in two senses: they can be used to rotate a vector into a new position or they can be used to rotate a coordinate basis (or coordinate system) into a new one. In this case, the vector is left alone but its components in the new basis will be different from those in the original basis. In Euclidean space, there are three basic rotations: one each around the x, y and z axes. Each rotation is specified by an angle of rotation. The rotation angle is defined to be positive for a rotation that is counterclockwise when viewed by an observer looking along the rotation axis towards the origin. Any arbitrary rotation can be composed of a combination of these three (Euler’s rotation theorem). For example, you can rotate a vector in any direction using a sequence of three rotations: v=Av=Rz(γ)Ry(β)Rx(α)v.

The rotation matrices that rotate a vector around the x, y, and z-axes are given by:

  • Counterclockwise rotation around x-axis

    Rx(α)=[1000cosαsinα0sinαcosα]

  • Counterclockwise rotation around y-axis

    Ry(β)=[cosβ0sinβ010sinβ0cosβ]

  • Counterclockwise rotation around z-axis

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

The following three figures show what positive rotations look like for each rotation axis:

For any rotation, there is an inverse rotation satisfying A1A=1. For example, the inverse of the x-axis rotation matrix is obtained by changing the sign of the angle:

Rx1(α)=Rx(α)=[1000cosαsinα0sinαcosα]=Rx(α)

This example illustrates a basic property: the inverse rotation matrix is the transpose of the original. Rotation matrices satisfy A’A = 1, and consequently det(A) = 1. Under rotations, vector lengths are preserved as well as the angles between vectors.

We can think of rotations in another way. Consider the original set of basis vectors, i,j,k, and rotate them all using the rotation matrix A. This produces a new set of basis vectors i,j,k related to the original by:

i=Aij=Ajk=Ak

Using the transpose, you can write the new basis vectors as a linear combinations of the old basis vectors:

[ijk]=A[ijk]

Now any vector can be written as a linear combination of either set of basis vectors:

v=vxi+vyj+vzk=vxi+vyj+vzk

Using algebraic manipulation, you can derive the transformation of components for a fixed vector when the basis (or coordinate system) rotates. This transformation uses the transpose of the rotation matrix.

[vxvyvz]=A1[vxvyvz]=A[vxvyvz]

The next figure illustrates how a vector is transformed as the coordinate system rotates around the x-axis. The figure after shows how this transformation can be interpreted as a rotation of the vector in the opposite direction.

References

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

Extended Capabilities

Version History

Introduced in R2013a

See Also

|