What they're really, of course, is some weird pan-dimensional trickery, because of course when...
... we're working in 3D we add a fourth dimension on to the vectors,
... and a fourth row/column on to the matrices and we're doing a sheer operation...
... in four dimensional space, which casts a shadow of its objects back into 3-dimensional space
... as a translation
We chose in our description before that the origin was gonna be here,
...on the base of the pyramid. But, in theory, it could be anywhere in the universe.
You could specify the vertices relative to Mars, or New York, or this point on the table over here...
.. or the top of the pyramid, or the center, or whatever.
The origin becomes almost like a center of gravity of the object
... because any transformations we do on the vertices, are done relative to the origin.
Because they're done in the same coordinate space,
... the same frame of reference that the vertices are specified in.
So, transformations...
[off screen voice] So what's a transformation?...
That's a good question.
Yeah, we need to... We've specified our objects.
We specified the vertices and the faces.
The way we move objects around in 3D space, is by applying operations at the vertices, manipulating the vertices.
Uh, using transformations. What is a transformation?
Well there's three basics types of transformations
... that we'll cover ... There are others, but the three basic types are scaling,
translation, and rotation.
And we'll start with scaling, I suppose.
So, let's draw a triangle. Let's keep it 2d for simplicity's sake.
So, we want to scale our triangle. Everything that's applicable in 2 dimensions...
...will also work in 3 dimensions. Everything we're going to talk about will work in 3 dimensions.
For now let's just work on scaling. We want to scale, let's say, vertically.
So, the way we do that, we write out our coordinate.
Let's just use, um, vertix A as an example.
In mathematics, uh, these coordinates are called vectors.
Vectors are just arrays of numbers, I mean, everyone is pretty familiar with vectors...
I like to write them vertically, you can write them horizontally
doesn't really matter, but I think it's probably more clear
if we write it vertically
to scale a vector, we just need to do a simple multiply operation
so we want to scale vertically
so, we don't want to scale an x
so we'll keep that as one.
What we do want to scale, is Y
so we'll scale by 2 and to get the answer all we do is
0 times 1 is 0, 1 times 2 is 2
And the result, if this is our new coordinate A...
it's up here.
A equals (0, 2).
Well if we apply that same transformation to our, um,
two vertices that are on the x axis, we find that they're unchanged.
Because, um, minus 1 times 1 is 1 -- there's minus one
and 0 times 2 is still 0.
So those vertices still lie on y=0
Translation works exactly the same,
however, instead of multiplying, we add.
Here's our triangle that we started with
So say we now want to translate it
one unit this way.
Well, let's take this coordinate as an example
So, we have 1 in x and 0 in y
plus, we want to move 1 unit in x
so, plus 1 unit in x and 0 in y.
Equals (2, 0).
So, this point now lies over here.
And if we do that to all the vertices of our shape
We get this.
So, we've had
Scaling...
and Translation.
Both work very much the same.
One's a multiplicative operation on a vector
and the other is an additive operation.
Rotation is slightly more complicated
and involves trigonometry.
So, I'll just write out the formulas.
Trigonometry tells us that
for any given angle, A,
are points x, new x, and new y.
Somewhat convoluted, but
that's trigonometry, isn't it?
Let's take our triangle again.
So this is our x axis, this is our y axis.
We have our vertices, as before.
Let's take this point again,
and we want to rotate it,
by 90 degrees anti-clockwise.
So, we'll follow our formula along here.
So, our new x value
is going to be
the x value here, which is (1, 0)...
[inaudible]
Because y is 0,
these cancel out.
x equals 0, y equals 1. So our new coordinate is (0, 1) which is what we'd
expect because we're rotating by 90 degrees. So that covers scale, translation
... and rotation and by applying these simple operations - maybe not so simple in
the case of rotation we can move our object around by manipulating the
vertices and we call these transformations now there's actually - if
we go back to rotation - there's another way to write out this formula that will
seem strange at first. But bear with me because the benefit of it will hopefully
become clear. We can draw a little table I'll try and make it a bit smaller
this time. This basically represents exactly the same information that we've
got here but just in a slightly different format. What we do is we
multiply our inputs down the columns and then sum across the rows to get the result
So if we just take our example that we had before of coordinate (1, 0)
wasn't it? So our x = 1 and y = 0. So let's write our inputs in the
top here. 1 times, 0 times.
And the cosine of 90, which we want here, is 0.
And also the cosine of 90 for this part here is 0.
Minus sine 90 is -1 and sine 90 is 1
So what did I say before? We multiply down the columns, and then ...
... we sum across the rows. So 1 x 0 = 0 and 1 x 1 = 1
0 x -1 = 0 and 0 x 0 = 0. So then we sum across the rows to get ...
... new x and new y. 0 + 0 = 0 1 + 0 = 1
... which is the answer we got before.
This representation of these formulae here...
... is in mathematical terms called a matrix.
Matrices are very important and useful objects when it comes to manipulating vectors.
So let's just for clarity write out the rules for multiplying a vector by a matrix.
So that sums up exactly what we were doing in the table here.
We're multiplying down the columns and we're summing across the rows.
So we've been able to represent rotation using a matrix format.
Let's now go on and see if we can represent scale in the same way.
So using our rules from before we can take a vector, say (1, 1)...
...and the scale matrix.
So what we want to do is scale, let's say in the y direction.
So we want to stay the same in x and multiply by 2 in y...
... and then put zeros here.
So following our rules for vector matrix multiplication,
we can see that the new x component is....
(1 x 1) + (1 x 0) = 1
(1 x 0) + (1 x 2)= 2 Is that the same answer that we were getting before?
Let's just try our old-fashioned 'vector x vector' multiplication to do a scale.
[mumbling vectors]
1 x 1 = 1 1 x 2 = 2
it's the same!
It's probably a good idea to explain why we would do it this silly...
... convoluted way.
Why would we take something that was very simple before, just adding and multiplying vectors
And then re-representing them in this strange format.
In going through these complicated rules of addition and
multiplication to get the same answer.
We have to apply these transformations on every single vertex...
... In order to move these 3D objects around in 3D space. That's really what we're trying to achieve.
So with the simple operations it's fine but we have to apply them all separately,
... one after the other.
And that's okay for a five vertex pyramid,
... but if you've got a hundred thousand vertices it quickly becomes quite costly.
And the more transformations that you have to apply at every single vertex
the more costly it becomes.
And this is where the power of the matrix lies.
This format allows us to actually multiply together two matrices.
And by multiplying together two matrices we get a third matrix, which represents...
the two transformations that were encoded in the original two matrices.
What we can do is concatenate and combine transformation after transformation,
simply by multiplying matrices together. And we can do that to compute a single
transformation matrix, which we then apply to every single vertex.
So we don't have to do transformation after transformation after transformation,
we can just do one operation: a matrix vector multiply at every vertex.
Let's have a quick look at the rules for (matrix x matrix) multiplication
... and if Sean has any sense he'll cut this bit out because it's really dull.
We've represented scale, we've represented rotation in matrix form.
Now I said before: 'Can we do translation?' And the answer is 'yes', but it's difficult.
Because of this multiplication everywhere there's nowhere that we can put our...
...translation vector because scale and rotation are multiplicative operations,
whereas translation is an additive operation and we can't do simple adds:
With the matrix' multiplication rules everything gets multiplied somewhere.
What we really want to do is say something like this:
We want to say that our new vector equals the old vector...
... times our transformation matrix...
... plus a translation.
Ideally, what we'd want to do is move this translation into the matrix.
But there's nowhere for us to put it because this is an additive operation an additive operation,
... and the matrix is for multiplies.
The way we do it is by using a little trick.
Instead of just having X and Y,
... we add an extra dimension onto our vectors.
And we fill it with 1.
We have to do something similar to the matrix in turn so that the rules can still be applied.
So we go a, b...
Oops!
We then have to have c, d, e, f,
0 0 1
and we have to have then a special value at the bottom here.
Let's just do the formula for X based on our previous rules,
... but with the extra rows and columns added on.
So, yeah let's just follow along here.
We've got xa + yb + (1 times C)...
xd + ye + (1 times f)
... and then we've got
(1 x 0) + (1 x 0)...
... + (1 x 1).
What we're doing here is we're multiplying as we were doing before, but multiplying by one.
So these values C and F remain the same,
...but they get added on to the previous result.
So the net effect of what we've done is that found a tricky way...
... to be able to do addition inside the matrix.
Which means that we can throw translation in there now. C and F can be our translation vector,
... and it will be multiplied by one and added to the results.
It seems like a bit of a hack, a bit of a weird trick.
But what we're really doing is moving...
...our simple 2D shape ...
... on its 2D plane...
... into the third dimension.
So that it exists on a single plane in 3D space.
And the special matrix with the extra row is doing...
... a three dimensional shear in 3d space but in the 2D space of the plane that looks like a translation.
So we've seen how it kind of works mathematically, and...
... what we're really doing of course is some weird pan-dimensional trickery,
... because of course, we're when we're working in 3d we add a fourth dimension onto the vectors,
... and a fourth row and column onto the matrices and we're doing a shear operation
... in four dimensional space which casts the shadow of its objects ...
... back into three-dimensional space as a translation.
It looks like a translation in 3d but really it's...
...mind-blowing
no matter how you arrange the three vertices of triangle they will always
lie on the same plane in space how not to store passwords emitted thank you
because you you really shouldn't store passwords yourself if you can all avoid
it