In this section, we will delve into the concept of transformation matrices, which are fundamental tools in 3D mathematics for manipulating and transforming objects in three-dimensional space. Understanding transformation matrices is crucial for applications in computer graphics, robotics, and many other fields.
Table of Contents
- Introduction to Transformation Matrices
- Types of Transformations
- Translation
- Rotation
- Scaling
- Homogeneous Coordinates
- Constructing Transformation Matrices
- Translation Matrix
- Rotation Matrix
- Scaling Matrix
- Combining Transformations
- Practical Examples
- Exercises
- Introduction to Transformation Matrices
Transformation matrices are used to perform linear transformations on vectors in 3D space. These transformations include translation, rotation, and scaling. A transformation matrix is a square matrix that, when multiplied by a vector, transforms the vector in a specific way.
- Types of Transformations
Translation
Translation involves moving an object from one position to another in 3D space. The translation matrix for moving a point \((x, y, z)\) by \((t_x, t_y, t_z)\) is:
\[
T = \begin{bmatrix}
1 & 0 & 0 & t_x
0 & 1 & 0 & t_y
0 & 0 & 1 & t_z
0 & 0 & 0 & 1
\end{bmatrix}
\]
Rotation
Rotation involves rotating an object around an axis. The rotation matrices for rotating around the x, y, and z axes by an angle \(\theta\) are:
- Rotation around the x-axis:
\[
R_x(\theta) = \begin{bmatrix}
1 & 0 & 0 & 0
0 & \cos\theta & -\sin\theta & 0
0 & \sin\theta & \cos\theta & 0
0 & 0 & 0 & 1
\end{bmatrix}
\]
- Rotation around the y-axis:
\[
R_y(\theta) = \begin{bmatrix}
\cos\theta & 0 & \sin\theta & 0
0 & 1 & 0 & 0
-\sin\theta & 0 & \cos\theta & 0
0 & 0 & 0 & 1
\end{bmatrix}
\]
- Rotation around the z-axis:
\[
R_z(\theta) = \begin{bmatrix}
\cos\theta & -\sin\theta & 0 & 0
\sin\theta & \cos\theta & 0 & 0
0 & 0 & 1 & 0
0 & 0 & 0 & 1
\end{bmatrix}
\]
Scaling
Scaling involves changing the size of an object. The scaling matrix for scaling by factors \(s_x\), \(s_y\), and \(s_z\) along the x, y, and z axes is:
\[
S = \begin{bmatrix}
s_x & 0 & 0 & 0
0 & s_y & 0 & 0
0 & 0 & s_z & 0
0 & 0 & 0 & 1
\end{bmatrix}
\]
- Homogeneous Coordinates
To perform transformations using matrices, we use homogeneous coordinates. A point \((x, y, z)\) in 3D space is represented as \((x, y, z, 1)\) in homogeneous coordinates. This allows us to use a single matrix to perform multiple transformations.
- Constructing Transformation Matrices
Translation Matrix
To translate a point \((x, y, z)\) by \((t_x, t_y, t_z)\):
\[
T = \begin{bmatrix}
1 & 0 & 0 & t_x
0 & 1 & 0 & t_y
0 & 0 & 1 & t_z
0 & 0 & 0 & 1
\end{bmatrix}
\]
Rotation Matrix
To rotate a point around the x, y, or z axis by an angle \(\theta\):
- Around the x-axis:
\[
R_x(\theta) = \begin{bmatrix}
1 & 0 & 0 & 0
0 & \cos\theta & -\sin\theta & 0
0 & \sin\theta & \cos\theta & 0
0 & 0 & 0 & 1
\end{bmatrix}
\]
- Around the y-axis:
\[
R_y(\theta) = \begin{bmatrix}
\cos\theta & 0 & \sin\theta & 0
0 & 1 & 0 & 0
-\sin\theta & 0 & \cos\theta & 0
0 & 0 & 0 & 1
\end{bmatrix}
\]
- Around the z-axis:
\[
R_z(\theta) = \begin{bmatrix}
\cos\theta & -\sin\theta & 0 & 0
\sin\theta & \cos\theta & 0 & 0
0 & 0 & 1 & 0
0 & 0 & 0 & 1
\end{bmatrix}
\]
Scaling Matrix
To scale a point by factors \(s_x\), \(s_y\), and \(s_z\):
\[
S = \begin{bmatrix}
s_x & 0 & 0 & 0
0 & s_y & 0 & 0
0 & 0 & s_z & 0
0 & 0 & 0 & 1
\end{bmatrix}
\]
- Combining Transformations
Transformations can be combined by multiplying their matrices. For example, to first rotate and then translate a point, you multiply the rotation matrix by the translation matrix:
\[ T \cdot R \]
Order matters in matrix multiplication, so the sequence of transformations is important.
- Practical Examples
Example 1: Translating a Point
Translate the point \((1, 2, 3)\) by \((4, 5, 6)\):
\[
T = \begin{bmatrix}
1 & 0 & 0 & 4
0 & 1 & 0 & 5
0 & 0 & 1 & 6
0 & 0 & 0 & 1
\end{bmatrix}
\]
\[
\begin{bmatrix}
1 & 0 & 0 & 4
0 & 1 & 0 & 5
0 & 0 & 1 & 6
0 & 0 & 0 & 1
\end{bmatrix}
\begin{bmatrix}
1
2
3
1
\end{bmatrix}
\begin{bmatrix}
5
7
9
1
\end{bmatrix}
\]
Example 2: Rotating a Point
Rotate the point \((1, 0, 0)\) around the z-axis by 90 degrees (\(\pi/2\) radians):
\[
R_z(\pi/2) = \begin{bmatrix}
0 & -1 & 0 & 0
1 & 0 & 0 & 0
0 & 0 & 1 & 0
0 & 0 & 0 & 1
\end{bmatrix}
\]
\[
\begin{bmatrix}
0 & -1 & 0 & 0
1 & 0 & 0 & 0
0 & 0 & 1 & 0
0 & 0 & 0 & 1
\end{bmatrix}
\begin{bmatrix}
1
0
0
1
\end{bmatrix}
\begin{bmatrix}
0
1
0
1
\end{bmatrix}
\]
- Exercises
Exercise 1: Translation
Translate the point \((2, 3, 4)\) by \((1, -1, 2)\). Write down the translation matrix and the resulting point.
Exercise 2: Rotation
Rotate the point \((0, 1, 0)\) around the x-axis by 90 degrees (\(\pi/2\) radians). Write down the rotation matrix and the resulting point.
Exercise 3: Scaling
Scale the point \((1, 2, 3)\) by factors \(2, 3, 4\) along the x, y, and z axes. Write down the scaling matrix and the resulting point.
Solutions
Solution 1: Translation
Translation matrix:
\[
T = \begin{bmatrix}
1 & 0 & 0 & 1
0 & 1 & 0 & -1
0 & 0 & 1 & 2
0 & 0 & 0 & 1
\end{bmatrix}
\]
Resulting point:
\[
\begin{bmatrix}
1 & 0 & 0 & 1
0 & 1 & 0 & -1
0 & 0 & 1 & 2
0 & 0 & 0 & 1
\end{bmatrix}
\begin{bmatrix}
2
3
4
1
\end{bmatrix}
\begin{bmatrix}
3
2
6
1
\end{bmatrix}
\]
Solution 2: Rotation
Rotation matrix around the x-axis by 90 degrees:
\[
R_x(\pi/2) = \begin{bmatrix}
1 & 0 & 0 & 0
0 & 0 & -1 & 0
0 & 1 & 0 & 0
0 & 0 & 0 & 1
\end{bmatrix}
\]
Resulting point:
\[
\begin{bmatrix}
1 & 0 & 0 & 0
0 & 0 & -1 & 0
0 & 1 & 0 & 0
0 & 0 & 0 & 1
\end{bmatrix}
\begin{bmatrix}
0
1
0
1
\end{bmatrix}
\begin{bmatrix}
0
0
1
1
\end{bmatrix}
\]
Solution 3: Scaling
Scaling matrix:
\[
S = \begin{bmatrix}
2 & 0 & 0 & 0
0 & 3 & 0 & 0
0 & 0 & 4 & 0
0 & 0 & 0 & 1
\end{bmatrix}
\]
Resulting point:
\[
\begin{bmatrix}
2 & 0 & 0 & 0
0 & 3 & 0 & 0
0 & 0 & 4 & 0
0 & 0 & 0 & 1
\end{bmatrix}
\begin{bmatrix}
1
2
3
1
\end{bmatrix}
\begin{bmatrix}
2
6
12
1
\end{bmatrix}
\]
Conclusion
In this section, we explored transformation matrices and their role in translating, rotating, and scaling objects in 3D space. We learned how to construct these matrices and apply them to points using homogeneous coordinates. Understanding these concepts is essential for manipulating 3D graphics and forms the foundation for more advanced topics in 3D mathematics.
Mathematics 3D
Module 1: Fundamentals of Linear Algebra
- Vectors and Vector Spaces
- Matrices and Determinants
- Systems of Linear Equations
- Eigenvalues and Eigenvectors
Module 2: Linear Transformations
- Definition and Properties
- Transformation Matrices
- Rotations, Translations, and Scalings
- Composition of Transformations
Module 3: Geometry in 3D Space
- Coordinates and Planes
- Vectors in 3D Space
- Dot Product and Cross Product
- Equations of Planes and Lines