Rotation matrix
Rotation matrix
Rotations in two and three dimensions
In all of this section, the matrices are assumed to act on column vectors, for instance in cartesian coordinates systems: [x,y,z] in 3D or [x,y] in 2D (each of them transposed to a column vector).
Dimension two
In two dimensions, every rotation matrix has the following form:
This matrix rotates the plane around the origin by an angle of . The x axis is rotated towards the y axis.
The new coordinates (x’,y’) for a point (x,y) will then be given by:
In an oriented plane
The effect of the rotation matrix in a plane oriented in the standard way
The effect of the same rotation matrix in a plane that is oriented otherwise
If we use the standard right-handed coordinate system, where x axis goes to the right and where y axis goes up, the rotation is counterclockwise. If one uses the opposite convention, for example x directed to the right and y directed to the bottom, the rotation will be clockwise. To get convinced that it is still the same rotation, one can think at the plane as a sheet of paper being watched alternatively from above and from beneath, by transparency.
Such non-standard orientations are almost never used in mathematics and physics, but they are very common in computer graphics, because they match the direction of writing for Western scripts: from the left to the right and from the top to the bottom. That’s the reason why, in much computer software, rotations go clockwise.
Assuming the standard orientation, for a clockwise rotation, simply replace by :
Common rotations
Particularly useful are the matrices for 90 and 180 rotations:
Dimension three
See also: Rotation representation
Basic rotations
There are three basic rotation matrices in three dimensions:
These matrices represent counterclockwise rotations of an object relative to fixed coordinate axes, by an angle of . The direction of the rotation is as follows: Rx rotates the y-axis towards the z-axis, Ry rotates the z-axis towards the x-axis, and Rz rotates the x-axis towards the y-axis.
The resulting coordinates (x’,y’,z’) for a point (x,y,z), for each of these rotations are:
x’
y’
z’
Rx()
Ry()
Rz()
In an oriented space
If the 3D space is oriented in the usual way, i.e. x going to the right, y going to the front and z going up, these three rotations are counterclockwise when the third (unchanged) axis goes towards the observer. This direction of the rotation can be determined by the right-hand rule.
General rotations
Other rotation matrices can be obtained from these three using matrix multiplication. For example, the product
represents a rotation whose yaw, pitch, and roll are , , and , respectively. Similarly, the product
represents a rotation whose Euler angles are , , and (using the z-x-z convention for Euler angles).
Finding the rotation matrix
Every rotation in three dimensions is defined by its axis a direction that is left fixed by the rotation and its angle the amount by which the rotation turns.
Determining the axis
A rotation R around axis u can be decomposed using 3 endomorphisms P, (I – P), and Q (click to enlarge).
Given a rotation matrix R, a vector u parallel to the rotation axis must satisfy
since 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.
Further, the equation may be rewritten
which shows that is the null space of R I. Viewed another way, is an eigenvector corresponding to the eigenvalue = 1 (every rotation matrix must have this eigenvalue).
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 .
Rotation matrix given an axis and an angle
For some applications, it is helpful to be able to make a rotation with a given axis. Given a unit vector u = (ux, uy, uz), where ux2 + uy2 + uz2 = 1, the matrix for a rotation by an angle of about an axis in the direction of u is:
where
This can be written more concisely as
where is the skew symmetric form of u, and is the outer product.
If the 3D space is oriented in the usual way, this rotation will be counterclockwise for an observer placed so that the axis u goes in his or her direction (Right-hand rule).
Simpler form of the axis-angle formula
Rodrigues’ rotation formula can be written as
where
The matrix I is the 3 3 identity matrix. The matrix Q is the skew-symmetric representation of a cross product with u. The matrix P is the projection onto the axis of rotation, and I P is the projection onto the plane orthogonal to the axis.
Properties of a rotation matrix
The