Linear Transformations and Manipulating points

We are going to do some geometry in the Cartesian plane. Perhaps counterintuitively, we will represent points as follows:

Important! $ \text{point }(x,y)\text{ is represented by column vector } \begin{bmatrix} x\\ y\\ 1 \end{bmatrix} $

Why the extra "1" coordinate? Just accept for a moment, and we will discuss once you've played around with these ideas for a bit.

We will look at linear transformations from $\mathbb{R}^3$ to $\mathbb{R}^3$, so if $T$ is a linear transformation, and if $\boldsymbol{u}$ is vector representing point $p$, then $T(\boldsymbol{u})$ gives us a new vector which (if we're lucky and the third coordinate is 1) corresponds to a new point. So $T$ maps points to points. So what kind of operations do we get?


  1. Download a0.cpp and save it to a suitable folder. Compile the program like this:
    g++ a0.cpp -o a0 -O2 -larmadillo
    ... and run it as: ./a0 An image like that on the right should popup on your screen.
  2. Change the line mat T = I; to mat T = A;, compile and run, and keep doing it for A,B,C,D.
    	    
    	    What does transformation A do?______________________
    	    
    	    What does transformation B do?______________________
    	    
    	    What does transformation C do?______________________
    	    
    	    What does transformation D do?______________________
    	  
  3. Try transformation T = A*B and then try T = B*A and compare the output. Explain why you get one result with A*B and another with B*A! (Make sure to check me that your explanation is correct!)
    Note: If you aren't already convinced that matrix multiplication is not commutative, you should be convinced now!
  4. If you look at the code, you will see that T is applied to u, i.e. we compute T*u. Let $T_A$ denote the transformation defined by matrix $A$, and let $T_B$ denote the transformation defined by matrix $B$. When we set T=A*B and apply $T$ to vector $\boldsymbol{u}$, are you computing $T_A(T_B(\boldsymbol{u}))$ or $T_B(T_A(\boldsymbol{u}))$?
  5. Final task: Modify the program to produce this image. You will probably be modifying the matrices, the angles and, of course, "T". When you've got it working, put a cout << T at the end of main. This will print out the matrix that defines your linear transformation T. Write it down (with just two digits after the decimal point).