Matrix Multiplication and Transformations
What You’ll Learn
Section titled “What You’ll Learn”Matrix multiplication is the most important operation in linear algebra. In this lesson you’ll learn how it works and see how matrices represent transformations like rotation, scaling, and shearing in 2D and 3D.
The Concept
Section titled “The Concept”Matrix Multiplication
Section titled “Matrix Multiplication”To multiply (size ) by (size ), the number of columns in must equal the number of rows in . The result is an matrix.
Each entry in the result is a dot product: row of dotted with column of .
In the diagram: each entry of the result matrix is computed by taking a row from the left matrix and a column from the right matrix, multiplying corresponding entries, and summing. The color-coded highlights show which row and column produce each result entry.
Key properties:
- Matrix multiplication is NOT commutative: in general
- It IS associative:
- The identity matrix satisfies
Linear Transformations
Section titled “Linear Transformations”Matrices represent linear transformations, operations that take vectors as input and produce new vectors as output.
Common transformations:
Rotation by angle (2D):
Scaling by and :
Reflection across the x-axis:
In the diagram: a unit square (blue) is transformed by a 45° rotation matrix. The green shape shows the result after applying the transformation. Each vertex gets multiplied by the matrix to produce its new position.
In games, these are combined into a single model matrix that transforms every vertex of a 3D model.
Worked Examples
Section titled “Worked Examples”Example 1: 2x2 Matrix Multiplication
Top-left:
Top-right:
Bottom-left:
Bottom-right:
Example 2: Rotation (90° counterclockwise)
The 90° rotation matrix is:
Apply it to the point :
The point moves from to , a quarter turn counterclockwise.
Example 3: Dimension Check
is , is . Can we multiply?
Inner dimensions match (), so yes. Result is .
Can we compute ? is , is . Inner dimensions are , so no. Order matters.
Real-World Application
Section titled “Real-World Application”Matrix multiplication powers almost everything you see on screen in modern games:
- Every frame, the engine multiplies the model matrix view matrix projection matrix to transform vertices from 3D world space to 2D screen space
- Character animations use skeletal animation with bone matrices multiplied together
- Camera movement is handled by updating the view matrix
- GPUs are literally designed to do matrix multiplication as fast as possible
Example: When you rotate your camera in a first-person game, the engine updates the view matrix and multiplies it with every object’s model matrix. This happens for every vertex, every frame, thousands of times per second.
Retrying will remove your ✅ checkmark until you pass again.