Phys121VIU said:
This was a question for a test of mine. I am unsure how to translate the object from the left image(Fig.1) to the right (Fig.2). I am to use matrix multiplication..
Do i start with the vertices in Fig.1 as a matrix, as in |0 -1 -2 0 -2 -1 |
...............|0 0 0 2 2 3 |
(I apologize, i don't know how to make large square brackets..)
\begin{bmatrix}0 & -1 & -2 & 0 & -2 & -1 \\ 0 & 0 & 0 & 2 & 2 & 3\end{bmatrix}
(Click on that to see the code.)
Those are the coordinates of 6 points in two-dimensions. A 2 by 2 matrix, of the form
\begin{bmatrix}cos(\theta) & -sin(\theta) \\ sin(\theta) & cos(\theta)\end{bmatrix}
gives a
rotation around the origin through angle \theta. A
translation would, normally, be a vector to be added.
But you can, as chiro says, use "projective" coordinates, with point (x, y) represented by (x, y, 1) with the understanding that if some operation causes the third coordinate to change, we divide each coordinate by that to get back to 1- the point (ax, ay, a) is the same point as (x, y, 1). However, I think chiro is giving the case of projective coordinates in 3 dimensions so the matrix has 3+ 1= 4 rows and columns. If you are working in two dimensions so your matrix should have 2+ 1= 3 rows and columns.
Doing that, a translation, adding a to the x-coordinate and b to the y coordinate, is given by
\begin{bmatrix}1 & 0 & a \\ 0 & 1 & b \\ 0 & 0 & 1\end{bmatrix}\begin{bmatrix}x \\ y \\ 1\end{bmatrix}= \begin{bmatrix}x+ a\\ y+ b\\ 1\end{bmatrix}