Rotation matrix
In linear algebra, a rotation matrix is a transformation matrix that is used to perform a rotation in Euclidean space. For example, using the convention [|below], the matrix
rotates points in the plane counterclockwise through an angle about the origin of a two-dimensional Cartesian coordinate system. To perform the rotation on a plane point with standard coordinates, it should be written as a column vector, and multiplied by the matrix :
If and are the coordinates of the endpoint of a vector with the length r and the angle with respect to the -axis, so that and, then the above equations become the trigonometric summation angle formulae:Indeed, these are the trigonometric summation angle formulae in matrix form. One way to understand this is to say we have a vector at an angle 30° from the -axis, and we wish to rotate that angle by a further 45°. We simply need to compute the vector endpoint coordinates at 75°.
The examples in this article apply to active rotations of vectors counterclockwise in a right-handed coordinate system by pre-multiplication. If any one of these is changed, then the inverse of the example matrix should be used, which coincides with its transpose.
Since matrix multiplication has no effect on the zero vector, rotation matrices describe rotations about the origin. Rotation matrices provide an algebraic description of such rotations, and are used extensively for computations in geometry, physics, and computer graphics. In some literature, the term rotation is generalized to include improper rotations, characterized by orthogonal matrices with a determinant of −1. An improper rotation combines a proper rotation with reflections. In other cases, where reflections are not being considered, the label proper may be dropped. The latter convention is followed in this article.
Rotation matrices are square matrices, with real entries. More specifically, they can be characterized as orthogonal matrices with determinant 1; that is, a square matrix is a rotation matrix if and only if and. The set of all orthogonal matrices of size with determinant +1 is a representation of a group known as the special orthogonal group, one example of which is the rotation group SO. The set of all orthogonal matrices of size with determinant +1 or −1 is a representation of the orthogonal group.
In two dimensions
In two dimensions, the standard rotation matrix has the following form:This rotates column vectors by means of the following matrix multiplication,
Thus, the new coordinates of a point after rotation are
Examples
For example, when the vectoris rotated by an angle, its new coordinates are
and when the vector
is rotated by an angle, its new coordinates are
Direction
The direction of vector rotation is counterclockwise if is positive, and clockwise if is negative for. Thus the clockwise rotation matrix is found asAn alternative convention uses rotating axes, and the above matrices also represent a rotation of the axes clockwise through an angle.
The two-dimensional case is the only non-trivial case where the rotation matrices group is commutative; it does not matter in which order rotations are multiply performed. For the 3-dimensional case, for example, a different order of multiple rotations gives a different result.
Non-standard orientation of the coordinate system
If a standard right-handed Cartesian coordinate system is used, with the to the right and the up, the rotation is counterclockwise. If a left-handed Cartesian coordinate system is used, with directed to the right but directed down, is clockwise. Such non-standard orientations are rarely used in mathematics but are common in 2D computer graphics, which often have the origin in the top left corner and the down the screen or page.See below for other alternative conventions which may change the sense of the rotation produced by a rotation matrix.
Common 2D rotations
Matricesare 2D rotation matrices corresponding to counter-clockwise rotations of respective angles of 0°, 90°, 180°, and 270°.
Relationship with complex plane
The matrices of the shapeform a ring, since their set is closed under addition and multiplication.
Since
, the map
is a ring isomorphism from this ring to the field of the complex numbers . Under this isomorphism, the rotation matrices correspond to the circle of the unit complex numbers, the complex numbers of modulus, since. As a result, the following equality holds,where the first equality is Euler's formula, the matrix corresponds to 1, and the matrix corresponds to the imaginary unit.
If one identifies with through the linear isomorphism, where and, the action of a matrix on a vector corresponds to multiplication on the complex number by. In other words, a vector rotation corresponds to multiplication on a complex number by a complex number of modulus .
In three dimensions
Basic 3D rotations
A basic 3D rotation is a rotation about one of the axes of a coordinate system. The following three basic rotation matrices rotate vectors by an angle about the -, -, or -axis, in three dimensions, using the right-hand rule—which codifies their alternating signs. Notice that the right-hand rule only works when multiplying. The same matrices can also represent a clockwise rotation of the axes keeping the vectors unchanged.For column vectors, each of these basic vector rotations appears counterclockwise when the axis about which they occur points toward the observer, the coordinate system is right-handed, and the angle is positive., for instance, would rotate toward the a vector aligned with the, as can easily be checked by operating with on the vector :
This is similar to the rotation produced by the above-mentioned two-dimensional rotation matrix. See below for alternative conventions which may apparently or actually invert the sense of the rotation produced by these matrices.
General 3D rotations
Other 3D rotation matrices can be obtained from these three using matrix multiplication. For example, the productrepresents a rotation whose yaw, pitch, and roll angles are, and, respectively. More formally, it is an intrinsic rotation whose Tait–Bryan angles are,,, about axes,,, respectively.
Similarly, the product
represents an extrinsic rotation whose Euler angles are,,, about axes,,.
These matrices produce the desired effect only if they are used to premultiply column vectors, and only if they are applied in the specified order. The order of rotation operations is from right to left; the matrix adjacent to the column vector is the first to be applied, and then the one to the left.
Conversion from rotation matrix to axis–angle
Every rotation in three dimensions is defined by its axis, and its angle — the amount of rotation about that axis.There are several methods to compute the axis and angle from a rotation matrix. Here, we only describe the method based on the computation of the eigenvectors and eigenvalues of the rotation matrix. It is also possible to use the trace of the rotation matrix.
Determining the axis
Given a rotation matrix, a vector parallel to the rotation axis must satisfysince the rotation of around the rotation axis must result in. The equation above may be solved for which is unique up to a scalar factor unless is the identity matrix.
Further, the equation may be rewritten
which shows that lies in the null space of.
This means precisely that that is an eigenvector of corresponding to the eigenvalue. Every rotation matrix must have this eigenvalue, the other two eigenvalues being complex conjugates of each other. It follows that a general rotation matrix in three dimensions has, up to a multiplicative constant, only one real eigenvector.
One way to determine the rotation axis is by showing that:
Since is a skew-symmetric matrix, we can choose such that
The matrix–vector product becomes a cross product of a vector with itself, ensuring that the result is zero:
Therefore, if
then
The magnitude of computed this way is, where is the angle of rotation.
This does not work if is symmetric. Above, if is zero, then all subsequent steps are invalid. In this case, the angle of rotation is 0° or 180° and any nonzero column of is an eigenvector of with eigenvalue 1 because.
Determining the angle
To find the angle of a rotation, once the axis of the rotation is known, select a vector perpendicular to the axis. Then the angle of the rotation is the angle between and .A more direct method, however, is to simply calculate the trace: the sum of the diagonal elements of the rotation matrix. Care should be taken to select the right sign for the angle to match the chosen axis:
from which follows that the angle's absolute value is
For the rotation axis, you can get the correct angle from
where
Rotation matrix from axis and angle
The matrix of a proper rotation by angle around the axis, a unit vector with, is given by:A derivation of this matrix from first principles can be found in section 9.2 here. The basic idea to derive this matrix is dividing the problem into few known simple steps.
- First rotate the given axis and the point such that the axis lies in one of the coordinate planes
- Then rotate the given axis and the point such that the axis is aligned with one of the two coordinate axes for that particular coordinate plane
- Use one of the fundamental rotation matrices to rotate the point depending on the coordinate axis with which the rotation axis is aligned.
- Reverse rotate the axis-point pair such that it attains the final configuration as that was in step 2
- Reverse rotate the axis-point pair which was done in step 1
where is the cross product matrix of ; the expression is the outer product, and is the identity matrix. Alternatively, the matrix entries are:
where is the Levi-Civita symbol with. This is a matrix form of Rodrigues' rotation formula, with
In the rotation of a vector around the axis by an angle can be written as:
or equivalently:
This can also be written in tensor notation as:
If the 3D space is right-handed and, this rotation will be counterclockwise when points towards the observer. Explicitly, with a right-handed orthonormal basis,
Note the striking merely apparent differences to the equivalent Lie-algebraic formulation below.