Literasi (Team Teaching) - #34 Transformasi 2D dan 3D dalam Grafik Komputer (M5)
Table of Contents
Introduction
This tutorial focuses on the concepts of 2D and 3D transformations in computer graphics, based on the content presented in the YouTube video "Transformasi 2D dan 3D dalam Grafik Komputer." Understanding these transformations is crucial for anyone studying computer graphics and image processing, as they form the basis for rendering shapes and manipulating objects in digital space.
Step 1: Understanding 2D Transformations
2D transformations are operations that change the position, size, or orientation of 2D objects. Key types include:
- Translation: Moves an object from one location to another.
- Scaling: Changes the size of an object.
- Rotation: Rotates an object around a specified point.
Practical Advice
- Use matrices to perform these transformations efficiently. For example, the transformation matrix for translation can be represented as:
where| 1 0 Tx | | 0 1 Ty | | 0 0 1 |
Tx
andTy
are the translation distances along the x and y axes.
Step 2: Applying Transformations in Practice
To apply these transformations, follow these steps:
- Define the object in a coordinate system (e.g., vertices of a triangle).
- Create the transformation matrix based on the desired operation (translation, scaling, rotation).
- Multiply the object's coordinate matrix by the transformation matrix to get the new coordinates.
Example
For a triangle defined by vertices (1, 1), (2, 2), and (3, 1):
- To translate it by (2, 3), use the translation matrix mentioned above.
Step 3: Understanding 3D Transformations
3D transformations expand the concepts of 2D transformations into three dimensions. Key types include:
- Translation: Similar to 2D but includes the z-axis.
- Scaling: Adjusts size in all three dimensions.
- Rotation: Can occur around the x, y, or z axes.
Practical Advice
- The 3D translation matrix looks like this:
| 1 0 0 Tx | | 0 1 0 Ty | | 0 0 1 Tz | | 0 0 0 1 |
Step 4: Performing 3D Transformations
Follow these steps for 3D transformations:
- Define your 3D object (e.g., a cube or sphere).
- Construct the appropriate transformation matrix for the desired operation.
- Apply the transformation by multiplying the object's coordinates with the transformation matrix.
Example
For a cube with vertices defined in 3D space, apply a rotation around the z-axis with the rotation matrix:
| cos(θ) -sin(θ) 0 0 |
| sin(θ) cos(θ) 0 0 |
| 0 0 1 0 |
| 0 0 0 1 |
where θ is the angle of rotation.
Conclusion
In this tutorial, we covered the basics of 2D and 3D transformations in computer graphics, including how to perform translations, scaling, and rotations using matrices. Understanding these concepts is essential for creating and manipulating graphical objects in both 2D and 3D environments. As a next step, you might want to explore software tools that allow you to visualize these transformations or experiment with coding your own transformations using programming languages like Python or JavaScript.