If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Matrix from visual representation of transformation

Learn how to determine the transformation matrix that has a given effect that is described visually.

Warmup example

Let's practice encoding linear transformations as matrices, as described in the previous article. For instance, suppose we want to find a matrix which corresponds with a 90degrees rotation.
Khan Academy video wrapper
The first column of the matrix tells us where the vector [10]\greenD{\left[ \begin{array}{c} 1 \\ 0 \end{array} \right]} goes, and—looking at the animation—we see that this vector lands on [01]\left[ \begin{array}{c} 0 \\ 1 \end{array} \right]. Based on this knowledge, we start filling in our matrix like this:
[0?1?] \left[ \begin{array}{cc} 0 & ? \\ 1 & ? \end{array} \right]
For the second column, we ask where the vector [01]\redD{\left[ \begin{array}{c} 0 \\ 1 \end{array} \right]} lands. Rotating this upward facing vector 90degrees yields a leftward facing arrow—i.e., the vector [10]\left[ \begin{array}{c} -1 \\ 0 \end{array} \right]—so we can finish writing our matrix as [0110] \left[ \begin{array}{cc} 0 & \redD{-1} \\ 1 & \redD{0} \end{array} \right] .
Now you try!

Practice problems

Problem 1
What matrix corresponds with the following transformation?
Khan Academy video wrapper
Choose 1 answer:
Choose 1 answer:

Problem 2
What matrix corresponds with the following transformation?
Khan Academy video wrapper
Choose 1 answer:
Choose 1 answer:

Problem 3
What matrix corresponds with the following transformation?
Khan Academy video wrapper
Choose 1 answer:
Choose 1 answer:

Problem 4
What matrix corresponds with the following transformation?
Khan Academy video wrapper
Choose 1 answer:
Choose 1 answer:

Problem 5
What matrix corresponds with the following transformation?
Khan Academy video wrapper
Choose 1 answer:
Choose 1 answer:

Problem 6
What matrix corresponds with the following transformation?
Khan Academy video wrapper
Choose 1 answer:
Choose 1 answer:

