Main content

## Algebra (all content)

### Course: Algebra (all content) > Unit 20

Lesson 10: Matrices as transformations- Transforming vectors using matrices
- Use matrices to transform 3D and 4D vectors
- Transforming polygons using matrices
- Transform polygons using matrices
- Matrices as transformations
- Matrix from visual representation of transformation
- Visual representation of transformation from matrix
- Understand matrices as transformations of the plane

© 2023 Khan AcademyTerms of usePrivacy PolicyCookie Notice

# Transforming polygons using matrices

Sal transforms a triangle using a 2x2 matrix. Created by Sal Khan.

## Want to join the conversation?

- Is the new (transformed) triangle similar to the original triangle? (Its clearly not congruent)(27 votes)
- No, they are not similar. There are some transformation matrices that preserve congruence (rigid body transformations, such as reflections, rotations, and translations). And scaling matrices produce similar triangles. However, a matrix exists to convert any non-degenerate triangle into any other triangle.

An example of a matrix that would produce similar triangles, is the rotation matrix:`cos(a) -sin(a)`

sin(a) cos(a)

This will rotate the triangle around the origin by a.(21 votes)

- Is there an explanation for why this "prime" vector is used? Why not call it like Position Vector a1 or Transformed Position Vector 1?(9 votes)
- Your question suggests a possible answer, Quintin. Look at how many keystrokes it took to write
*Transformed Position Vector 1*. Compare that to just adding an apostrophe. If Sal used the longer names, he'd use up a lot of extra time (and space on the display). On the other hand, the longer name makes it clearer what the relationship is to the original vector. The "prime" notation only indicates that vector V is somehow related to vector V'. It doesn't tell you anything about what that relationship is. There's a lot of this sort of tradeoff in mathematics, and terseness sometimes wins over clarity.(33 votes)

- At1:30

Sal combined three matrices into one. Is That acceptable?

If it is, will someone kind enough to tell me the circumstances of combining matrices?

Will the answers be the same either it is combined or seperated?(17 votes)- Well, he explained that they were all position vectors. What that tells us is that they are all made up of the same kinds of information: an x position and a y position. We could have 30 position vectors combined like this.

In Sal's example, the output was a recipe for the new position of each vector. Notice, with the way he designed his matrices, he started with 3 points (vertices of a triangle) and he ended with new locations for each of those points (vertices of the transformed triangle). You would want to think through whether the information that you start with has comparable meaning and that you end up with a sensible answer. If your triangle suddenly had four points, this could be a problem.

In another kind of matrix, from the business world, you might have sets of products of different sizes or fancy decorations with an original set of prices, and then run a transformation matrix to create a new set of prices on the products so that the larger or fancier products have a greater price increase. You can add any number of products to your product matrix and run the same transformation matrix.(9 votes)

- Matrix multiplication is not commutative. Is there a mathematical reason why the transformation matrix (T) is always first in a transformation or is it simply a convention?(12 votes)
- Yes, there is a reason -- it's because we typically write the coordinates of our points as columns. So to deal with the coordinates of just one set of points at a time, we put the transformation matrix (T matrix) first so that when we do the multiplication, we take rows of the T matrix and columns of the matrix of points. If we put the T matrix second, we would be multiplying rows of the matrix of points -- that is, lumping all the x-coordinates of our set of points together, and then all the y-coordinates of our points together. This would mean that the transformation not only depends on the T matrix, but also on the exact set of points chosen, and this isn't mathematically very helpful, so we don't do it.(12 votes)

- so can the T matrix only be 2 x 2?(6 votes)
- Not necessarily, all transformation matrices will always be square matrices, but they can be bigger than 2 × 2, depending on the kind of transformation and the dimension of the objects they affect.(10 votes)

- How EXACTLY can VECTORS be used in the COMPUTER GRAPHICS WORLD?(3 votes)
- One example would be the OpenGL standard; it's a framework to create 3D computer graphics, used by a great percentage of modern 3D programs, from 3D drawing software to 3D games. It's very efficient in part because it forces the programmer to go down to the math basics to draw anything.

If you want to draw a point, you have to specify it's position in 3D space, and for that you use a vector.

If you want to specify that a surface should be illuminated you have to give OpenGL the normal to that surface, and that is another vector.

And I'll answer your question about matrix multiplication here as well, since all 3D transformations you make in OpenGL, from moving the camera to creating complex shapes require you to work with transformation matrices, and the way to link together transformations is to multiply the different transformation matrices.(13 votes)

- How to write transformation Matrix? Or it can selected randomly.(3 votes)
- Transformation matrices are not selected randomly, but for their particular transformation property. Transformations include shearing, scaling, translation, rotation.

Here are some examples of transformation matrices:

https://upload.wikimedia.org/wikipedia/commons/thumb/2/2c/2D_affine_transformation_matrix.svg/250px-2D_affine_transformation_matrix.svg.png(10 votes)

- Why didn't Sal multiply the three position vectors separately?(5 votes)
- Because we already know that it is possible to multiply them separately, he was demonstrating that the technique worked when all vectors were placed into a single matrix representing the triangle.(5 votes)

