Rotation Matrix
Rotation Matrix is a type of transformation matrix. The purpose of this matrix is to perform the rotation of vectors in Euclidean space. Geometry provides us with four types of transformations, namely, rotation, reflection, translation, and resizing. Furthermore, a transformation matrix uses the process of matrix multiplication to transform one vector to another. When we want to alter the cartesian coordinates of a vector and map them to new coordinates, we take the help of the different transformation matrices.
If we are working in 2dimensional space then the order of a rotation matrix will be 2 x 2. Similarly, the order of a rotation matrix in ndimensional space is n x n. Rotation matrices describe the rotation of an object or a vector in a fixed coordinate system. These matrices are widely used to perform computations in physics, geometry, and engineering. In this article, we will take an indepth look at the rotation matrix in 2D and 3D space as well as understand their important properties.
1.  What is Rotation Matrix? 
2.  Rotation Matrix in 2D 
3.  Rotation Matrix in 3D 
4.  Clockwise Rotation Matrix 
5.  Properties of Rotation Matrix 
6.  FAQs on Rotation Matrix 
What is Rotation Matrix?
A rotation matrix can be defined as a transformation matrix that operates on a vector and produces a rotated vector such that the coordinate axes always remain fixed. These matrices rotate a vector in the counterclockwise direction by an angle θ. A rotation matrix is always a square matrix with real entities. This implies that it will always have an equal number of rows and columns. Moreover, rotation matrices are orthogonal matrices with a determinant equal to 1. Suppose we have a square matrix P. Then P will be a rotation matrix if and only if P^{T} = P^{1} and P = 1.
Rotation Matrix Example
Say we have a matrix P = \(\begin{bmatrix} cos\theta & sin\theta\\ \\sin\theta & cos\theta \end{bmatrix}\). This is a 2 x 2 square matrix.
P^{T} = \(\begin{bmatrix} cos\theta & sin\theta\\ \\sin\theta & cos\theta \end{bmatrix}\)
P^{1} = \(\begin{bmatrix} cos\theta & sin\theta\\ \\sin\theta & cos\theta \end{bmatrix}\)
Hence, P^{T} = P^{1}
Now, P = (cos^{2}θ + sin^{2}θ) = 1.
Thus, P is a rotation matrix. We can say that P rotates the cartesian coordinates in an anticlockwise direction through θ with respect to the xaxis in a 2D system.
Rotation Matrix in 2D
The process of rotating an object with respect to an angle in a twodimensional plane is 2D rotation. We accomplish this rotation with the help of a 2 x 2 rotation matrix that has the standard form as given below:
M(θ) = \(\begin{bmatrix} cos\theta & sin\theta \\ \\sin\theta& cos\theta \end{bmatrix}\).
If we want to rotate a vector with the coordinates (x, y) then we use matrix multiplication to perform the rotation as follows:
\(\begin{bmatrix} x' \\ \\y' \end{bmatrix}\) = \(\begin{bmatrix} cos\theta & sin\theta \\ \\sin\theta& cos\theta \end{bmatrix}\) \(\begin{bmatrix} x \\ \\y \end{bmatrix}\).
On solving this equation we get,
x' = xcosθ  ysinθ.
y' = xsinθ + ycosθ.
Here, θ is the angle of rotation in the anticlockwise direction.
Rotation Matrix in 2D Derivation
Let G be a vector in the xy plane with a length r and it traces out an angle v with respect to the xaxis. We now rotate G in the counterclockwise direction by an angle θ. If (x, y) were the original coordinates of the tip of the vector G, then (x', y') will be the new coordinates after rotation.
Expressing (x, y) in the polar form we have;
x = r cos v  (1)
y = r sin v  (2)
Similarly, expressing (x', y') in polar form
x' = r cos (v + θ)
y' = r sin (v + θ)
Expanding the brackets using trigonometric identities we get,
x' = r (cos v.cos θ  sin v.sin θ)
= r cos v.cos θ  r sin v.sin θ
From (1) and (2) we have,
x' = x cos θ  y sin θ  (3)
y' = r (sin v.cos θ + cos v.sin θ)
= r sin v.cos θ + r cos v.sin θ
y' = y cos θ + x sin θ  (4)
If we take the help of a 2 x 2 rotation matrix to denote (3) and (4) we get,
\(\begin{bmatrix} x' \\ \\y' \end{bmatrix}\) = \(\begin{bmatrix} cos\theta & sin\theta \\ \\sin\theta& cos\theta \end{bmatrix}\) \(\begin{bmatrix} x \\ \\y \end{bmatrix}\).
Thus, \(\begin{bmatrix} cos\theta & sin\theta \\ \\sin\theta& cos\theta \end{bmatrix}\) will be the rotation matrix.
Rotation Matrix in 3D
In 3D space, rotation can occur about the x, y, or zaxis. Such a type of rotation that occurs about any one of the axis is known as a basic or elementary rotation. Given below are the rotation matrices that can rotate a vector through an angle about any particular axis.
P (x, \(\gamma\)) = \(\begin{bmatrix} 1 & 0 & 0\\ 0 & cos\gamma & sin\gamma \\ 0& sin\gamma & cos\gamma \end{bmatrix}\). This is also known as a roll. It is defined as the counterclockwise rotation of \(\gamma\) about the x axis.
P (y, \(\beta\)) = \(\begin{bmatrix} cos\beta & 0 & sin\beta\\ 0 &1 & 0 \\ sin\beta & 0 & cos\beta \end{bmatrix}\). Such a matrix is known as a pitch. Here, it represents the counterclockwise rotation of \(\beta\) about the y axis.
P (z, \(\alpha\)) = \(\begin{bmatrix} cos\alpha & sin\alpha &0 \\ sin\alpha & cos\alpha & 0 \\ 0& 0 & 1 \end{bmatrix}\). This rotation matrix is called a yaw and it is the the counterclockwise rotation of \(\alpha\) about the z axis.
According to the convention, a positive rotation given by angle θ is used to denote a counterclockwise rotation. However, if we change the signs according to the righthand rule, we can also represent clockwise rotations. The righthand rule states that if you curl your fingers around the axis of rotation, where the fingers point to the direction of θ then the thumb points perpendicular to the plane of rotation in the direction of the axis of rotation.
Now if we want to find the new coordinates (x', y', z') of a vector(x, y, z) after rotation about a particular axis we follow the formula given below:
\(\begin{bmatrix} x'\\ y'\\ z' \end{bmatrix}\) = P(x, y or z) \(\begin{bmatrix} x\\ y\\ z \end{bmatrix}\)
Suppose an object is rotated about all three axes, then such a rotation matrix will be a product of the three aforementioned rotation matrices [P (z, \(\alpha\)), P (y, \(\beta\)) and P (x, \(\gamma\))]. The general rotation matrix is represented as follows:
P = \(\begin{bmatrix} cos\alpha & sin\alpha &0 \\ sin\alpha & cos\alpha & 0 \\ 0& 0 & 1 \end{bmatrix}\) \(\begin{bmatrix} cos\beta & 0 & sin\beta\\ 0 &1 & 0 \\ sin\beta & 0 & cos\beta \end{bmatrix}\) \(\begin{bmatrix} 1 & 0 & 0\\ 0 & cos\gamma & sin\gamma \\ 0& sin\gamma & cos\gamma \end{bmatrix}\)
To find the coordinates of the rotated vector about all three axes we multiply the rotation matrix P with the original coordinates of the vector.
Rotation Matrix in 3D Derivation
To derive the x, y, and z rotation matrices, we will follow the steps similar to the derivation of the 2D rotation matrix. A 3D rotation is defined by an angle and the rotation axis. Suppose we move a point Q given by the coordinates (x, y, z) about the xaxis to a new position given by (x', y,' z'). The x component of the point remains the same. Hence, this rotation is analogous to a 2D rotation in the yz plane. For this reason our 3 x 3 rotation matrix is given by Q (x, \(\gamma\)) = \(\begin{bmatrix} 1 & 0 & 0\\ 0 & cos\gamma & sin\gamma \\ 0& sin\gamma & cos\gamma \end{bmatrix}\). The same concept is applied to the rotation of the object about the y and z axes in order to obtain the respective rotation matrices.
Clockwise Rotation Matrix
When we rotate a vector in the counterclockwise direction then its angle, θ, is positive. However, if the vector is rotated in the clockwise direction then the angle will be negative, θ. We use the negative and positive signs as a means of indicating the direction of rotation.
The counterclockwise rotation matrix in 2D is given as:
M(θ) = \(\begin{bmatrix} cos\theta & sin\theta \\ \\sin\theta& cos\theta \end{bmatrix}\).
Thus, the clockwise rotation matrix in 2D is as follows:
M(θ) = \(\begin{bmatrix} cos(\theta) & sin(\theta) \\ \\sin(\theta)& cos(\theta) \end{bmatrix}\).
As sin (θ) = sin θ and cos (θ) = cos θ
M(θ) = \(\begin{bmatrix} cos\theta & sin\theta \\ \\sin\theta& cos\theta \end{bmatrix}\)
Similarly, we can get the clockwise rotation matrices in 3D as given below:
P (x, \(\gamma\)) = \(\begin{bmatrix} 1 & 0 & 0\\ 0 & cos\gamma & sin\gamma \\ 0& sin\gamma & cos\gamma \end{bmatrix}\).
P (y, \(\beta\)) = \(\begin{bmatrix} cos\beta & 0 & sin\beta\\ 0 &1 & 0 \\ sin\beta & 0 & cos\beta \end{bmatrix}\).
P (z, \(\alpha\)) = \(\begin{bmatrix} cos\alpha & sin\alpha &0 \\ sin\alpha & cos\alpha & 0 \\ 0& 0 & 1 \end{bmatrix}\).
Properties of Rotation Matrix
There are certain properties that are applicable to both 2D and 3D rotation matrices. These are as follows:
 A rotation matrix will always be a square matrix.
 As a rotation matrix is always an orthogonal matrix the transpose will be equal to the inverse of the matrix.
 The determinant of a rotation matrix will always be equal to 1.
 Multiplication of rotation matrices will result in a rotation matrix.
 If we take the cross product of two rows of a rotation matrix it will be equal to the third.
 The dot product of a row with a column of a rotation matrix will be equal to 1.
ā Related Articles:
Important Notes on Rotation Matrix:
 A rotation matrix rotates a vector such that the coordinate axes remain fixed.
 A 2D rotation matrix in the counterclockwise direction is given by \(\begin{bmatrix} cos\theta & sin\theta \\ \\sin\theta& cos\theta \end{bmatrix}\).
 In 3D space, the yaw, pitch, and roll form the rotation matrices about the z, y, and xaxis respectively.
 In a clockwise rotation matrix the angle is negative, θ.
 The transpose of a rotation matrix will always be equal to its inverse and the value of the determinant will be equal to 1.
Examples on Rotation Matrix

Example 1: If A (1, 2) is rotated in the counterclockwise direction by 60 degrees, what are the coordinate values?
Solution: We know that \(\begin{bmatrix} x' \\ \\y' \end{bmatrix}\) = \(\begin{bmatrix} cos\theta & sin\theta \\ \\sin\theta& cos\theta \end{bmatrix}\) \(\begin{bmatrix} x \\ \\y \end{bmatrix}\)
Thus, \(\begin{bmatrix} x' \\ \\y' \end{bmatrix}\) = \(\begin{bmatrix} cos60 ° & sin60 ° \\ \\sin60 °& cos60 ° \end{bmatrix}\) \(\begin{bmatrix} 1 \\ \\2 \end{bmatrix}\)
\(\begin{bmatrix} x' \\ \\y' \end{bmatrix}\) = \(\begin{bmatrix} \frac{1}{2} & \frac{\sqrt{3}}{2}\\ \\\frac{\sqrt{3}}{2} & \frac{1}{2} \end{bmatrix}\) \(\begin{bmatrix} 1 \\ \\2 \end{bmatrix}\)
On solving we get, (x', y') = (1/2 + √3, 1 + √3/2)
Answer: (1/2 + √3, 1 + √3/2) 
Example 2: If B (2, 3) is rotated in the clockwise direction by 90 degrees, what are the coordinate values?
Solution: We know that \(\begin{bmatrix} x' \\ \\y' \end{bmatrix}\) = \(\begin{bmatrix} cos\theta & sin\theta \\ \\sin\theta& cos\theta \end{bmatrix}\) \(\begin{bmatrix} x \\ \\y \end{bmatrix}\)
Thus, \(\begin{bmatrix} x' \\ \\y' \end{bmatrix}\) = \(\begin{bmatrix} cos(90 °) & sin(90 °) \\ \\sin(90 °)& cos(90 °) \end{bmatrix}\) \(\begin{bmatrix} 2 \\ \\3 \end{bmatrix}\)
\(\begin{bmatrix} x' \\ \\y' \end{bmatrix}\) = \(\begin{bmatrix} 0 & 1\\ \\1 & 0 \end{bmatrix}\) \(\begin{bmatrix} 2 \\ \\3 \end{bmatrix}\)
On solving we get, (x', y') = (3, 2)
Answer: (3, 2) 
Example 3: If C (5, 2, 6) is rotated in the counterclockwise direction by 180 degrees about the xaxis, what are the coordinate values?
Solution: \(\begin{bmatrix} x'\\ y'\\ z' \end{bmatrix}\) = \(\begin{bmatrix} 1 & 0 & 0\\ 0 & cos\gamma & sin\gamma \\ 0& sin\gamma & cos\gamma \end{bmatrix}\) \(\begin{bmatrix} x\\ y\\ z \end{bmatrix}\)
\(\begin{bmatrix} x'\\ y'\\ z' \end{bmatrix}\) = \(\begin{bmatrix} 1 & 0 & 0\\ 0 & cos180 ° & sin180 ° \\ 0& sin180 ° & cos180 ° \end{bmatrix}\) \(\begin{bmatrix} 5\\ 2\\ 6 \end{bmatrix}\)
\(\begin{bmatrix} x'\\ y'\\ z' \end{bmatrix}\) = \(\begin{bmatrix} 1 & 0 & 0\\ 0 & 1 & 0 \\ 0& 0 & 1 \end{bmatrix}\) \(\begin{bmatrix} 5\\ 2\\ 6 \end{bmatrix}\)
On solving we get (x', y', z') = (5, 2, 6)
Answer: (5, 2, 6)
FAQs on Rotation Matrix
What is the Rotation Matrix?
A rotation matrix can be defined as a transformation matrix that is used to rotate a vector in Euclidean space. The vector is conventionally rotated in the counterclockwise direction by a certain angle in a fixed coordinate system.
How Do You Find the Rotation of a Vector using the Rotation Matrix?
To find the rotation of a vector we simply multiply the required rotation matrix with the coordinates of the given vector. In 2D space, this is given by \(\begin{bmatrix} x' \\ \\y' \end{bmatrix}\) = \(\begin{bmatrix} cos\theta & sin\theta \\ \\sin\theta& cos\theta \end{bmatrix}\) \(\begin{bmatrix} x \\ \\y \end{bmatrix}\). In 3D space, \(\begin{bmatrix} x'\\ y'\\ z' \end{bmatrix}\) = P(x, y or z) \(\begin{bmatrix} x\\ y\\ z \end{bmatrix}\). Here, P(x, y or z) indicates the rotation matrix about the x, y or z axis respectively.
Is a Rotation Matrix Invertible?
Yes, a rotation matrix is invertible. The transpose of a rotation matrix will be equal to its inverse. This is because all rotation matrices are orthogonal matrices.
What is the Formula for Rotation matrix?
A 2D rotation matrix is given by \(\begin{bmatrix} cos\theta & sin\theta \\ \\sin\theta& cos\theta \end{bmatrix}\). The yaw, pitch and roll of a 3 x 3 rotation matrix is given by \(\begin{bmatrix} cos\alpha & sin\alpha &0 \\ sin\alpha & cos\alpha & 0 \\ 0& 0 & 1 \end{bmatrix}\), \(\begin{bmatrix} cos\beta & 0 & sin\beta\\ 0 &1 & 0 \\ sin\beta & 0 & cos\beta \end{bmatrix}\) and \(\begin{bmatrix} 1 & 0 & 0\\ 0 & cos\gamma & sin\gamma \\ 0& sin\gamma & cos\gamma \end{bmatrix}\) respectively.
Is Rotation Matrix Linear?
A rotation matrix will always preserve the angles between the vectors as well as their lengths, thus, it is a type of linear transformation. This implies that if we rotate a parallelogram its shape will remain intact.
What is the Rule for a 90Degree Rotation Matrix?
If we want to rotate a vector given by (x, y) by 90 degrees in the counterclockwise direction using the rotation matrix then the new coordinates are given as (y, x).
What are the Properties of the Rotation Matrix?
The determinant of a rotation matrix will always be 1 and the transpose of such a matrix will be equal to its inverse. Furthermore, for clockwise rotation, a negative angle is used.
visual curriculum