Transformation Matrices in Computer Graphics
Learn how transformation matrices combine translation, rotation, and scaling in computer graphics. Understand homogeneous coordinates and the model-view-projection pipeline.
Detailed Explanation
Transformation Matrices in Graphics
Computer graphics uses 4x4 transformation matrices in homogeneous coordinates to represent all common transformations uniformly.
Homogeneous Coordinates
A 3D point (x, y, z) becomes (x, y, z, 1) in homogeneous coordinates. This allows translation to be represented as matrix multiplication.
Basic Transformations
Translation by (tx, ty, tz):
T = | 1 0 0 tx |
| 0 1 0 ty |
| 0 0 1 tz |
| 0 0 0 1 |
Scaling by (sx, sy, sz):
S = | sx 0 0 0 |
| 0 sy 0 0 |
| 0 0 sz 0 |
| 0 0 0 1 |
Rotation around Z-axis by angle a:
Rz = | cos(a) -sin(a) 0 0 |
| sin(a) cos(a) 0 0 |
| 0 0 1 0 |
| 0 0 0 1 |
The MVP Pipeline
In a standard graphics pipeline, vertices pass through three transformations:
- Model matrix: positions the object in world space
- View matrix: positions the camera (inverse of camera's transform)
- Projection matrix: maps 3D to 2D (perspective or orthographic)
clip_position = Projection * View * Model * vertex
Combining Transforms
Multiple transformations are combined by matrix multiplication. The order is right-to-left: the rightmost matrix is applied first.
M = Translation * Rotation * Scale
This first scales, then rotates, then translates — the correct order for most object transformations.
Use Case
Transformation matrices are the foundation of all 3D rendering. Every vertex in a 3D scene passes through a chain of matrix multiplications to produce its final screen position. Game engines like Unity and Unreal, graphics APIs like OpenGL and Vulkan, and 3D modeling tools all rely on 4x4 transformation matrices internally.