- does transformation matrix have to be a square matrix??(3 votes)
- no, remember when we multiply matrices we need the first one to have the same number of columns as the second one's rows, basically if you get a 2d vector use a 2 by k matrix and the multiplication will work out(but the result may not be particularly useful ), similarly for 3d vectors use 3 by k matrix. hope that helps, sorry for late reply(2 votes)

- hey sal does the trig ratio in this triangle remain the same in the example shown in this video?

My opinion say yes because all the points are multiplied by same matrix(1 vote)- Yes, to be similar, each side of your triangle has to be proportional (via the same constant) to its corresponding side on the transformed triangle, which is true from your distance calculations.

Or, you can have a combination of corresponding angles and sides or corresponding angles have to be congruent (equal).

So, even without the angles, you have shown they are similar, at least for the triangles.

Soooo,

I have some little tools that I use for checking congruency and similarity and slope and all kinds of similar aspects of geometry and math. I used my Law of Cosines tool and ran your side lengths. Guess what! Each angle was congruent to its corresponding angle on the other triangle.

So your matrices worked. Ta Da!(1 vote)

## Video transcript

Voiceover:We've already used a transformation matrix
to transform one point, what I want to do in this video, is transform a series of points. So, I have these position vectors, p1, p2, and p3, and I've plotted them right over here. And you can imagine them to even be vertices of a triangle that looks something like this (that's one side, that's another side, and that's another side, right like that) and what I'm curious about is what happens if I transform
these three points? And like the last video, I could apply this transformation matrix separately to each of them to see what they transform into, or instead I could take
this transformation matrix, and multiply it times a matrix composed of these position vectors, so let me do that... Let me take my transformation matrix, let me copy and paste that. So, copy and paste. So, I'm going to take
my transformation matrix and I am going to multiply that by a matrix that has all three of these position vectors in it, where each of the columns of this matrix is going to be one of
these position vectors. So, the first one is 2, 1. Then we have -2, 0 Then we have 0, 2. So, one way you could think about it is we're taking our transformation matrix and we're multiplying it by a matrix that is composed of the first column is position vector 1, the second column is position vector 2, and the third column is position vector 3. Now, what is this going to give us? Well, this is a 2x2 matrix. We're multiplying it by a 2x3 matrix, so matrix multiplication
is defined over here because the number of columns here is the same as the number of rows here. And it's going to result in a 2x3 matrix. So, it's going to result in a 2x3 matrix. So, 2 rows and 3 columns, which we could imagine represents three new position vectors. So, what's this going to be? Let's go step by step. So, this first entry, first row, first column, is this row times this column, so 2x2 which is 4, plus 1 plus 1, so it's 4 plus 1 so this is going to be 5. Let me do it in a different color. -1 times 2 is -2. plus 2 times 1 plus 2, that's -2 plus 2 which is 0. So, we already see it transformed 2,1 to 5,0. 1, 2, 3, 4, 5. So if we consider this p1, we consider this p1 prime, p1 after our transformation. Now, let's go to p2. 2 times -2 is -4, plus 1 times 0, so it's -4 plus 0, which is just -4. And then -1 times 2 is positive 2, plus 2 times 0, which
is just going to be 0. So it's going to be positive 2 plus 0, which is just 2. So, -4, 2. Negative 1, 2, 3, 4 comma 2. Right over here. So this is p2 This was p2 right over here. This is p2 prime. This is position vector p2 prime. Or the position that position vector p2 prime would specify. And then finally, let's look at p3. So we have 2 times 0, which is 0, plus 1 times 2, so that's zero plus 2 or just 2, and then we have -1 times 0, which is 0. plus 2 times 2 is four. So, we get the point 2, 4. So, 2 comma 1, 2, 3, 4... we go right over here. So, this is p3 right over here. This is p3 prime. And so something interesting has happened. We now have the vertices you could imagine of a new triangle. Of a new triangle that
looks something like this. That looks something like this. So, what you can imagine is... Actually, let me draw it... Let me draw our new one
with this blue color. so we can see it a little better. So we went from that smaller triangle, we went from that smaller triangle to the larger one, this is the smaller one right over here. That's our smaller triangle to the larger one, or another way you could think of it, this entire triangle was transformed, and right now we only
transformed the vertices, but it actually turns out, and I'm not proving this video, that if you transformed- if you took any of these
points on this triangle, it would have transformed to a corresponding point on
this larger triangle. And what's neat about this is hopefully you're starting to appreciate the power of a transformation matrix. And hopefully you're
starting to appreciate why this is useful as you
start to think about things like computer games and animation, because what transformation matrixes allow us to do, and this is what these computer programs allow us to do - view things from different perspectives, what they're actually
doing under the covers, is they're using transformation matrixes, and they're multiplying
them times coordinates, in order to get new coordinates based on the position or the
perspective of the player, or the position or the
perspective of the camera, or the virtual camera in
a computer graphics world. So two, I guess, several neat things here, is we haven't just
transformed a point now, we've transformed three points, which could represent the
vertices of a triangle, and you see it as this kind of expansion and rotation that seems to have happened when we used this transformation matrix. If we use a different
transformation matrix, we would have a different transformation and not only did we do it, but we saw that we could
do it with multiple position vectors as the same time. I could have done it independently and gotten the same result, but this is hopefully starting to show you the power of matrixes, and why
it also could be useful in things like computer
graphics and animation and things like that.