Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 26

Matrix Transformations: Scaling, Rotation, and Shear

Recommended resources

Introduction

In our last lesson, we established a powerful new perspective: a matrix is not just a grid of numbers, but an operator that performs a linear transformation on vectors and spaces. We explored how matrix multiplication calculates the result of these transformations and how multiplying matrices together composes them, like applying a rotation and then a shear.

Today, we're going to master the other side of this relationship. Your goal for this lesson is to learn how to describe linear transformations (scaling, rotation, shear) using matrices. Instead of being given a matrix and finding its effect, you will start with a desired geometric effect and construct the precise matrix that produces it. This skill bridges the gap between a visual, geometric goal and the concrete algebraic object needed to execute it—a foundational concept for building and understanding AI systems that manipulate data in high-dimensional spaces.


1. The Universal Recipe for Finding a Transformation Matrix

The previous lesson hinted at the core idea, and it's so fundamental that we will start by focusing on it exclusively. A 2D linear transformation is completely determined by where it moves the two standard basis vectors: (the vector ) and (the vector ).

Why? Because any vector can be written as a linear combination of these basis vectors: . Because the transformation is linear, the transformed vector will be the same linear combination of the transformed basis vectors:

This gives us a universal recipe:

  1. Find where the basis vector lands after the transformation. These coordinates will be the first column of your matrix.
  2. Find where the basis vector lands. These coordinates will be the second column of your matrix.

That's it. The resulting 2x2 matrix perfectly encodes the transformation.

To see this principle in action, let's watch a segment from the video we saw last time, but with a new focus.

Linear transformations and matrices | Chapter 3, Essence of linear algebra

This clip from 3Blue1Brown's 'Linear transformations and matrices' demonstrates exactly how to apply this recipe to construct matrices for a rotation and a shear.

Watch the segment from 08:00 to 08:55. Observe carefully how he constructs the matrix for a 90-degree rotation and then for a shear transformation by simply tracking where i-hat and j-hat land.


2. Formalizing the Recipe: The Standard Matrix

The intuitive recipe you just saw has a formal name in linear algebra. Let's define the terms properly, which will be helpful for more advanced topics. This aligns with your preference for understanding the theory first.

Linear Transformations

The textbook 'Interactive Linear Algebra' by Georgia Tech provides a formal definition of what we are doing. This reading will introduce the terms 'standard coordinate vectors' and the 'standard matrix' of a linear transformation.

Please read two subsections from this webpage: Start with 'Subsection 3.3.2 The Standard Coordinate Vectors'. The vectors denoted as e1, e2, ... are the formal names for what we've been calling i-hat, j-hat, etc. Then, read 'Subsection 3.3.3 The Matrix of a Linear Transformation'. Focus on the main theorem. It states exactly what we discussed: the matrix A for a transformation T is formed by columns that are the result of applying T to each standard coordinate vector.

The key theorem from this reading confirms our recipe: For a linear transformation , its standard matrix is given by:

where and .


3. A Gallery of Geometric Transformations

Now, let's apply this recipe to build the standard matrices for the three key transformations mentioned in our learning outcome: scaling, rotation, and shear.

Scaling

A scaling transformation stretches or compresses space along the axes. Let's say we want to scale by a factor of along the x-axis and along the y-axis.

  1. Transform : The vector is scaled by along the x-axis. It becomes . This is our first column.
  2. Transform : The vector is scaled by along the y-axis. It becomes . This is our second column.

Combining these gives the general scaling matrix:

A scaling that is the same in all directions () is called a dilation. A scaling of gives the identity matrix, which does nothing.

For a worked-out numerical example, watch this short video segment.

Linear Algebra: Scaling and Shearing Transformations

This video from Center of Math provides a clear, step-by-step calculation of a scaling transformation.

Watch the segment from 02:15 to 04:15. The instructor demonstrates scaling a vector [1, 2] by a factor of 2. Notice how the matrix they use, [[2, 0], [0, 2]], is a specific instance of the general scaling matrix we just derived.

Rotation

Let's find the matrix for a counter-clockwise rotation by an angle about the origin. We need a little trigonometry.

  1. Transform : The vector , a point on the positive x-axis, rotates to the point . This is our first column.
  2. Transform : The vector , a point on the positive y-axis, rotates to the point , which simplifies to . This is our second column.

Combining these gives the rotation matrix:

To see this laid out, you can refer to the following resource.

Geometry of Linear Transformations

This tutorial from Harvey Mudd College clearly shows the derivation of the rotation matrix by considering the destinations of the basis vectors.

Read just the short section titled 'Rotations'. It provides the standard matrix and shows the transformed basis vectors that form its columns.

Quick Practice: What is the matrix for a counter-clockwise rotation of 90°?
(Hint: , )
The matrix is . This matches the result from the 3Blue1Brown video.

Shear

A shear transformation slants space, keeping one axis fixed.

  • Horizontal Shear: The x-axis is fixed, and points are shifted horizontally depending on their y-coordinate. Let be the shear factor.
    1. Transform : The vector is on the x-axis, so it doesn't move. It stays at . First column.
    2. Transform : The vector is shifted horizontally by (since its y-value is 1). It lands at . Second column.

The horizontal shear matrix is:

  • Vertical Shear: Similarly, a vertical shear fixes the y-axis and shifts points vertically based on their x-coordinate. The matrix is:

Let's watch a final clip to see both types of shear transformations calculated numerically.

Linear Algebra: Scaling and Shearing Transformations

The same Center of Math video also provides clear examples of both horizontal and vertical shearing.

Watch the segment from 04:03 to 07:55. Observe the calculation for a horizontal shear and then for a vertical shear. Note how the resulting matrices match the general forms we just derived.


Conclusion

Today you've reversed the flow of logic from our last lesson and gained a powerful new skill. Instead of just analyzing a given transformation, you can now build one from scratch to achieve a desired geometric outcome.

Key Takeaways:

  • The Universal Recipe: Any 2D linear transformation is fully described by a 2x2 matrix whose columns are the coordinates of the transformed basis vectors, and .
  • Scaling Matrix: Stretches or compresses along the axes. It's a diagonal matrix: .
  • Rotation Matrix: Rotates the plane counter-clockwise by angle . It involves sine and cosine: .
  • Shear Matrix: Slants the plane. A horizontal shear is , and a vertical shear is .

Preview of the Next Lesson:
We now know how to represent and build transformations. But what if we want to quantify their effect or reverse them? In the next lesson, we will learn how to compute the determinant and inverse of a matrix. The determinant will give us a single number describing how much a transformation expands or contracts area, and the inverse will give us a new matrix that represents the "undo" operation for the original transformation.