Rotation matrices
Rotation about any axis is a linear transformation. Any linear transformation can be expressed using a matrix. To represent a three-dimensional rotation we need a 3 X 3 or a 4 X 4 matrix. In this section, we are going to derive a matrix that represents rotation around the Z-Axis by some angle theta. This matrix will be used to transform a vector into a rotated version of that vector,
.The new vector will be the result of rotating the original vector around the Z-Axis. After we derive the matrix which rotates around the Z-Axis, rotation matrices for the X-Axis and Y-Axis will be discussed as well.
![](https://static.packt-cdn.com/products/9781787123663/graphics/B05887_3_11.jpg)
is the result of rotation vector
by some angle
around the Z-Axis. We can represent this rotation in terms of matrix Z; this can be expressed with the following formula:
![](https://static.packt-cdn.com/products/9781787123663/graphics/B05887_3_13.jpg)
The definition of this rotation matrix, Z, is given. We will go into detail about how to derive this matrix in the How it works section:
![](https://static.packt-cdn.com/products/9781787123663/graphics/B05887_3_14.jpg)
To use the rotation matrix, simply plug in the numbers for theta and evaluate...