# Simple Affine Stretch of Triangle

I am having a little trouble with the following problem:

Use explicit affine transformation, i.e., written down in matrix form, to stretch triangle having vertices $$(\frac{1}{2},0), (\frac{1}{2},\frac{1}{2}),(1,0)$$ to cover triangle with vertices $$(\frac{1}{2},1),(0,0),(1,0)$$.

Intuitively, we have a simple right triangle sitting in the plane. What we need to do is to stretch to cover the second one, which looks like we have adjoined the copy of initial one to form isosceles triangle. I am stuck on writing down explicitly what this transformation looks like. Any help is appreciated.

• – amd Apr 20 at 20:06

Since you’re being asked to represent an affine transformation as a single matrix, I presume that you’re familiar with homogeneous coordinates. So, you’re looking for a matrix of the form $$M=\begin{bmatrix}a_{11}&a_{12}&t_{1} \\ a_{21} & a_{22} & t_2 \\ 0&0&1\end{bmatrix}$$ such that $$M\left(\frac12,0,1\right)^T = \left(\frac12,1,1\right)^T \\ M\left(\frac12,\frac12,1\right)T = (0,0,1)^T \\ M(1,0,1)^T = (1,0,1)^T.$$ If you multiply these out, you will have a system of linear equations in the unknown entries of $$M$$ to solve.

On the other hand, if you package the three conditions up as a single matrix equation, you can derive an expression for $$M$$ as the product of two matrices. We have $$M \begin{bmatrix}\frac12&\frac12&1 \\ 0&\frac12&0 \\ 1&1&1\end{bmatrix} = \begin{bmatrix} \frac12&0&1 \\ 1&0&0 \\ 1&1&1 \end{bmatrix}$$ and since the matrix on the left-hand side is nonsingular (the triangle isn’t degenerate, so the homogeneous coordinates of its vertices are linearly independent), $$M = \begin{bmatrix}\frac12&0&1\\1&0&0\\1&1&1\end{bmatrix} \begin{bmatrix}\frac12&\frac12&1\\0&\frac12&0\\1&1&1\end{bmatrix}^{-1}.$$ Recall that the columns of a transformation matrix are the images of the basis vectors. Geometrically, then, the right-hand matrix maps the vertices of the first triangle to $$(1,0)$$, $$(0,1)$$ and $$(0,0)$$, respectively, and the left-hand matrix maps these points to the second triangle’s vertices.

Using your observation that the two triangles are isosceles and equal sides of each one are paired, you might instead try to compose the transformation out of more basic ones. There’s probably going to be a rotation and a scaling, together with a translation or two so that everything lines up correctly. Note, however, that there’s also an orientation change: the first triangle’s vertices are traversed clockwise, but the second one’s are traversed counterclockwise, so you’ll need to throw in a reflection as well. Here’s one possible sequence:

1. Translate by $$(-1,0)$$
2. Reflect in the $$x$$-axis
3. Rotate clockwise by 45°
4. Scale $$x$$ by $$\sqrt2$$ and $$y$$ by $$2\sqrt2$$
5. Translate by $$(1,0)$$.

You can either multiply the five matrices that represent these simpler transformations together, or work in coordinates, applying the formula for each transformation in turn, then extracting the elements of the composite matrix after simplifying the resulting expressions.

GENERAL EQUATION

There is a neat formula for your case $$\vec{P}(p_1; p_2) = (-1) \frac{ \det \begin{pmatrix} 0 & \vec{x} & \vec{y} & \vec{z} \\ p_1 & a_1 & b_1 & c_1 \\ p_2 & a_2 & b_2 & c_2 \\ 1 & 1 & 1 & 1 \\ \end{pmatrix} }{ \det \begin{pmatrix} a_1 & b_1 & c_1 \\ a_2 & b_2 & c_2 \\ 1 & 1 & 1 \\ \end{pmatrix} },$$ where $$p_1$$ and $$p_2$$ are coordinates of the point you are mapping, $$\vec{a}$$, $$\vec{b}$$, and $$\vec{c}$$ are certain points in the domain and $$\vec{x}$$, $$\vec{y}$$, and $$\vec{z}$$ are their images, namely $$\vec{P}: \vec{a} \rightarrow \vec{x};~ \vec{P}: \vec{b} \rightarrow \vec{y};~ \vec{P}: \vec{c} \rightarrow \vec{z}.$$

Here's how it works (plugging in initial points) $$\vec{P}(p_1; p_2) = (-1) \frac{ \det \begin{pmatrix} 0 & \vec{x} & \vec{y} & \vec{z} \\ p_1 & 1/2 & 1/2 & 1 \\ p_2 & 0 & 1/2 & 0 \\ 1 & 1 & 1 & 1 \\ \end{pmatrix} }{ \det \begin{pmatrix} 1/2 & 1/2 & 1 \\ 0 & 1/2 & 0 \\ 1 & 1 & 1 \\ \end{pmatrix} } = 2(\vec{z} - \vec{x}) p_1 + 2(\vec{y} - \vec{x}) p_2 + 2\vec{x} - \vec{z} =$$ now I plug in the final points $$= 2 \left[ \begin{pmatrix} 1 \\ 0 \end{pmatrix} - \begin{pmatrix} 1/2 \\ 1 \end{pmatrix} \right] p_1 + 2 \left[ \begin{pmatrix} 0 \\ 0 \end{pmatrix} - \begin{pmatrix} 1/2 \\ 1 \end{pmatrix} \right] p_2 + \left[ 2 \begin{pmatrix} 1/2 \\ 1 \end{pmatrix} - \begin{pmatrix} 1 \\ 0 \end{pmatrix} \right]$$ Simplification yields $$\vec{P}(p_1; p_2) = \begin{pmatrix} 1 \\ -2 \end{pmatrix} p_1 + \begin{pmatrix} -1 \\ -2 \end{pmatrix} p_2 + \begin{pmatrix} 0 \\ 2 \end{pmatrix}$$ Or you can write that in canonical form $$\vec{P}(p_1; p_2) = \begin{pmatrix} 1 & -1 \\ -2 & -2 \end{pmatrix} \begin{pmatrix} p_1 \\ p_2 \end{pmatrix} + \begin{pmatrix} 0 \\ 2 \end{pmatrix}$$ Now you may check that $$\vec{P}(1/2; 0) = \begin{pmatrix} 1/2 \\ 1 \end{pmatrix};~ \vec{P}(1/2; 1/2) = \begin{pmatrix} 0 \\ 0 \end{pmatrix};~ \vec{P}(1; 0) = \begin{pmatrix} 1 \\ 0 \end{pmatrix}.$$