Topics About Contact Resources Quotes

Interactive Linear Transformations

Linear transformations are simple.
Let's view our 2D space as two vectors , a horizontal and vertical vector, then we can visualize how to transform (rotate, scale, skew) our 2D space.

Let's call the horizontal vector (x axis) the i vector.
Let's call the vertical vector (y axis) the j vector.

The default i vector is (1, 0) and the default j vector is (0, 1).

A vector tells us how far go (it's length) in a certain direction.
Moving a vector does not change a vector!


For example, our vector i is positioned at (0, 0), a direction of straight to the right, with a length (or magnitude) of 1.
Experiment with our i vector and j vector below before reading further
Notice how our vectors are laid out in the top left; Remind you of a matrix?
That's no accident, a matrix simply stores both vectors

How To Calculate Linear Transformations

Let's look at a simple, concrete example, let's take the point p = (1, 2).
Let''s set our i vector to the default value of (1, 0) and our j vector to the default value of (0, 1).

How do we use these vectors to tell us what our point p will be in our transformed space?

Simple, let's take it one component at a time.
First let's take the x component of our point p (1, 2) which is 1 (the x component is the first number of a point by convention) then we will do the following to it. x = (p.x * i.x) + (p.x * j.x) When we plug the values of our point and vectors in we get x = (1 * 1) + (1 * 0).Great, we just found our x!

Our transformed x = 1.

Now let's do the same thing for the y. y = (p.y * i.y) + (p.y * j.y)When we plug the values of our point and vectors in we get y = (2 * 0) + (2 * 1). Our transformed y = 2.

Super easy! Just addition and mulitplication.

Hold On!

Our transformed point is (1, 2) that is the same as our orignal point p!

Why is that?

Our transformed point is the same as p because our vectors i and j are at their default value!

If we don't want to transform our 2D space, we can assume our i and j vectors are at their default values of i = (1, 0) and j = (0, 1).

In that case, we can skip these calculations, which is what we usually do, but it is still helpful to think about 2d (and 3D) space with these transformations in mind.
Notice that in the interactive these calculations are in the upper right So we can see that these transformations are like a machine, we put in a point and we get out a transformed point.
How the point is transformed depends on the values of the i and j vectors.
If our i and j vectors are at their default values we get the same point out that we put in,
however if the i and/or j vectors have been transformed we get out our point in the transformed 2d space!
If we make our vector i point in the same direction as our vector j (they can point in any direction, they just need to be pointing in the same direction) our 2D space has become a 1D space!

The magnitude or length of the vectors cannot both be (0, 0) otherwise you would have no space at all.

Conclusion

So we see how easy it is to transform our 2D space, we simply transform our i vector and/or our j vector.

We can also see how easy it is to transform our 2D space to 1D space, we simply make our i vector and our j vector point in the same direction (which means they are colinear)!

Resources