Rotation
← Back: Translation  Overview: Transformations  Next: Homogeneous coordinates → 
Rotation is a transformation where the coordinates are rotated around the origin of the global coordinate system. The direction of the rotation is defined by the rotation axis, about which the rotation is applied. To determine the direction, the righthandrule shown in the figure on the left can be used. If the thumb is pointing in the direction of the rotation axis, the other fingers indicate the rotation direction for positive angles.
In this article rotation is first described for two dimensions and based on the twodimensional transform matrix, rotation in threedimensional space is presented.
Twodimensional
The figure on the right shows an example, where the vector is rotated by around the origin, what results in vector . The rotation axis in this case is pointing out of the figure in the direction of the imaginary axis. The length of the vector is assumed as and so the length of is as well. The initial angle of relative to the xaxis is . Hence the resulting coordinates and can be computed as follows:


Using the addition theorems of sine and cosine leads to:


Regarding the vector and its angle to the xaxis, equals and equals . By applying this the above equations can be reformed to:


These two equations for and can also be written in matrix notation:
So the transformation matrix for rotation about in two dimensions is:
Example: rotation in twodimensional space
The rotation of a rectangle corresponds to the rotation of each of the three position vectors of the corners individually. The red rectangle is the initial one. If it is rotated by 30 degrees, the result is the blue rectangle. The corresponding transformation matrix is: The green rectangle is obtained by rotating the red rectangle by 90 degrees. This corresponds to the following transformation matrix: Another possibility to obtain the green rectangle is rotating the blue rectangle by 60 degrees. Then the transformation matrix is: The back transformation of the blue rectangle to the red rectangle for example is done by the following transformation matrix: 
Threedimensional
In threedimensional space three basic types of rotation are regarded: rotation around x, y and zaxis. These three types are defined by the axis and the rotation angle and denoted as , and .
Rotation around one one of the three coordinate axes changes two components of the coordinates while the component on the rotation axis stays as it is. Hence the properties of twodimensional rotation can also be used for threedimensional rotation. The rotation matrix for rotation around the zaxis for example equals the identity matrix with the twodimensional rotation matrix replacing the four top left components:
As the coordinates are rotated around the zaxis, the x and ycomponents are calculated as in twodimensional space (see above) and the zcomponent stays as it is:
Accordingly the rotation matrices for the x and yaxis are:
The three colums of the rotation matrix describe the new coordinate axes. The first colum corresponds to the new xaxis, the second column to the new yaxis and the third to the new zaxis:
Example: Threedimensional rotation
The figure on the right shows a colored coordinate frame in the black global coordinate system. The left subfigure shows the initial situation, the initial position vector and three colored axes are the following: The colored coordinate frame is then rotated around the xaxis by 90 degrees. The corresponding rotation matrix is: The resulting position vector is: As can be seen in the right subfigure the rotation matrix describes the three resulting axes of the colored coordinate frame after the rotation: 