Want to join the conversation?

  • blobby green style avatar for user dr4jrh
    You lost me on this one.
    (8 votes)
    Default Khan Academy avatar avatar for user
    • old spice man green style avatar for user Robert Willis
      The answer to each question can be easily found by looking at where the green and red basis vectors end up after each transformation, and encoding where they do in a 2X2 matrix as follows:
      _ _
      | green-x-coord red-x-coord |
      | |
      | green-y-coord red-y-coord |
      |_ _|

      It is really that simple. The green vector is the vector that defines the x-axis and has length 1, labeled "i" with a little caret on top, pronounced "eye-hat," while the red arrow in the vector that defines the y-axis and has length 1 as well, labeled "j" with a little caret on top, pronounced "jay-hat." The 2x2 matrix has two columns: the left column says where i-hat ends up after the transformation, and the right column says where j-hat does.

      I hope that helps a bit. :-)
      (8 votes)
  • leafers ultimate style avatar for user Jan
    Hi everyone,

    after seeing the videos, I understand how to do a transformation that corresponds to a 90° rotation or a rotation multiple of 90°.

    Now I am wondering what might be a rule to translate a transformation expressed as a matrix into a rotaion expressed in degree.

    My intuition says that
    1.) I would need to rotate the x and the y component by the same degree if I do not wish to somehow squeez my vector/figure/coordinate system.
    2.) I would probably able to calculate the matrix that corresponds to a rotation of given degrees using the unity circle and the sine etc functions.

    So I would need to calculate the angle phi for any given point P in the coordinate system, add the angle I would like to rotate it, and then calculate the respective x,y coordinates.

    Is this reasoning correct?

    And if I want to resize the object (as in the tasks earlier), I assume, I could alter the magnitude of the vectors pointing to each corner of the object. But what would I need to do to alter the size of object and altering the distance to the origin at the same time, e.g. enlarge a triangle and at the same time get it closer to the origin? Would that still be a linear transformation?

    Thanks in advance :-)
    (6 votes)
    Default Khan Academy avatar avatar for user
    • leaf orange style avatar for user D. v.
      Your assumption is correct but you don't need to retrieve the original angle of the rotated point first. The trigonometric identities tell you that x'=x⋅cos(θ)-y⋅sin(θ) and y'=x⋅sin(θ)+y⋅cos(θ). And since matrices are all about forming i values each formed from j others values in different proportions, the matrix come by itself :

      +cos θ   -sin θ
      +sin θ +cos θ


      Since θ is a given constant, sin θ and cos θ are also constants, so you can replace each every expression in the matrix by its numerical equivalent if you wish to do so.

      As regards your last question, to translate your figure, you indeed need to ADD a matrix to your result, which is no longer linear. However, it remains possible to perform an affine transformation in a single operation (multiplication of a square matrix), by adding one more dimension : https://en.wikipedia.org/wiki/Transformation_matrix#Affine_transformations
      (2 votes)
  • female robot grace style avatar for user Isaac Kriegerventh
    So we are saying that the result of every linear transformation of the vector zero is the vector zero? In order to be a Linear Transformation?
    (3 votes)
    Default Khan Academy avatar avatar for user
  • leaf green style avatar for user Samson Lawal
    Are matrix transformations always represented as a 2x2 matrix? The textbook I'm using suggests that but I want to be sure.
    (3 votes)
    Default Khan Academy avatar avatar for user
  • piceratops ultimate style avatar for user Miguel Bartelsman
    Is it standard to use

    [1, 0]
    [0, 1]

    as a base for linear bidimensional transformations? or does this need to be specified like so:

    [1, 0] > [a, b]
    [0, 1] > [c, d]
    (3 votes)
    Default Khan Academy avatar avatar for user
    • leaf grey style avatar for user Alex
      The columns (not rows) of the n * n identity matrix are considered the standard basis for R^n, so yes, [1, 0]^T and [0, 1]^T are the columns of I_2 and are thus the standard basis for anything in R^2. They even have special names: {i-hat and j-hat}, or {e_1, e_2}.
      (3 votes)
  • duskpin sapling style avatar for user Xuyang Cao
    Each vector in the question is broken into its corresponding x and y. However, I am wondering that instead of expressing the linear transformation by the matrix, could I express the transformation by using a general formula and without breaking down the vector?

    Like in the warmup example, suppose there is a vector-valued function h in which two-dimensional vector V is transformed into two-dimensional vector W. Then I generalize a function h(v1, v2)=(-v2, v1), where in the right part of the equation the -v2 represents the returned w1, and v1 represents the returned w2. This specific function could represent the 90-degree rotation, as desired.

    And thus what's the difference between using a linear algebra function and the matrix method which breaks down the vector? Does one have more advantages over the other? Thanks a lot.
    (3 votes)
    Default Khan Academy avatar avatar for user
    • spunky sam red style avatar for user Bernard Field
      A good observation. Any linear function can be represented using a matrix. The benefits of using a matrix is that we get to use all the theory associated with matrices, such as Gaussian elimination, eigenvectors, determinants, matrix multiplication (as opposed to function composition), inverse matrices, etc.
      (3 votes)
  • aqualine tree style avatar for user White
    I honestly think 3b1b's Essence of Linear Algebra is one of the most enlightening things you can find on the internet.
    (2 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user Yurii Tsap
    Maybe I don't quite catch it, but why in every sample the vector start point is [0,0]?
    And what will be if we will operate with more complicated vectors, what the transformation matrix will look like?
    (2 votes)
    Default Khan Academy avatar avatar for user
  • primosaur ultimate style avatar for user Callen
    Can someone explain what the vector actually does to the object in question 5? Does it rotate
    [-2 0]
    [-1 -1]
    the camera (or object) 180 degrees left or right, does it increase/decrease the size by -1, what exactly does it do? Thanks!
    (2 votes)
    Default Khan Academy avatar avatar for user
    • aqualine sapling style avatar for user Michael C.
      It's a very odd transformation, to be sure.
      It is rotate 180 degrees, scaled by 2 in the x-axis, but also seems to have what is called a "shear" transformation. See: https://en.wikipedia.org/wiki/Shear_mapping .

      tl;dr, it is where the graph "shifts" on either side of an axis by +k magnitude (not direction).
      See that the (1,0) gets put into (-2, -1).. it would be (-1, 0) due to the rotation, * 2 = (-2, 0) for scaling, and - (0, 1) = (-2, -1) for sheer.

      Hope this helps!
      (3 votes)
  • duskpin ultimate style avatar for user mathnerd28
    How does Example #6 end up as [1,.5] [.5, 1]? It looks to me like the vector lands on [-1,0], [0,-1]. What am I seeing wrong? Thanks!
    (1 vote)
    Default Khan Academy avatar avatar for user