Certainly! Here’s Chapter 2 on “Rotation Matrix” for your course on Linear Algebra Advanced.
In the realm of linear algebra, rotation matrices play a crucial role in various applications, including deep learning. A rotation matrix is a square matrix that can be used to rotate points in Euclidean space. This chapter will delve into the concept of rotation matrices, provide examples, and include Python code using the NumPy library for practical implementation.
A rotation matrix, often denoted as $R$, is a square matrix that represents a rotation in n-dimensional Euclidean space. In 2D space, it is a 2×2 matrix, while in 3D space, it is a 3×3 matrix. The elements of the matrix are typically calculated using trigonometric functions, such as sine and cosine.
In 2D space, a rotation matrix is defined as follows:
$$
R(\theta) = \begin{bmatrix}
\cos(\theta) & -\sin(\theta) \\
\sin(\theta) & \cos(\theta)
\end{bmatrix}
$$
Here, $\theta$ represents the angle of rotation in radians. The matrix $R(\theta)$ can be used to rotate a 2D point $(x, y)$ counter-clockwise by an angle $\theta$.
Let’s consider an example of rotating a point $(2, 1)$ by an angle of $\frac{\pi}{4}$ radians (45 degrees) counter-clockwise in 2D space using the rotation matrix.
You can implement rotation matrices in Python using the NumPy library. Here’s an example of how to rotate a 2D point using NumPy:
import numpy as np
# Define the rotation angle in radians
theta = np.pi / 4 # 45 degrees
# Define the 2D point
point = np.array([2, 1])
# Calculate the rotation matrix
rotation_matrix = np.array([[np.cos(theta), -np.sin(theta)],
[np.sin(theta), np.cos(theta)]])
# Apply the rotation matrix to the point
rotated_point = np.dot(rotation_matrix, point)
print("Original Point:", point)
print("Rotated Point:", rotated_point)This code will output the rotated point, which in this case is [1. 1.41421356].
This concludes Chapter 2 on Rotation Matrix. Rotation matrices are fundamental in various computer graphics, computer vision, and deep learning applications. Understanding how to create and apply these matrices is essential for many mathematical and programming tasks.