1

Given the vertices of 2 triangles, as written below, how do I find a 4x4 homogeneous transformation matrix to describe the transformation from the first triangle to the second?

$$Triangle 1 = T_1 = \{(0,0)(0,1)(1,0)\}$$

$$Triangle 2 = T_2 = \{(1,1)(2,2)(3,1)\}$$

I can do this using 3x3 matrices, but am specifically asked for a 4x4 matrix. For 3x3 (below), I found the inverse of the matrix describing the first triangle in homogeneous coordinate. I multiplied that matrix by the homogeneous, 3x3 matrix of the second triangle, and ended up with a 3x3 transformation matrix. This matrix works, as when multiplied by $T_1$, you get $T_2$. I am assuming a 4x4 can be found by treating the z values as zeroes, but I'm not sure how to proceed. $$ T_2 = R_{trans}*T_1 => R_{trans} = T_2*T_1^{-1}$$ $$T_1 = \begin{bmatrix} 0 & 0 & 1\\ 0 & 1 & 0 \\ 1 & 1 & 1 \\ \end{bmatrix} $$

$$T_1^{-1} = \begin{bmatrix} -1 & -1 & 1\\ 0 & 1 & 0 \\ 1 & 0 & 0 \\ \end{bmatrix} $$ $$T_2*T_1^{-1} = \begin{bmatrix} 2 & 1 & 1\\ 0 & 1 & 1\\ 0 & 0 & 1 \\ \end{bmatrix} = R_{trans}$$

cl40
  • 45
  • 6
  • Since your triangles are express as two dimensional objects, their homogenous transformation is going to be 3-dimensional. To get 4D, just tack on another dimension whose value is always 0 (i.e., $T_1 = {(0,0,0), (0,1,0), (1,0,0)}$, etc. The effect on the transformation will be to add another row and colum which are $0$ everywhere except for $1$ on the diagonal. – Paul Sinclair Feb 05 '17 at 19:54
  • So I would end up with a 4x3 matrix for the triangle vertices? – cl40 Feb 06 '17 at 14:28

1 Answers1

1

The most likely reason to want a $4\times4$ matrix for this is because you want to leverage some technology which is geared towards 3d operations. So you can think of your 2d coordinates as embedded into a 3d space which in turn is represented using homogeneous coordinates.

In general an affine 2d operation would have the following matrix representation in projective 3d:

$$\begin{pmatrix}x'\\y'\\0\\1\end{pmatrix}=\begin{pmatrix} *&*&0&*\\ *&*&0&*\\ 0&0&1&0\\ 0&0&0&1 \end{pmatrix}\cdot\begin{pmatrix}x\\y\\0\\1\end{pmatrix}$$

So you essentially insert a row and column into the matrix, namely the third row and column in the above matrix, to indicate that the third coordinate should be left as it is. That way a zero $z$ coordinate on input will become a zero $z$ coordinate on output.

If your transformation is not affine but projective, you can use a more general form where the last row can have arbitrary values except in the thrid column. That's what I used in this post when representing a 2d projective transformation for use in a matrix3d CSS transformation.

MvG
  • 42,596